Sunrise & Sunset API
Free JSON endpoints for sunrise, sunset, the three twilights, golden hour, solar noon, day length and solar azimuth — for any city in our database. No API key, no signup, no attribution required (though a link back is appreciated).
Times are computed with Skyfield against the JPL DE421 ephemeris, and account for atmospheric refraction at the horizon. Every response is in the city's own local time zone, including daylight saving where it applies.
Monthly solar data
Returns one row per day for a given month, with the full set of solar events.
| Parameter | Type | Notes |
|---|---|---|
city_slug | string | City slug as used in our URLs — the tokyo in sunrise.am/tokyo/ |
year | integer | 1900–2999 |
month | integer | 1–12 |
Example
{
"city_slug": "tokyo",
"year": 2026,
"month": 7,
"month_label": "July 2026",
"days": [
{
"day": 1,
"sunrise_time": "04:29",
"sunset_time": "19:00",
"sunrise_azimuth_deg": 60.2,
"sunrise_cardinal": "ENE",
"sunset_azimuth_deg": 299.6,
"sunset_cardinal": "WNW",
"daylight_length_str": "14h 31m",
"daylight_diff_str": "-0m 04s",
"civil_twilight_start": "04:00",
"civil_twilight_end": "19:29",
"nautical_twilight_start": "03:20",
"nautical_twilight_end": "20:09",
"astro_twilight_start": "02:37",
"astro_twilight_end": "20:52",
"solar_noon_time": "11:44",
"solar_noon_sun_dist_mil_km": "152.09"
}
/* … one object per day of the month … */
]
}
Yearly series
Returns 365 (or 366) entries for a whole year, with times expressed as decimal hours — convenient for plotting a daylight curve.
Example
[
{
"date": "2026-01-01",
"sunrise": 6.853333333333333,
"sunset": 16.635833333333334,
"solar_noon": 11.742777777777777,
"civil_dawn": 6.371944444444444,
"civil_dusk": 17.1175,
"nautical_dawn": 5.843055555555555,
"nautical_dusk": 17.64611111111111,
"astronomical_dawn": 5.326388888888888,
"astronomical_dusk": 18.162777777777777,
"day_length_hours_str": "9h 46m"
}
/* … one object per day of the year … */
]
Decimal hours are local time: 6.8533 is 06:51:12. Multiply the
fractional part by 60 for minutes.
Finding a city slug
Slugs match our own URLs, so the simplest way to find one is to look the
city up on the site — browse all cities
or start from a country.
Slugs are lowercase, ASCII, hyphen-separated: sao-paulo,
new-york-city, hong-kong-city.
Errors
| Status | Meaning |
|---|---|
400 | Year or month outside the accepted range |
404 | No active city with that slug |
500 | City record is missing coordinates or a time zone |
Errors return JSON of the form {"error": "City not found"}.
Fair use
There is no hard rate limit today, which is a courtesy rather than a promise. Sustained heavy use without caching may be blocked.
Notes on accuracy
- Sunrise and sunset mark the moment the Sun's upper limb meets the visible horizon, with a standard refraction correction of 34 arcminutes applied. Real-world times vary by a minute or two with temperature and pressure.
- Times assume a flat horizon at sea level. Mountains, tall buildings or elevation will shift what you actually observe.
- Inside the polar circles some events do not occur at all. During polar day
or polar night the relevant fields come back as
N/Arather than a time — handle that case. - Azimuth is degrees clockwise from true north, not magnetic north.