Sunrise and sunset times by API, for any place and date
The best-known free option is sunrise-sunset.org: call api.sunrise-sunset.org/json with lat and lng and it returns sunrise, sunset, solar noon, day length and twilight times, with no key but a required link back to the site. Pass its tz parameter if you want local times. For golden hour and moon phase in the same answer, our Sunrise, Sunset and Moon Phase API returns all of it for $0.002 per call.
Try it free Sunrise & Sunset API — golden hour, moon phase, $0.002 · $0.002 / call
The free endpoint
Without tz, test your times carefully: the docs describe local times, but a test in December 2026 came back in UTC. The site asks every user to show a visible link to it.
# formatted=0 gives ISO 8601 times you can parse
https://api.sunrise-sunset.org/json?lat=48.8566&lng=2.3522&date=2026-06-21&formatted=0&tz=Europe/Paris
Do you need an API at all
Sunrise and sunset are astronomy, not live data. If your code runs in Python, the astral package computes them offline; in JavaScript, suncalc does the same. An API makes sense when you can't add a dependency (no-code tools, spreadsheets, AI agents) or you want a single answer with time zones already applied.
What our API returns
- Sunrise, sunset and solar noon, in UTC and, if you give a time zone, local time.
- Civil, nautical and astronomical dawn and dusk.
- Morning and evening golden hour (sun below 6 degrees), for photographers and outdoor apps.
- Day length as text and minutes, plus the sun's altitude at noon.
- Polar day and polar night detected and named, instead of empty fields.
- Moon phase name, phase fraction, percentage lit and whether it is waxing.
curl -i -X POST https://iamai.markets/api/x402/services/w1RU39upjaqr \
-H "Content-Type: application/json" \
-d '{"lat": 48.8566, "lon": 2.3522, "date": "2026-06-21", "timezone": "Europe/Paris"}'
# 402 with the price ($0.002), then your x402 client pays and repeats it
Accuracy you can expect
It's computed on our side with the suncalc formulas, so there is no outside service to wait for and dates from 1900 to 2200 work. Times assume sea level and a flat horizon; hills, buildings and air refraction can move the visible sunrise by a few minutes. That is the same assumption most free services make.
The product
Questions
Is the sunrise-sunset.org API free for commercial use?
It is free, and its terms ask for a visible link back. Read its page for the current conditions before you ship.
Does NOAA have a sunrise sunset API?
NOAA publishes a solar calculator and the formulas behind it rather than a JSON API. The libraries above use the same kind of maths.
What happens above the Arctic Circle in June?
Our API returns no sunrise or sunset and says "midnight sun", with a day length of 24 hours.
Related
Updated 2026-12-02
