Home / APIs / Sun & Moon Times

Sun & Moon Times API

Sunrise, sunset, golden hour, solar position, and moon phase for any coordinate and date.

Coming soon 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.

Endpoints

MethodPathDescription
GET/timessun event times
GET/positionsun azimuth/altitude
GET/moonphase/illumination
GET/moon-timesmoonrise/set

Quick start

cURL (via RapidAPI)
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 '{}'
JavaScript (fetch)
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();
Example response
{
  "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.

Basic
Free
1,000 requests / mo
Pro
$5 / mo
100,000 requests / mo
Ultra
$20 / mo
1,000,000 requests / mo
Mega
$50 / mo
2,000,000 requests / mo

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.

Coming soon on RapidAPI ↗