Sunrise Sunset & Moon Phase API
Sunrise, sunset, solar noon, day length, civil/nautical/astronomical twilight and golden hour for any coordinates and date, plus moon phase, illumination, moonrise/moonset and next full and new moon. Times are returned in the local time zone, detected automatically from the coordinates.
Authentication & base URL
Subscribe through one of our marketplace listings; your marketplace API key and base URL are shown there. All endpoints return JSON over HTTPS, served from a global edge network (typically 20–150 ms).
Endpoints
GET /v1/sun
Sun times
| Parameter | In | Description | Example |
|---|---|---|---|
lat * | query | Latitude | 40.4168 |
lon * | query | Longitude | -3.7038 |
date | query | Date YYYY-MM-DD (default: today) | 2026-06-21 |
tz | query | IANA time zone for the returned times, or 'auto' (detected from coordinates) | auto |
GET /v1/moon
Moon phase and times
| Parameter | In | Description | Example |
|---|---|---|---|
lat * | query | Latitude | 40.4168 |
lon * | query | Longitude | -3.7038 |
date | query | Date YYYY-MM-DD (default: today) | 2026-06-21 |
tz | query | IANA time zone for the returned times, or 'auto' (detected from coordinates) | auto |
Example
GET /v1/sun?lat=40.4168&lon=-3.7038&date=2026-06-21&tz=auto
{
"lat": 40.4168,
"lon": -3.7038,
"timezone": "Europe/Madrid",
"date": "2026-06-21",
"sunrise": "2026-06-21T06:45:59+02:00",
"sunset": "2026-06-21T21:49:38+02:00",
"solarNoon": "2026-06-21T14:17:48+02:00",
"nadir": "2026-06-21T02:17:48+02:00",
"dayLength": "15h 3m 39s",
"dayLengthSeconds": 54219,
"civilTwilight": {
"dawn": "2026-06-21T06:12:47+02:00",
"dusk": "2026-06-21T22:22:49+02:00"
},
"nauticalTwilight": {
"dawn": "2026-06-21T05:30:30+02:00",
"dusk": "2026-06-21T23:05:06+02:00"
},
"astronomicalTwilight": {
"dawn": "2026-06-21T04:40:48+02:00",
"dusk": "2026-06-21T23:54:49+02:00"
},
"goldenHour": {
"morningEnds": "2026-06-21T07:27:04+02:00",
"eveningStarts": "2026-06-21T21:08:32+02:00"
},
"sunAltitudeAtNoonDeg": 73.02
}Sunrise, sunset, solar noon, day length, civil/nautical/astronomical twilight and golden hour for any coordinates and date, plus moon phase, illumination, moonrise/moonset and next full and new moon. Times are returned in the local time zone, detected automatically from the coordinates.
Use cases
Weather and outdoor apps, photography (golden hour planning), smart-home lighting automations, prayer and calendar apps, fishing and hunting apps, astronomy dashboards, solar energy estimates.
Why this API
- Fast: global edge network, answers in milliseconds.
- Local times out of the box: the time zone is detected from the coordinates (or pass tz).
- Handles polar day and polar night correctly.
- Moon phase name, emoji, illumination %, age and the next full/new moon in one call.
- Calculation based on the open-source SunCalc algorithm (BSD). Moon phase times are approximate (typically within a few hours).
- Fair pricing: Free plan 500 requests/month, Pro 25,000 for $4.99, Ultra 150,000 for $14.99.
Pricing
Free plan with 500 calls per month, then Pro (25,000 calls for $4.99/month) and Ultra (150,000 calls for $14.99/month). See all plans.