Astronomy

Premium
ℹ️

Note: This is a premium API section. You need an active subscription to access these endpoints. View pricing

Solar event times for any location and date, including sunrise, sunset, twilight periods, and photography windows.

Lunar event times and phase information for any location and date.

Standards Used

  • ISO 8601
  • IANA TZDB
  • GeoNames
  • IATA

Polar Regions#

When the sun doesn't rise or set, sunrise and sunset are null and polar_condition indicates why:

  • midnight_sun - sun doesn't set (summer in polar latitudes)

  • polar_night - sun doesn't rise (winter in polar latitudes)

The Astronomy Objects#

Sun Object#

FieldTypeRequiredDescription
blue_hournull | objectNo
datestringYesDate (ISO 8601).
Example: 2024-06-21
day_lengthstringYesDay length as "HH:MM".
Example: 15:07
day_length_minutesinteger (int32)YesDay length in minutes.
Example: 907
golden_hournull | objectNo
locationobjectYes Location coordinates resolved from input.
latitudenumber (double)YesLatitude in decimal degrees.
Example: 40.7128
longitudenumber (double)YesLongitude in decimal degrees.
Example: -74.006
polar_conditionstringNoPolar condition if applicable (midnight_sun or polar_night).
Example: midnight_sun
solar_noonstringYesSolar noon time (ISO 8601).
Example: 2024-06-21T12:57:00-04:00
sunrisestringNoSunrise time (ISO 8601), null if sun doesn't rise.
Example: 2024-06-21T05:24:00-04:00
sunsetstringNoSunset time (ISO 8601), null if sun doesn't set.
Example: 2024-06-21T20:31:00-04:00
timezonestringYesIANA timezone used for times.
Example: America/New_York
twilightnull | objectNo

Moon Object#

FieldTypeRequiredDescription
age_daysnumber (double)YesDays since new moon.
Example: 14.5
datestringYesDate (ISO 8601).
Example: 2024-06-21
illuminationnumber (double)YesIllumination percentage (0-100).
Example: 99.5
locationobjectYes Location coordinates resolved from input.
latitudenumber (double)YesLatitude in decimal degrees.
Example: 40.7128
longitudenumber (double)YesLongitude in decimal degrees.
Example: -74.006
moonrisestringNoMoonrise time (ISO 8601), null if moon doesn't rise.
Example: 2024-06-21T19:45:00-04:00
moonsetstringNoMoonset time (ISO 8601), null if moon doesn't set.
Example: 2024-06-22T04:30:00-04:00
phasestringYesPhase identifier.
Example: full
phase_namestringYesHuman-readable phase name.
Example: Full Moon
timezonestringYesIANA timezone used for times.
Example: America/New_York

Moon Phase Values#

Schema 'MoonPhase' not found in OpenAPI specification.

Location Object#

FieldTypeRequiredDescription
latitudenumber (double)YesLatitude in decimal degrees.
Example: 40.7128
longitudenumber (double)YesLongitude in decimal degrees.
Example: -74.006

Twilight Object#

FieldTypeRequiredDescription
astronomicalobjectYes Twilight period with dawn and dusk times.
dawnstringNoDawn time (ISO 8601).
Example: 2024-06-21T04:30:00-04:00
duskstringNoDusk time (ISO 8601).
Example: 2024-06-21T21:15:00-04:00
civilobjectYes Twilight period with dawn and dusk times.
dawnstringNoDawn time (ISO 8601).
Example: 2024-06-21T04:30:00-04:00
duskstringNoDusk time (ISO 8601).
Example: 2024-06-21T21:15:00-04:00
nauticalobjectYes Twilight period with dawn and dusk times.
dawnstringNoDawn time (ISO 8601).
Example: 2024-06-21T04:30:00-04:00
duskstringNoDusk time (ISO 8601).
Example: 2024-06-21T21:15:00-04:00

PhotoHour Object#

Used for both golden_hour and blue_hour fields, containing morning and evening time windows.

FieldTypeRequiredDescription
eveningnull | objectNo
morningnull | objectNo

Endpoints#

Path Parameters

ParameterTypeRequiredDescription
locationpathstringYesCoordinates (lat,lon), city GeoNames ID, or airport IATA code

Query Parameters

ParameterTypeRequiredDescription
datequerystringNoDate (ISO 8601, YYYY-MM-DD). Defaults to today.
Example: 2024-06-21

Response

FieldTypeRequiredDescription
age_daysnumber (double)YesDays since new moon.
Example: 14.5
datestringYesDate (ISO 8601).
Example: 2024-06-21
illuminationnumber (double)YesIllumination percentage (0-100).
Example: 99.5
locationobjectYes Location coordinates resolved from input.
latitudenumber (double)YesLatitude in decimal degrees.
Example: 40.7128
longitudenumber (double)YesLongitude in decimal degrees.
Example: -74.006
moonrisestringNoMoonrise time (ISO 8601), null if moon doesn't rise.
Example: 2024-06-21T19:45:00-04:00
moonsetstringNoMoonset time (ISO 8601), null if moon doesn't set.
Example: 2024-06-22T04:30:00-04:00
phasestringYesPhase identifier.
Example: full
phase_namestringYesHuman-readable phase name.
Example: Full Moon
timezonestringYesIANA timezone used for times.
Example: America/New_York

Example Request

const response = await fetch(
  'https://worlddataapi.com/v1/moon/40.7128,-74.0060?date=2024-06-21',
  {
    headers: {
      'X-API-Key': 'YOUR_API_KEY'
    }
  }
);

const data = await response.json();

Error Responses

StatusDescription
400Invalid location or date
402Premium subscription required
404Location not found
429Rate limit exceeded

Path Parameters

ParameterTypeRequiredDescription
locationpathstringYesCoordinates (lat,lon), city GeoNames ID, or airport IATA code

Query Parameters

ParameterTypeRequiredDescription
datequerystringNoDate (ISO 8601, YYYY-MM-DD). Defaults to today.
Example: 2024-06-21

Response

FieldTypeRequiredDescription
blue_hournull | objectNo
datestringYesDate (ISO 8601).
Example: 2024-06-21
day_lengthstringYesDay length as "HH:MM".
Example: 15:07
day_length_minutesinteger (int32)YesDay length in minutes.
Example: 907
golden_hournull | objectNo
locationobjectYes Location coordinates resolved from input.
latitudenumber (double)YesLatitude in decimal degrees.
Example: 40.7128
longitudenumber (double)YesLongitude in decimal degrees.
Example: -74.006
polar_conditionstringNoPolar condition if applicable (midnight_sun or polar_night).
Example: midnight_sun
solar_noonstringYesSolar noon time (ISO 8601).
Example: 2024-06-21T12:57:00-04:00
sunrisestringNoSunrise time (ISO 8601), null if sun doesn't rise.
Example: 2024-06-21T05:24:00-04:00
sunsetstringNoSunset time (ISO 8601), null if sun doesn't set.
Example: 2024-06-21T20:31:00-04:00
timezonestringYesIANA timezone used for times.
Example: America/New_York
twilightnull | objectNo

Example Request

const response = await fetch(
  'https://worlddataapi.com/v1/sun/40.7128,-74.0060?date=2024-06-21',
  {
    headers: {
      'X-API-Key': 'YOUR_API_KEY'
    }
  }
);

const data = await response.json();

Error Responses

StatusDescription
400Invalid location or date
402Premium subscription required
404Location not found
429Rate limit exceeded