Public APIs
Sunrise and Sunset favicon

Sunrise and Sunset

Science & Math

Sunset and sunrise times for a given latitude and longitude.

Sunrise and Sunset's website screenshot

About Sunrise and Sunset

The Sunrise and Sunset API provides sunrise, sunset, twilight, golden hour, blue hour, solar position, and moon data for any location on Earth, given a latitude and longitude. Requests are made via a GET call to https://api.sunrise-sunset.org/v2, returning JSON, with support for a single date, a range of up to 366 days in one request, or a full year in one call. Plain HTTP is supported alongside HTTPS, making it usable by IoT and embedded devices such as Arduino and ESP8266 boards that cannot make TLS connections.

Response data includes sunrise/sunset times, civil/nautical/astronomical twilight boundaries, dawn/dusk, first/last light, golden hour and blue hour windows, solar noon, day length, solar azimuth and altitude, and moonrise/moonset with moon phase and illumination percentage. Times are returned in ISO 8601 format in the local timezone of the given coordinates by default, with an option to request Unix epoch seconds or a different named timezone. The API distinguishes polar-day and polar-night conditions and marks non-occurring events as null rather than inferring them from other fields.

The API is free to use with no sign-up or API key required, subject to reasonable request volume limits enforced via HTTP 429 responses with a Retry-After header. Attribution with a visible link to sunrise-sunset.org is required in any application or page displaying the data. It is suited to developers building applications, embedded/IoT devices, or websites that need astronomical timing data for a given location.

Key features

  • Sunrise, sunset, twilight (civil, nautical, astronomical), golden hour and blue hour times for any latitude/longitude
  • Solar position data including azimuth and altitude at sunrise, sunset and solar noon
  • Moonrise, moonset, moon phase and moon illumination percentage
  • Query a single day, a specific date, or up to a full year (366 days) in one request
  • Plain HTTP support for IoT and embedded devices like Arduino and ESP8266
  • Times returned in ISO 8601 or Unix epoch format, automatically in the location's local timezone

Frequently asked questions

Is the Sunrise-Sunset API free to use?

Yes, it's free of charge for reasonable request volumes with no sign up or API key required. Attribution with a visible link to sunrise-sunset.org is required.

What happens if I send too many requests?

The API responds with a 429 status code and a Retry-After header telling you how many seconds to wait before trying again.

What format is the API response in?

Responses are JSON, with times in ISO 8601 format by default (or Unix epoch seconds if requested), returned in the local timezone of the coordinates unless a different tz is specified.

Does it work with embedded devices like Arduino?

Yes, plain HTTP is supported alongside HTTPS, which is handy for IoT and embedded devices such as Arduino and ESP8266 that cannot make TLS connections.

Can I get a full year of data in one request?

Yes, using date_start and date_end parameters you can request up to 366 days of data in a single request, avoiding the need for daily calls.

Advertise here

Featured products

  • SerpApi - Search API favicon
  • Screenshot Scout favicon
  • TalorData favicon
  • CoreClaw favicon

Show your product to thousands of developers

· 100k monthly pageviews
· 7k newsletter subscribers

Advertise your product