Sunrise and sunset API
Give a date and coordinates; get sunrise, solar noon, sunset, day length and the three twilights, in local time with the UTC offset that applied that day (historical time zones and daylight saving are resolved from the coordinates), plus the UTC instant and a unix timestamp.
Get a free key Try it in the playground API reference
What you get
- Sunrise and sunset (upper limb, 34' refraction), solar noon, day length
- Civil, nautical and astronomical dawn and dusk (Sun at -6, -12, -18 degrees)
- Polar day and night stated explicitly instead of a missing value
- The same for the Moon and the planets on request
Example
curl -X POST https://astro-agent.dev/v1/astronomy/rise-set -H 'Content-Type: application/json' \
-H "X-Credits-Token: $ASTRO_AGENTS_KEY" -d '{"date":"2026-12-21","latitude":59.3293,"longitude":18.0686}'
A real answer to this request (excerpt). The same request always returns the same
result_sha256, which POST https://astro-agent.dev/v1/verify recomputes for free:
{
"endpoint": "astronomy/rise-set",
"result": {
"subject": {
"timezone": "Europe/Stockholm"
},
"sun": {
"civil_dawn": "2026-12-21T07:47:43+01:00",
"sunrise": "2026-12-21T08:43:24+01:00",
"solar_noon": "2026-12-21T11:45:46+01:00",
"sunset": "2026-12-21T14:48:08+01:00",
"civil_dusk": "2026-12-21T15:43:48+01:00",
"day_length_minutes": 364.7
}
},
"meta": {
"result_sha256": "450ffd67fe6f6e96f7a580ce2490f8d19af50ac58e7cf21f5b5fee6dd013227f"
}
}
Routes and prices
| Route | Name | Price per call | What it returns |
|---|---|---|---|
POST /v1/astronomy/rise-set | Rise, set and twilight times for a place | $0.01 | Rise, transit and set of the Sun, Moon and planets for a place and local day, with civil, nautical and astronomical twilight, day length, golden hour and blue hour. |
POST /v1/astronomy/day | Astronomical summary of the day for a place | $0.02 | One call for a day at a place: sunrise, sunset, twilight, day length, golden and blue hour; the Moon's phase, illumination, rise and set; the planets observable that night; the next lunations, planetary stations and eclipse. |
The same routes are MCP tools on https://astro-agent.dev/mcp.
Limits
- Dates from 1800 to 2200; range routes take up to a year per call.
- Without a key: 1 free call on the $0.01-0.02 routes, then HTTP 402 with a pay-per-call offer (USDC, x402).
- Free key (an email, no card): 10,000 calls a month, 30 a minute, personal, research and evaluation use only. Paid plans from $19 a month by card, for commercial use: see pricing.
- Past the quota, calls answer 429 until the 1st of the month: nothing is charged beyond the plan.
Alternatives
sunrise-sunset.org is free with no key (it asks for a visible attribution link) and sunrisesunset.io is free too. If you only need today's sunrise for a weather widget, they are the simpler choice.
Checked on the providers' own pages on 2026-11-20. Their terms may have changed since.
When Astro Agents fits
- No attribution link in your product, and commercial use on a paid plan
- Historical dates back to 1800 with the time zone that applied then
- One call that also returns golden hour, the Moon and tonight's planets (the day route)