GET/v1/sun
Sunrise, sunset, solar noon, twilights and day length for a place and date
Times are UTC instants; add tz to get local wall-clock times as well. Inside the polar circles a day may have no sunrise or sunset — those fields are null and polar says which.
PARAMETERS
- latquery · numberREQUIRED
- Latitude in decimal degreese.g. 40.7128
- lonquery · numberREQUIRED
- Longitude in decimal degreese.g. -74.006
- datequery · string
- Civil date, YYYY-MM-DD (default: today, UTC)e.g. 2026-06-21
- tzquery · string
- IANA zone for local timese.g. America/New_York
REQUEST
curl "https://api.apialmanac.com/v1/sun?lat=40.7128&lon=-74.006" \ -H "X-API-Key: YOUR_KEY"
import requests
r = requests.get("https://api.apialmanac.com/v1/sun?lat=40.7128&lon=-74.006", headers={"X-API-Key": "YOUR_KEY"})
print(r.status_code, r.headers.get("X-Gw-Remaining"))
print(r.json())
const r = await fetch("https://api.apialmanac.com/v1/sun?lat=40.7128&lon=-74.006", {
headers: { "X-API-Key": "YOUR_KEY" }
});
console.log(r.status, r.headers.get("X-Gw-Remaining"));
console.log(await r.json());
RESPONSE
200OK
{
"date": "2026-06-21",
"location": {
"lat": 40.7128,
"lon": -74.006
},
"zone": "America/New_York",
"polar": null,
"sunrise": {
"utc": "2026-06-21T09:25:00Z",
"local": "2026-06-21T05:25:00-04:00"
},
"sunset": {
"utc": "2026-06-22T00:31:00Z",
"local": "2026-06-21T20:31:00-04:00"
},
"solar_noon": {
"utc": "2026-06-21T16:58:00Z",
"local": "2026-06-21T12:58:00-04:00"
},
"day_length": {
"seconds": 54360,
"text": "15h 06m"
},
"civil_twilight": {
"dawn": {
"utc": "2026-06-21T08:52:00Z"
},
"dusk": {
"utc": "2026-06-22T01:04:00Z"
}
},
"nautical_twilight": {
"dawn": {
"utc": "2026-06-21T08:10:00Z"
},
"dusk": {
"utc": "2026-06-22T01:46:00Z"
}
},
"astronomical_twilight": {
"dawn": {
"utc": "2026-06-21T07:22:00Z"
},
"dusk": {
"utc": "2026-06-22T02:34:00Z"
}
},
"golden_hour": {
"morning_end": {
"utc": "2026-06-21T10:03:00Z"
},
"evening_start": {
"utc": "2026-06-21T23:53:00Z"
}
},
"max_elevation_degrees": 72.7
}