Sun & Moon API
Sunrise, sunset, civil dawn and dusk, day length, moon phase, illumination, moonrise and moonset for any place and date, up to 7 days per call.
50 free requests, no credit card.
GET/api/v1/astronomyMonterey, California (local time)
{
"lat": 36.605,
"lon": -121.888,
"timezone": "America/Los_Angeles",
"date": "2026-10-18",
"days": 2,
"data": [
{
"date": "2026-10-18",
"sun": {
"sunrise": "07:18",
"sunset": "18:28",
"dawn": "06:52",
"dusk": "18:54",
"day_length": "11:10"
},
"moon": {
"phase": "waxing_crescent",
"illumination_pct": 48.9,
"age_days": 7.3,
"moonrise": "16:29",
"moonset": "01:36"
}
}
],
"port": {
"name": "Monterey Ca",
"slug": "monterey-ca",
"country": "United States"
}
}
Days per call1 to 7
Any datepast or future
Time zonelocal with port, UTC with lat/lon
Computationastronomical, no model
Request
GEThttps://tidesatlas.com/api/v1/astronomy
| Parameter | Type | Description |
|---|---|---|
lat, lon | float | Coordinates (decimal degrees). Times are returned in UTC. |
port | string | Instead of lat/lon: a station slug. Times are returned in the station's local time zone. |
date | YYYY-MM-DD | First day. Default: today. |
days | int | 1 to 7. Default 1. |
X-API-Key | header | Your API key (or ?api_key= in the query string). |
Code examples
curl "https://tidesatlas.com/api/v1/astronomy?port=monterey-ca&days=1" \ -H "X-API-Key: YOUR_KEY"
const params = new URLSearchParams({ port: 'monterey-ca', days: 1 });
const res = await fetch(`https://tidesatlas.com/api/v1/astronomy?${params}`, {
headers: { 'X-API-Key': 'YOUR_KEY' }
});
const data = await res.json();import requests
r = requests.get(
"https://tidesatlas.com/api/v1/astronomy",
params={"port": "monterey-ca", "days": 1},
headers={"X-API-Key": "YOUR_KEY"},
timeout=30,
)
data = r.json()$ch = curl_init('https://tidesatlas.com/api/v1/astronomy?port=monterey-ca&days=1');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: YOUR_KEY'],
]);
$data = json_decode(curl_exec($ch), true);Response
Real response for Monterey, California (local time), 18 October 2026 (arrays shortened).
{
"lat": 36.605,
"lon": -121.888,
"timezone": "America/Los_Angeles",
"date": "2026-10-18",
"days": 2,
"data": [
{
"date": "2026-10-18",
"sun": {
"sunrise": "07:18",
"sunset": "18:28",
"dawn": "06:52",
"dusk": "18:54",
"day_length": "11:10"
},
"moon": {
"phase": "waxing_crescent",
"illumination_pct": 48.9,
"age_days": 7.3,
"moonrise": "16:29",
"moonset": "01:36"
}
}
],
"port": {
"name": "Monterey Ca",
"slug": "monterey-ca",
"country": "United States"
}
}| Field | Meaning |
|---|---|
data[].sun.sunrise / sunset | Sunrise and sunset, HH:MM |
data[].sun.dawn / dusk | Civil twilight start and end |
data[].sun.day_length | Day length, HH:MM |
data[].moon.phase | new_moon, waxing_crescent, first_quarter, waxing_gibbous, full_moon, … |
data[].moon.illumination_pct / age_days | Illuminated fraction (%) and days since new moon |
data[].moon.moonrise / moonset | Moonrise and moonset, HH:MM |
Data sources
Computed on our servers with standard astronomical algorithms (solar position and lunar ephemeris). No external service, so responses are fast and available for any date.
Good to know
- With
lat/lonthe times are UTC: for places far from Greenwich, sunset can fall on the next UTC day. Useportto get local times. - Twilight is civil twilight (sun 6° below the horizon).
FAQ
Can I query a date in the past?
Yes, any date: pass date=YYYY-MM-DD.
Why do fishermen and photographers use it?
Moon phase drives tidal range (spring tides near new and full moon); dawn, dusk and moonrise plan the light.
Which plans include it?
The Complete pack, which also includes tides, and the weather-only pack. New accounts get 50 free requests; see the docs for current prices.