How does one get twilight information from the API?

  • 1
  • Question
  • Updated 2 years ago
I need to get the civil twilight information for a location and I would prefer to use the API to do so. Does anyone know how to get this information using the API?
Photo of jezra

jezra

  • 4 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
it seems your needs can be cleared by consuming the astronomy feature

see http://www.wunderground.com/weather/api/d/docs?d=data/astronomy for reference
Photo of jezra

jezra

  • 4 Posts
  • 0 Reply Likes
twilight is not part of the astronomy API
Photo of afelicioni

afelicioni

  • 227 Posts
  • 43 Reply Likes
ops.. my fault, so
TL;DR
You can't get civil twilight via Weather Underground API

Depending on the scenario, different alternative options could be available.
A quick search reveals that a broad user base is using formulae from Jean Meeus' Astronomical Algorithms, common software setups already supply classes, functions, components, libraries that are mostly based on it.

For example, with PHP you can get civil twilight via date_sun_info
(Edited)
Photo of jezra

jezra

  • 4 Posts
  • 0 Reply Likes
that is way too much work, I'll just use a regex to scrape the twilight data from the wunderground local astronomy webpage.
Photo of Vincenzo Manzoni

Vincenzo Manzoni

  • 2 Posts
  • 0 Reply Likes
i also need this information. i use python to ingest WU date, so I use pyephem and this help page for retrieve the civil twilight. however, it would be great to have the information in the astronomy feature (WU already has the information because it shows it in the webpage)
Photo of jezra

jezra

  • 4 Posts
  • 0 Reply Likes
It has been over a year since I made this request.
The solution that I found, was to use an API provided by http://www.aerisweather.com/