Overview
The Sunrise and Sunset API returns accurate sunrise, sunset, solar noon, and day length data for any latitude/longitude coordinate on Earth. It is completely free and requires no API key, making it one of the easiest APIs to start with. Use it to build apps that adapt content or UI based on daylight, from smart home automation to photography planning tools.
Beginner Tip
Pass any latitude and longitude plus a date to get precise solar times — for example, use your city coordinates to see today sunrise and sunset. All times are returned in UTC by default; add tzid=YOUR_TIMEZONE to get local times.
Measurement Record
What actually happened when we called this API from our own infrastructure. Every value below was recorded by the request, not copied from the provider's documentation.
- Request
- GET https://api.sunrise-sunset.org/json?lat=40.7128&lng=-74.0060&date=today&formatted=0
- Result
- HTTP 200 · application/json · 495 bytes · compressed
- Response time
- 186 ms (median of 3) · fastest 183 ms
- Transport
- TLSv1.3 · TLS_AES_256_GCM_SHA384 · certificate issued by Google Trust Services
- Browser CORS
- Allowed — Access-Control-Allow-Origin: *
- Served by
- cloudflare
- Recorded
- 2026-08-10
Fields Returned
Top-level fields present in the response we captured, with the type and value we actually received.
| Field | Type | Value received |
|---|---|---|
| sunrise | string (date) | 2026-08-10T10:00:18+00:00 |
| sunset | string (date) | 2026-08-11T00:02:26+00:00 |
| solar_noon | string (date) | 2026-08-10T17:01:22+00:00 |
| day_length | integer | 50528 |
| civil_twilight_begin | string (date) | 2026-08-10T09:31:59+00:00 |
| civil_twilight_end | string (date) | 2026-08-11T00:30:45+00:00 |
| nautical_twilight_begin | string (date) | 2026-08-10T08:55:36+00:00 |
| nautical_twilight_end | string (date) | 2026-08-11T01:07:08+00:00 |
| astronomical_twilight_begin | string (date) | 2026-08-10T08:16:10+00:00 |
| astronomical_twilight_end | string (date) | 2026-08-11T01:46:34+00:00 |
Captured Response
Captured from a real request to https://api.sunrise-sunset.org/json?lat=40.7128&lng=-74.0060&date=today&formatted=0 on 2026-08-10. Long arrays and nested objects are truncated to keep the shape readable.
{
"results": {
"sunrise": "2026-08-10T10:00:18+00:00",
"sunset": "2026-08-11T00:02:26+00:00",
"solar_noon": "2026-08-10T17:01:22+00:00",
"day_length": 50528,
"civil_twilight_begin": "2026-08-10T09:31:59+00:00",
"civil_twilight_end": "2026-08-11T00:30:45+00:00",
"nautical_twilight_begin": "2026-08-10T08:55:36+00:00",
"nautical_twilight_end": "2026-08-11T01:07:08+00:00",
"astronomical_twilight_begin": "2026-08-10T08:16:10+00:00",
"astronomical_twilight_end": "2026-08-11T01:46:34+00:00"
},
"status": "OK",
"tzid": "UTC"
} Field Reference
status Request status — OK on success or INVALID_REQUEST when parameters are wrong. Implementation Example
Calls a real endpoint of this API. Replace any placeholder credentials with your own key.
const url = "https://api.sunrise-sunset.org/json?lat=40.7128&lng=-74.0060&date=today&formatted=0";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data); What Can You Build?
Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.
How This API Fails
We deliberately sent this API a broken request and recorded exactly what came back on 2026-08-10. Knowing the shape of an error before you hit it makes error handling much easier to write.
Returned an HTML error page rather than JSON — worth knowing if your client assumes every response can be parsed as JSON.
Common Errors & Troubleshooting
Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.
Measured Score Breakdown
Live HTTP request to the API endpoint
Fully tested on Aug 10, 2026
Technical Specifications
Related Tags
Similar APIs
View All →arcsecond.io
⭐ Beginner's Pickarcsecond.io is a free astronomy API that aggregates data from multiple space databases, including stars, planets, exoplanets, and observing sites.
GBIF
⭐ Beginner's PickGBIF (Global Biodiversity Information Facility) is a free, open API providing access to hundreds of millions of species occurrence records from around the world.
iDigBio
iDigBio is a free API that gives you access to millions of digitized natural history museum specimens from institutions across the United States and beyond.
inspirehep.net
INSPIRE-HEP is a free REST API for the High Energy Physics literature database, covering papers, authors, institutions, conferences, and experiments in particle physics.
ISRO
⭐ Beginner's PickISRO is a free, no-auth API that provides detailed information about the Indian Space Research Organisation spacecraft and missions.