Astronomy API for Sunrise, Sunset, and Moon Phase Data
One Astronomy API call returns sun, moon, twilight, and golden hour data for any date, past or future, by coordinates, city, address, or IP. Free for 1,000 credits a day, at 1 credit per call.
ip:"216.73.216.193",
location:Object,
continent_code:"NA",
continent_name:"North America",
country_code2:"US",
country_code3:"USA",
country_name:"United States",
country_name_official:"United States of America",
is_eu:false,
state_prov:"Ohio",
state_code:"US-OH",
district:"Franklin",
city:"Columbus",
zipcode:"43215",
latitude:"39.96199",
longitude:"-83.00275",
locality:"Mile on High",
elevation:"235",
astronomy:Object,
date:"2026-11-27",
current_time:"06:23:51.315",
mid_night:"00:19",
night_end:"05:54",
morning:Object,
astronomical_twilight_begin:"05:54",
astronomical_twilight_end:"06:27",
nautical_twilight_begin:"06:27",
nautical_twilight_end:"07:00",
civil_twilight_begin:"07:00",
civil_twilight_end:"07:27",
blue_hour_begin:"06:49",
blue_hour_end:"07:12",
golden_hour_begin:"07:12",
golden_hour_end:"08:12",
sunrise:"07:27",
sunset:"17:11",
evening:Object,
golden_hour_begin:"16:27",
golden_hour_end:"17:27",
blue_hour_begin:"17:27",
blue_hour_end:"17:49",
civil_twilight_begin:"17:11",
civil_twilight_end:"17:38",
nautical_twilight_begin:"17:38",
nautical_twilight_end:"18:11",
astronomical_twilight_begin:"18:11",
astronomical_twilight_end:"18:44",
night_begin:"18:44",
sun_status:"-",
solar_noon:"12:19",
day_length:"09:43",
sun_altitude:-12.638361371445846,
sun_distance:147645925.76123366,
sun_azimuth:107.15482017333875,
moon_phase:"WANING_GIBBOUS",
moonrise:"20:20",
moonset:"11:00",
moon_status:"-",
moon_altitude:48.246455242719925,
moon_distance:361280.5323986267,
moon_azimuth:264.891764871841,
moon_parallactic_angle:57.90857396682848,
moon_illumination_percentage:"-88.29",
moon_angle:220.01501889662217,
Trusted by teams at
One Request, Every Sun and Moon Field
The Astronomy API returns sunrise, sunset, moonrise, moonset, moon phase, twilight, golden hour, and blue hour times for any location and any date. Query it with coordinates, an IPv4 or IPv6 address, a city name, or a street address. By default, event times use the local time zone for that place.
curl 'https://api.ipgeolocation.io/v3/astronomy?apiKey=API_KEY&lat=40.76473&long=-74.00084'{
"location": {
"latitude": "40.76473",
"longitude": "-74.00084",
"country_name": "United States",
"state_prov": "New York",
"city": "New York",
"locality": "Midtown West",
"elevation": "9"
},
"astronomy": {
"date": "2026-10-29",
"current_time": "06:33:56.040",
"mid_night": "00:39",
"night_end": "05:50",
"morning": {
"astronomical_twilight_begin": "05:50",
"astronomical_twilight_end": "06:22",
"nautical_twilight_begin": "06:22",
"nautical_twilight_end": "06:54",
"civil_twilight_begin": "06:54",
"civil_twilight_end": "07:22",
"blue_hour_begin": "06:44",
"blue_hour_end": "07:05",
"golden_hour_begin": "07:05",
"golden_hour_end": "08:01"
},
"sunrise": "07:22",
"sunset": "17:56",
"evening": {
"golden_hour_begin": "17:17",
"golden_hour_end": "18:13",
"blue_hour_begin": "18:13",
"blue_hour_end": "18:35",
"civil_twilight_begin": "17:56",
"civil_twilight_end": "18:24",
"nautical_twilight_begin": "18:24",
"nautical_twilight_end": "18:56",
"astronomical_twilight_begin": "18:56",
"astronomical_twilight_end": "19:28"
},
"night_begin": "19:28",
"sun_status": "-",
"solar_noon": "12:39",
"day_length": "10:33",
"sun_altitude": -9.869168560046097,
"sun_distance": 148631813.8153374,
"sun_azimuth": 99.40906748202292,
"moon_phase": "WANING_GIBBOUS",
"moonrise": "20:30",
"moonset": "11:43",
"moon_status": "-",
"moon_altitude": 52.608971139098124,
"moon_distance": 364605.1626589418,
"moon_azimuth": 263.3038592927023,
"moon_parallactic_angle": 58.17925492923368,
"moon_illumination_percentage": "-85.67",
"moon_angle": 224.48474531450978
}
}Astronomy by City or Address
Get astronomical information for any city, street address, or named location. Pass a location as a query parameter to retrieve sunrise, sunset, moonrise, moonset, twilight times, golden hour, blue hour, and other astronomical data for that location.
Full API Docscurl 'https://api.ipgeolocation.io/v3/astronomy?apiKey=API_KEY&location=New%20York'{
"location": {
"location_string": "New York",
"country_name": "United States",
"state_prov": "New York",
"city": "New York",
"locality": "",
"latitude": "40.71273",
"longitude": "-74.00602",
"elevation": "6"
},
"astronomy": {
"date": "2026-10-29",
"current_time": "06:33:56.534",
"mid_night": "00:39",
"night_end": "05:50",
"morning": {
"astronomical_twilight_begin": "05:50",
"astronomical_twilight_end": "06:22",
"nautical_twilight_begin": "06:22",
"nautical_twilight_end": "06:54",
"civil_twilight_begin": "06:54",
"civil_twilight_end": "07:22",
"blue_hour_begin": "06:44",
"blue_hour_end": "07:05",
"golden_hour_begin": "07:05",
"golden_hour_end": "08:01"
},
"sunrise": "07:22",
"sunset": "17:56",
"evening": {
"golden_hour_begin": "17:17",
"golden_hour_end": "18:13",
"blue_hour_begin": "18:13",
"blue_hour_end": "18:35",
"civil_twilight_begin": "17:56",
"civil_twilight_end": "18:24",
"nautical_twilight_begin": "18:24",
"nautical_twilight_end": "18:56",
"astronomical_twilight_begin": "18:56",
"astronomical_twilight_end": "19:28"
},
"night_begin": "19:28",
"sun_status": "-",
"solar_noon": "12:39",
"day_length": "10:34",
"sun_altitude": -9.86299503761222,
"sun_distance": 148631813.8153374,
"sun_azimuth": 99.41602438618526,
"moon_phase": "WANING_GIBBOUS",
"moonrise": "20:31",
"moonset": "11:43",
"moon_status": "-",
"moon_altitude": 52.61741568059783,
"moon_distance": 364605.1661316123,
"moon_azimuth": 263.3689600954356,
"moon_parallactic_angle": 58.2638340362214,
"moon_illumination_percentage": "-85.67",
"moon_angle": 224.48482345746874
}
}Astronomy by IP Address
Get astronomical information based on an IPv4 or IPv6 address. The API automatically resolves the IP address to its location and returns sunrise, sunset, moonrise, moonset, twilight times, golden hour, blue hour, and other astronomical data.
Full API Docscurl 'https://api.ipgeolocation.io/v3/astronomy?apiKey=API_KEY&ip=8.8.8.8'{
"ip": "8.8.8.8",
"location": {
"continent_code": "NA",
"continent_name": "North America",
"country_code2": "US",
"country_code3": "USA",
"country_name": "United States",
"country_name_official": "United States of America",
"is_eu": false,
"state_prov": "California",
"state_code": "US-CA",
"district": "Santa Clara",
"city": "Mountain View",
"zipcode": "94043-1351",
"latitude": "37.42240",
"longitude": "-122.08421",
"locality": "Charleston Terrace",
"elevation": "3"
},
"astronomy": {
"date": "2026-10-29",
"current_time": "03:33:56.039",
"mid_night": "00:52",
"night_end": "06:02",
"morning": {
"astronomical_twilight_begin": "06:02",
"astronomical_twilight_end": "06:32",
"nautical_twilight_begin": "06:32",
"nautical_twilight_end": "07:03",
"civil_twilight_begin": "07:03",
"civil_twilight_end": "07:30",
"blue_hour_begin": "06:53",
"blue_hour_end": "07:13",
"golden_hour_begin": "07:13",
"golden_hour_end": "08:06"
},
"sunrise": "07:30",
"sunset": "18:13",
"evening": {
"golden_hour_begin": "17:37",
"golden_hour_end": "18:29",
"blue_hour_begin": "18:29",
"blue_hour_end": "18:50",
"civil_twilight_begin": "18:13",
"civil_twilight_end": "18:40",
"nautical_twilight_begin": "18:40",
"nautical_twilight_end": "19:10",
"astronomical_twilight_begin": "19:10",
"astronomical_twilight_end": "19:41"
},
"night_begin": "19:41",
"sun_status": "-",
"solar_noon": "12:51",
"day_length": "10:43",
"sun_altitude": -46.85301788883555,
"sun_distance": 148631813.8153374,
"sun_azimuth": 67.31450511528658,
"moon_phase": "WANING_GIBBOUS",
"moonrise": "21:05",
"moonset": "11:50",
"moon_status": "-",
"moon_altitude": 79.38111034286753,
"moon_distance": 364605.1626519111,
"moon_azimuth": 154.59096812163125,
"moon_parallactic_angle": -22.638676928232154,
"moon_illumination_percentage": "-85.67",
"moon_angle": 224.48474515618548
}
}What the Astronomy API Returns
Four groups of fields provide a complete view of astronomical events for any point and time on Earth.
Location Context
Columbus, United StatesEvery response resolves the place you asked about: city, state, country, coordinates, and elevation. Ask by IP and the API geolocates it first; ask by address and it geocodes it. Times come back in that location's own time zone.
See the Astronomy API documentation for a complete field-by-field reference
Moon Phases and Lunar Data
Moonrise, moonset, phase, illumination, and position for any date and place.
Live data for Columbus, United States
Waning Gibbous
88.29%
View the complete moon fields reference in the Astronomy API documentation.
How Sunrise and Sunset Times Are Calculated
The Astronomy API computes Sun and Moon events from their position relative to your local horizon, using your coordinates, date, elevation, and time zone to produce accurate local event times.
Standard solar depression angles, as defined by the U.S. Naval Observatory, govern our twilight fields.
- Civil twilight spans zero to six degrees below the horizon.
- Nautical twilight spans six to twelve degrees below the horizon.
- Astronomical twilight spans twelve to eighteen degrees below the horizon.
One honest caveat: no provider can promise observed rise times to the second, because refraction bends with that day's atmosphere. The USNO notes computed times can differ from observation by a minute or more, longer at high latitudes. We compute the convention precisely and say so plainly.
Astronomy Data for Any Date, or 90 Days at Once
Pass date and the same request returns any past or future day. Need a range? The timeSeries endpoint returns up to 90 days of sunrise, sunset, twilight, and moon data in a single call, one row per day, for calendars, almanac features, and solar planning.
curl -X GET 'https://api.ipgeolocation.io/v3/astronomy/timeSeries?apiKey=<YOUR_API_KEY>&lat=40.76473&long=-74.00084&dateStart=2026-10-26&dateEnd=2026-10-28'{
"location": {
"latitude": "40.76473",
"longitude": "-74.00084",
"country_name": "United States",
"state_prov": "New York",
"city": "New York",
"locality": "Midtown West",
"elevation": "9"
},
"astronomy": [
{
"date": "2026-10-26",
"mid_night": "00:40",
"night_end": "05:47",
"morning": {
"astronomical_twilight_begin": "05:47",
"astronomical_twilight_end": "06:19",
"nautical_twilight_begin": "06:19",
"nautical_twilight_end": "06:51",
"civil_twilight_begin": "06:51",
"civil_twilight_end": "07:19",
"blue_hour_begin": "06:40",
"blue_hour_end": "07:02",
"golden_hour_begin": "07:02",
"golden_hour_end": "07:57"
},
"sunrise": "07:19",
"sunset": "18:00",
"evening": {
"golden_hour_begin": "17:21",
"golden_hour_end": "18:17",
"blue_hour_begin": "18:17",
"blue_hour_end": "18:38",
"civil_twilight_begin": "18:00",
"civil_twilight_end": "18:27",
"nautical_twilight_begin": "18:27",
"nautical_twilight_end": "18:59",
"astronomical_twilight_begin": "18:59",
"astronomical_twilight_end": "19:31"
},
"night_begin": "19:31",
"sun_status": "-",
"solar_noon": "12:39",
"day_length": "10:41",
"moon_phase": "FULL_MOON",
"moonrise": "17:57",
"moonset": "07:56",
"moon_status": "-"
},
{
"date": "2026-10-27",
"mid_night": "00:40",
"night_end": "05:48",
"morning": {
"astronomical_twilight_begin": "05:48",
"astronomical_twilight_end": "06:20",
"nautical_twilight_begin": "06:20",
"nautical_twilight_end": "06:52",
"civil_twilight_begin": "06:52",
"civil_twilight_end": "07:20",
"blue_hour_begin": "06:41",
"blue_hour_end": "07:03",
"golden_hour_begin": "07:03",
"golden_hour_end": "07:59"
},
"sunrise": "07:20",
"sunset": "17:59",
"evening": {
"golden_hour_begin": "17:20",
"golden_hour_end": "18:15",
"blue_hour_begin": "18:15",
"blue_hour_end": "18:37",
"civil_twilight_begin": "17:59",
"civil_twilight_end": "18:26",
"nautical_twilight_begin": "18:26",
"nautical_twilight_end": "18:58",
"astronomical_twilight_begin": "18:58",
"astronomical_twilight_end": "19:30"
},
"night_begin": "19:30",
"sun_status": "-",
"solar_noon": "12:39",
"day_length": "10:38",
"moon_phase": "FULL_MOON",
"moonrise": "18:37",
"moonset": "09:15",
"moon_status": "-"
},
{
"date": "2026-10-28",
"mid_night": "00:39",
"night_end": "05:49",
"morning": {
"astronomical_twilight_begin": "05:49",
"astronomical_twilight_end": "06:21",
"nautical_twilight_begin": "06:21",
"nautical_twilight_end": "06:53",
"civil_twilight_begin": "06:53",
"civil_twilight_end": "07:21",
"blue_hour_begin": "06:42",
"blue_hour_end": "07:04",
"golden_hour_begin": "07:04",
"golden_hour_end": "08:00"
},
"sunrise": "07:21",
"sunset": "17:57",
"evening": {
"golden_hour_begin": "17:18",
"golden_hour_end": "18:14",
"blue_hour_begin": "18:14",
"blue_hour_end": "18:36",
"civil_twilight_begin": "17:57",
"civil_twilight_end": "18:25",
"nautical_twilight_begin": "18:25",
"nautical_twilight_end": "18:57",
"astronomical_twilight_begin": "18:57",
"astronomical_twilight_end": "19:29"
},
"night_begin": "19:29",
"sun_status": "-",
"solar_noon": "12:39",
"day_length": "10:36",
"moon_phase": "WANING_GIBBOUS",
"moonrise": "19:28",
"moonset": "10:32",
"moon_status": "-"
}
]
}See the Astronomy API documentation for a complete field-by-field reference
Use Cases
Prayer Time Applications
Daily prayer schedules are anchored to the sun: dawn and dusk prayers to twilight boundaries, midday to solar noon, sunset prayers to the sunset itself. The API returns each boundary per location per date for a perfect prayer times app.
Photography and Golden Hour Planning
Golden hour and blue hour windows, per date, per location, in local time. A photo-planning app can tell a photographer in Santorini exactly when the light turns and how long it lasts, from one request made with nothing more than the town's name.
Solar Energy and Panel Placement
sun_altitude and sun_azimuth by street address give the sun's current position at a site without a site survey. Pull a 90-day timeSeries for daily sunrise, sunset, solar noon and day length to estimate seasonal yield windows. Time series entries do not include altitude or azimuth, so modeling full sun paths requires separately sampled position data.
Smart Home and IoT Scheduling
Lights at sunset, blinds at golden hour, irrigation before dawn. Because the API accepts an IP address, a hub can schedule against real local sun times with no GPS hardware and no user setup, and re-resolve automatically when the device changes networks.
Travel and Outdoor Apps
Day length and daylight windows by city power safe-hiking cutoffs, sunrise summit alerts, and itinerary planning. Add moonrise, moonset, and phase for stargazing features: a WANING_CRESCENT sky is dark enough for the Milky Way, a FULL_MOON night is not.
Astronomy API FAQs
time_zone parameter with any IANA name, and timestamps then include the full date.date parameter returns any single past or future date, and the timeSeries endpoint returns up to 90 days in one call: pass dateStart and dateEnd with your location and you get one entry per day, covering sun, twilight, and moon fields. It is the practical way to build calendars and seasonal charts.sun_status reads "Always above the twilight angle" or "Always below the twilight angle". The moon behaves the same way through moon_status. Your code can branch on the status fields rather than parsing sentinel times.ip parameter, or with no parameter to use the caller's own IP. The API geolocates the address, resolves its time zone, and returns sunrise, sunset, twilight, and moon data for that place in local time. One request does the whole chain: no separate geolocation lookup, no coordinate handling.elevation tightens results for observers above sea level. For details, see our practical guide.Start with 1,000 Free
Astronomy Credits a Day
Sunrise to moonset in one request. Get sun, moon, twilight, and golden hour data for any place and date on Earth, backed by a 99.99% uptime SLA. No credit card required.