Free Sunrise, Sunset & Moon API
发布时间:2026-09-01 | 浏览:1
JSON sunrise, sunset, twilight, golden hour and moon data for any point on Earth. One GET request, no signup.
No signup, no API key, no credit card. Just link back to sunrisesunset.io.
Cloudflare Workers in 300+ cities. P99 under 50 ms.
One request returns a full year of daily data via date_start + date_end.
One endpoint returns rise, set, azimuth, altitude, moon phase, golden and blue hour.
Hits the live API from your browser. Same request your own front-end would make.
Example requests
Standard https://api.sunrisesunset.io/json?lat=38.907192&lng=-77.036873 Copy
Specific date https://api.sunrisesunset.io/json?lat=38.907192&lng=-77.036873&date=2026-06-21&timezone=UTC Copy
One-year range https://api.sunrisesunset.io/json?lat=38.907192&lng=-77.036873&date_start=2026-01-01&date_end=2026-12-31 Copy
24-hour times https://api.sunrisesunset.io/json?lat=38.907192&lng=-77.036873&time_format=24 Copy
Unix timestamps https://api.sunrisesunset.io/json?lat=38.907192&lng=-77.036873&time_format=unix Copy
ISO 8601 https://api.sunrisesunset.io/json?lat=38.907192&lng=-77.036873&formatted=0 Copy
All sent as query-string values on a single GET request.
Response fields
Wrapped in { results, status, tzid } . results is a single object, or an array when a date range is used.
Returned in the status field. HTTP status tracks it: 200 for OK and INVALID_TZID (which still returns data), 400 for bad input, 500 for server errors.
OK Request succeeded.
INVALID_TZID Timezone didn't validate. Fell back to the location's own zone and returned data anyway.
INVALID_REQUEST Missing or malformed lat/lng.
INVALID_DATE Unparseable date, or a range longer than one year.
UNKNOWN_ERROR Something broke on our end. Retry.
Building with an AI assistant?
Paste this into ChatGPT, Claude or Cursor, then ask for the code you want. It includes every parameter and field, plus the edge cases that break first drafts: nulls at the poles, utc_offset in minutes, times as strings rather than dates.
There's also an OpenAPI 3.0 spec at api.sunrisesunset.io/openapi.yaml for Postman, Insomnia, or generating a typed client.
Free for personal and commercial use. All we ask is a visible backlink, so paste this anywhere on your site:
Aug 2, 2026 Golden hour and blue hour as begin/end windows, morning and evening. New sun_status field separates midnight sun from polar night. Additive only; every existing field is unchanged, including golden_hour.
Golden hour and blue hour as begin/end windows, morning and evening. New sun_status field separates midnight sun from polar night. Additive only; every existing field is unchanged, including golden_hour.
Apr 4, 2026 Moon data (rise/set, phase, illumination), sun altitude/azimuth at solar noon + rise + set, automatic elevation from terrain.
Moon data (rise/set, phase, illumination), sun altitude/azimuth at solar noon + rise + set, automatic elevation from terrain.
Jan 14, 2026 JSONP callback, formatted=0 for ISO 8601 output, nautical twilight fields, granular status codes.
JSONP callback, formatted=0 for ISO 8601 output, nautical twilight fields, granular status codes.
Apr 13, 2025 Fixed a DST edge-case that could return the wrong day at the boundary.
Fixed a DST edge-case that could return the wrong day at the boundary.
Jul 30, 2024 time_format option (12, 24, military, unix).
time_format option (12, 24, military, unix).
Nov 29, 2023 date_start + date_end range queries, up to 365 days.
date_start + date_end range queries, up to 365 days.
Oct 13, 2023 Lower response times; migrated onto Cloudflare Workers.
Lower response times; migrated onto Cloudflare Workers.
May 26, 2023 utc_offset added to responses.
utc_offset added to responses.
Jun 21, 2022 first_light + last_light fields (astronomical twilight).
first_light + last_light fields (astronomical twilight).
Jun 9, 2022 API released.
Watching the API? Status page