Sunrise-Sunset times
Sunrise, sunset, solar noon and twilight times for a place and date.
Address that will be called:
What it gives you
Sunrise, sunset, solar noon and twilight times for a place and date. With formatted=0 the times are in ISO 8601 format in UTC.
Terms and limits
The documentation says the API is free to use with no sign-up or key, and that attribution is required: show a visible link to sunrise-sunset.org on the page where you show the data. The page describes a newer version 2, and says the version 1 address used here is unchanged and supported.
_Read on 14 November 2026 from sunrise-sunset.org/api._
Good habits
- Cache answers that do not change often.
- Handle errors: the service may be busy or down.
- Give credit where the terms ask for it.
- Do not put secret keys into a web page: this API needs none, but many others do.
The same request in code
curl
curl -L "https://api.sunrise-sunset.org/json?lat=30.9&lng=75.85&formatted=0"Python
import json, urllib.request
with urllib.request.urlopen("https://api.sunrise-sunset.org/json?lat=30.9&lng=75.85&formatted=0") as r:
data = json.load(r)
print(data['results'])JavaScript (browser or Node.js)
const res = await fetch("https://api.sunrise-sunset.org/json?lat=30.9&lng=75.85&formatted=0");
const data = await res.json();
console.log(data.results);A real answer
This is what the example request above returned when we called it on 14 November 2026 with the default values (it took about 0.5 s from our computer). Values such as times and temperatures change.
{
"results": {
"sunrise": "2026-11-14T01:22:14+00:00",
"sunset": "2026-11-14T11:59:44+00:00",
"solar_noon": "2026-11-14T06:40:59+00:00",
"day_length": 38250,
"civil_twilight_begin": "2026-11-14T00:56:49+00:00",
"civil_twilight_end": "2026-11-14T12:25:09+00:00",
"nautical_twilight_begin": "2026-11-14T00:27:43+00:00",
"nautical_twilight_end": "2026-11-14T12:54:15+00:00",
"astronomical_twilight_begin": "2026-11-13T23:59:03+00:00",
"astronomical_twilight_end": "2026-11-14T13:22:55+00:00"
},
"status": "OK",
"tzid": "UTC"
}This is an independent directory. It is not connected with any of the services listed. Each address was called on 14 November 2026 with curl, Python, Node.js and Chrome (from a page on another site), and the answer shown is a real one. APIs change: check the service's own page before you depend on it.