Sunrise, sunset and moon phase API
Sunrise, sunset, solar noon, day length, the three twilights and the moon phase for any coordinates and date.
GET /v1/sun1 creditAbout $0.001Try it
curl 'https://api.apifor.dev/v1/sun?lat=-6.2&lng=106.8167&date=2026-11-28&tz=%2B07:00' \
-H 'x-api-key: YOUR_API_KEY'{
"success": true,
"data": {
"date": "2026-11-28",
"lat": -6.2,
"lng": 106.8167,
"timezone": "+07:00",
"sunrise": "05:26",
"sunset": "17:53",
"solar_noon": "11:40",
"day_length_seconds": 44795,
"polar": null,
"twilight": {
"civil": {
"dawn": "05:04",
"dusk": "18:15"
},
"nautical": {
"dawn": "04:38",
"dusk": "18:41"
},
"astronomical": {
"dawn": "04:11",
"dusk": "19:08"
}
},
"moon": {
"phase": "Waning Gibbous",
"illumination": 0.797,
"age_days": 19.16,
"trend": "waning",
"elongation_degrees": 126.4,
"at": "2026-11-28T12:00:00Z"
},
"solar_declination": -21.267,
"equation_of_time_minutes": 12.7,
"times_note": "Times are HH:MM in the requested tz (default UTC). Sunrise and sunset include standard refraction (zenith 90.833°)."
},
"meta": {
"attribution": {
"source": "Computed by APIFor (NOAA/USNO solar formulae, Meeus lunar phase, tabular Islamic calendar)",
"license": "MIT",
"license_url": "https://opensource.org/license/mit",
"source_url": "https://gml.noaa.gov/grad/solcalc/calcdetails.html",
"attribution_page": "https://apifor.dev/sources",
"notice": "Calculated on request. Sunrise and sunset are typically within 1 to 2 minutes of observed times."
}
}
}A real response from our OpenAPI file, with long lists and strings shortened.
Endpoints and price
| Endpoint | Credits | About |
|---|---|---|
GET /v1/sun | 1 credit | $0.001 |
GET /v1/sun/coverage (Free) | Free | $0 |
USD at Starter pack prices ($5 for 5,000 credits). Calls that fail before work starts are refunded.
Coverage today
Works for any country.
Sources, row counts and country-only fields per country: GET /v1/sun/coverage, free with your API key. How coverage works
Limits
- Dates from 1900 to 2100.
- tz takes a UTC offset such as +07:00 or an IANA zone such as Asia/Tokyo.
- Near the poles sunrise and sunset can be null, with polar set to polar_night or midnight_sun.
Questions
How accurate is it?
Sunrise and sunset use standard refraction and are usually within a minute or two of observed times.
Which time is the moon phase for?
12:00 UTC on the date you ask for.