Date & Time
Sunrise & Sunset API
Compute sunrise, sunset, solar noon, and day length for any location and date using the NOAA solar algorithm.
Request Headers
| Name | Required | Description |
|---|---|---|
X-RapidAPI-Key | required | Your RapidAPI key. Get one free. |
X-RapidAPI-Host | required | sunrise-sunset.p.rapidapi.com |
Endpoints
GET
/v1/astronomy/sun Compute sunrise, sunset, solar noon, and day length for a location
Parameters
| Name | Type | Required | Default | Constraints |
|---|---|---|---|---|
date | string | required | — | matches \S |
lat | number | required | — | -90-90 |
lon | number | required | — | -180-180 |
Code Examples
curl --request GET \
--url 'https://sunrise-sunset.p.rapidapi.com/v1/astronomy/sun?date=example&lat=0&lon=0' \
--header 'x-rapidapi-key: YOUR_API_KEY' \
--header 'x-rapidapi-host: sunrise-sunset.p.rapidapi.com' const url = "https://sunrise-sunset.p.rapidapi.com/v1/astronomy/sun?date=example&lat=0&lon=0";
const options = {
method: "GET",
headers: {
"x-rapidapi-key": "YOUR_API_KEY",
"x-rapidapi-host": "sunrise-sunset.p.rapidapi.com"
}
};
const response = await fetch(url, options);
const data = await response.json();
console.log(data); import requests
url = "https://sunrise-sunset.p.rapidapi.com/v1/astronomy/sun"
querystring = {"date": "example", "lat": 0, "lon": 0}
headers = {
"x-rapidapi-key": "YOUR_API_KEY",
"x-rapidapi-host": "sunrise-sunset.p.rapidapi.com"
}
response = requests.get(url, headers=headers, params=querystring)
print(response.json()) Interactive Example
$ GET /v1/astronomy/sun?lat=51.5074&lon=-0.1278&date=2026-06-21
{"sunrise":"2026-06-21T03:43:00Z","sunset":"2026-06-21T20:21:00Z","solar_noon":"2026-06-21T12:02:00Z","day_length_hours":16.64} Subscribe & License
Access this API with commercial-ready tiers on RapidAPI. Flexible plans designed for side-projects, startups, and high-volume production architectures.
Developer Support
Need help integrating or have a custom endpoint request? Our engineering team is here to assist with authentication, payload schemas, and high-frequency rate limit increases.
System Performance
Monitored 24/7 with a 99.9% uptime SLA. Built atop cloud-native microservices with globally distributed edge caching to ensure ultra-low latency response times.
All Systems Operational