Sun & Moon Times API
Sunrise, sunset, golden hour, solar position, and moon phase for any coordinate and date.
Get it on RapidAPI ↗Sun & Moon Times computes solar and lunar events for any coordinate and date, powered by SunCalc. Get the full set of sun times (sunrise, sunset, solar noon, dawn, dusk, golden hour, and more) as ISO timestamps, the sun's azimuth and altitude, the moon's phase and illumination, and moonrise/moonset with always-up/always-down flags.
Pure astronomical math — no location data is logged. Perfect for photography (golden-hour) apps, weather and outdoor tools, smart-home automation, and calendars.
Step-by-step tutorial: Sunrise & Sunset API: Golden Hour, Solar Position, Moon Phase
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /times | sun event times |
| GET | /position | sun azimuth/altitude |
| GET | /moon | phase/illumination |
| GET | /moon-times | moonrise/set |
Quick start
curl --request curl \
--url 'https://sun-moon-times.p.rapidapi.com/-G "https://sun-moon-times.p.rapidapi.com/times" -d "lat=51.5074" -d "lng=-0.1278" -d "date=2023-09-21" -H "X-RapidAPI-Key: YOUR_KEY" -H "X-RapidAPI-Host: sun-moon-times.p.rapidapi.com"' \
--header 'X-RapidAPI-Key: YOUR_KEY' \
--header 'X-RapidAPI-Host: sun-moon-times.p.rapidapi.com' \
--header 'content-type: application/json' \
--data '{}'const res = await fetch('https://sun-moon-times.p.rapidapi.com/-G "https://sun-moon-times.p.rapidapi.com/times" -d "lat=51.5074" -d "lng=-0.1278" -d "date=2023-09-21" -H "X-RapidAPI-Key: YOUR_KEY" -H "X-RapidAPI-Host: sun-moon-times.p.rapidapi.com"', {
method: 'curl',
headers: {
'X-RapidAPI-Key': 'YOUR_KEY',
'X-RapidAPI-Host': 'sun-moon-times.p.rapidapi.com',
'content-type': 'application/json'
},
body: JSON.stringify({})
});
const data = await res.json();{
"date": "2023-09-21T00:00:00.000Z",
"latitude": 51.5074,
"longitude": -0.1278,
"times": {
"solarNoon": "2023-09-20T11:55:29.406Z",
"sunrise": "2023-09-20T05:43:52.939Z",
"sunset": "2023-09-20T18:07:05.873Z",
"dawn": "2023-09-20T05:10:27.254Z",
"dusk": "2023-09-20T18:40:31.558Z",
"goldenHour": "2023-09-20T17:23:00.000Z"
}
}Pricing
Subscribe on RapidAPI. Start free; upgrade as you scale.
For AI agents
Programmatic discovery and keyless testing:
- OpenAPI spec:
https://abundanceapis.com/openapi/sun-moon-times.json - MCP server (keyless trial):
https://abundanceapis.com/mcp— add this Streamable-HTTP MCP endpoint in Claude, Cursor, or any MCP client, then calllist_apisand the sample tools. - Production: subscribe on RapidAPI and send
X-RapidAPI-Key+X-RapidAPI-Host: sun-moon-times.p.rapidapi.com.
Frequently asked questions
Is timezone considered?
Times are returned in UTC unless a timezone offset is supplied.
Accuracy?
Based on NOAA algorithms, accurate within a minute.
Data retention?
No location data is stored after the request.
Ready to build with Sun & Moon Times?
Grab your key on RapidAPI and start on the free tier.
Get it on RapidAPI ↗