Sunrise Sunset API
Overview
To use Sunrise Sunset, you need an API key. You can get one by creating a free account and visiting your dashboard.
GET Endpoint
https://api.apiverve.com/v1/sunrisesunsetExample
How to call the Sunrise Sunset API in different programming languages.
curl -X GET \
"https://api.apiverve.com/v1/sunrisesunset?lat=36.72016&lon=-4.42034&date=01-16-2026" \
-H "X-API-Key: your_api_key_here"const response = await fetch('https://api.apiverve.com/v1/sunrisesunset?lat=36.72016&lon=-4.42034&date=01-16-2026', {
method: 'GET',
headers: {
'X-API-Key': 'your_api_key_here',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);import requests
headers = {
'X-API-Key': 'your_api_key_here',
'Content-Type': 'application/json'
}
response = requests.get('https://api.apiverve.com/v1/sunrisesunset?lat=36.72016&lon=-4.42034&date=01-16-2026', headers=headers)
data = response.json()
print(data)package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.apiverve.com/v1/sunrisesunset?lat=36.72016&lon=-4.42034&date=01-16-2026", nil)
req.Header.Set("X-API-Key", "your_api_key_here")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}{
"status": "ok",
"error": null,
"data": {
"solarNoon": "2025-12-16T12:14:40.51Z",
"sunrise": "2025-12-16T07:24:56.165Z",
"sunset": "2025-12-16T17:04:24.854Z",
"sunriseEnd": "2025-12-16T07:27:58.828Z",
"sunsetStart": "2025-12-16T17:01:22.192Z",
"dawn": "2025-12-16T06:56:02.774Z",
"dusk": "2025-12-16T17:33:18.245Z",
"nauticalDawn": "2025-12-16T06:23:38.134Z",
"nauticalDusk": "2025-12-16T18:05:42.886Z",
"nightEnd": "2025-12-16T05:52:07.048Z",
"night": "2025-12-16T18:37:13.971Z",
"goldenHourEnd": "2025-12-16T08:05:08.406Z",
"goldenHour": "2025-12-16T16:24:12.613Z"
}
}Authentication
The Sunrise Sunset API requires authentication via API key. Include your API key in the request header:
X-API-Key: your_api_key_hereInteractive API Playground
Test the Sunrise Sunset API directly in your browser with live requests and responses.
Parameters
The following parameters are available for the Sunrise Sunset API:
Get Sunrise Sunset
| Parameter | Type | Required | Description | Default | Example |
|---|---|---|---|---|---|
lat | number | required | The latitude of the location Range: -90 - 90 | - | |
lon | number | required | The longitude of the location Range: -180 - 180 | - | |
datePremium | string | optional | The date for which you want to get the sunrise and sunset times (e.g., MM-DD-YYYY : 01-01-2022) Format: date (e.g., 01-16-2026) | - |
Response
The Sunrise Sunset API returns responses in JSON, XML, YAML, and CSV formats. The JSON response is shown in the Example section above; alternative formats below.
Other Response Formats
<?xml version="1.0" encoding="UTF-8"?>
<response>
<status>ok</status>
<error xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<data>
<solarNoon>2025-12-16T12:14:40.51Z</solarNoon>
<sunrise>2025-12-16T07:24:56.165Z</sunrise>
<sunset>2025-12-16T17:04:24.854Z</sunset>
<sunriseEnd>2025-12-16T07:27:58.828Z</sunriseEnd>
<sunsetStart>2025-12-16T17:01:22.192Z</sunsetStart>
<dawn>2025-12-16T06:56:02.774Z</dawn>
<dusk>2025-12-16T17:33:18.245Z</dusk>
<nauticalDawn>2025-12-16T06:23:38.134Z</nauticalDawn>
<nauticalDusk>2025-12-16T18:05:42.886Z</nauticalDusk>
<nightEnd>2025-12-16T05:52:07.048Z</nightEnd>
<night>2025-12-16T18:37:13.971Z</night>
<goldenHourEnd>2025-12-16T08:05:08.406Z</goldenHourEnd>
<goldenHour>2025-12-16T16:24:12.613Z</goldenHour>
</data>
</response>
status: ok
error: null
data:
solarNoon: '2025-12-16T12:14:40.51Z'
sunrise: '2025-12-16T07:24:56.165Z'
sunset: '2025-12-16T17:04:24.854Z'
sunriseEnd: '2025-12-16T07:27:58.828Z'
sunsetStart: '2025-12-16T17:01:22.192Z'
dawn: '2025-12-16T06:56:02.774Z'
dusk: '2025-12-16T17:33:18.245Z'
nauticalDawn: '2025-12-16T06:23:38.134Z'
nauticalDusk: '2025-12-16T18:05:42.886Z'
nightEnd: '2025-12-16T05:52:07.048Z'
night: '2025-12-16T18:37:13.971Z'
goldenHourEnd: '2025-12-16T08:05:08.406Z'
goldenHour: '2025-12-16T16:24:12.613Z'
| key | value |
|---|---|
| solarNoon | 2025-12-16T12:14:40.51Z |
| sunrise | 2025-12-16T07:24:56.165Z |
| sunset | 2025-12-16T17:04:24.854Z |
| sunriseEnd | 2025-12-16T07:27:58.828Z |
| sunsetStart | 2025-12-16T17:01:22.192Z |
| dawn | 2025-12-16T06:56:02.774Z |
| dusk | 2025-12-16T17:33:18.245Z |
| nauticalDawn | 2025-12-16T06:23:38.134Z |
| nauticalDusk | 2025-12-16T18:05:42.886Z |
| nightEnd | 2025-12-16T05:52:07.048Z |
| night | 2025-12-16T18:37:13.971Z |
| goldenHourEnd | 2025-12-16T08:05:08.406Z |
| goldenHour | 2025-12-16T16:24:12.613Z |
Response Structure
All API responses follow a consistent structure with the following fields:
| Field | Type | Description | Example |
|---|---|---|---|
status | string | Indicates whether the request was successful ("ok") or failed ("error") | ok |
error | string | null | Contains error message if status is "error", otherwise null | null |
data | object | null | Contains the API response data if successful, otherwise null | {...} |
Learn more about response formats β
Response Data Fields
When the request is successful, the data object contains the following fields:
| Field | Type | Sample Value | Description |
|---|---|---|---|
solarNoonPremium | string | Solar noon time | |
sunrise | string | Sunrise time in ISO 8601 format | |
sunset | string | Sunset time in ISO 8601 format | |
sunriseEnd | string | Moment the sun's disc has fully cleared the horizon, in UTC | |
sunsetStart | string | Moment the sun's disc first touches the horizon at sunset, in UTC | |
dawn | string | Start of civil twilight, when the sun is 6 degrees below the horizon | |
dusk | string | End of civil twilight, when the sun drops 6 degrees below the horizon | |
nauticalDawn | string | Start of nautical twilight, when the sun is 12 degrees below the horizon | |
nauticalDusk | string | End of nautical twilight, when the sun drops 12 degrees below the horizon | |
nightEnd | string | End of astronomical night, when the sun rises above 18 degrees below the horizon | |
night | string | Start of astronomical night, when the sun drops 18 degrees below the horizon | |
goldenHourEnd | string | End of the morning golden hour, when soft low-angle light gives way to daylight | |
goldenHour | string | Start of the evening golden hour, when the light turns soft and low-angle |
Headers
Only X-API-Key is required. Optional headers include Accept for response format negotiation (JSON, XML, or YAML), User-Agent, and X-Request-ID for request tracing. See all request headers β
GraphQL AccessALPHA
Access Sunrise Sunset through GraphQL to combine it with other API calls in a single request. Query only the sunrise sunset data you need with precise field selection, and orchestrate complex data fetching workflows.
Credit Cost: Each API called in your GraphQL query consumes its standard credit cost.
POST https://api.apiverve.com/v1/graphqlquery {
sunrisesunset(
input: {
lat: 36.72016
lon: -4.42034
date: "01-16-2026"
}
) {
solarNoon
sunrise
sunset
sunriseEnd
sunsetStart
dawn
dusk
nauticalDawn
nauticalDusk
nightEnd
night
goldenHourEnd
goldenHour
}
}Note: Authentication is handled via the x-api-key header in your GraphQL request, not as a query parameter.
CORS Support
The Sunrise Sunset API accepts cross-origin requests from any origin, so it can be called directly from browser-based applications without a proxy. See CORS support β
Rate Limiting
Sunrise Sunset requests are throttled per minute on the Free plan and unthrottled on paid plans. Exceeding the limit returns 429 Too Many Requests; rate-limit usage is reported in the X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset response headers. See per-plan limits and best practices β
Error Codes
The Sunrise Sunset API uses standard HTTP status codes β 200 on success, 400 for invalid parameters, 401 for missing or invalid keys, 403 for insufficient credits, 429 for rate-limit exhaustion, and 500/503 for server-side issues. Each error response includes an X-Request-ID header you can quote when contacting support. See full error handling guide β
SDKs for Sunrise Sunset
Official Sunrise Sunset packages on npm, PyPI, NuGet, and JitPack β plus a Postman collection and an OpenAPI spec. See the SDK guide β
No-Code Integrations
Sunrise Sunset works with Zapier, Make, Pipedream, n8n, and Power Automate using the same API key. See setup guides β
Frequently Asked Questions
How do I get an API key for Sunrise Sunset?
How many credits does Sunrise Sunset cost?
Each successful Sunrise Sunset API call consumes credits based on plan tier. Check the pricing section above for the exact credit cost. Failed requests and errors don't consume credits, so you only pay for successful sunrise sunset lookups.
Can I use Sunrise Sunset in production?
The free plan is for testing and development only. For production use of Sunrise Sunset, upgrade to a paid plan (Starter, Pro, or Mega) which includes commercial use rights, no attribution requirements, and guaranteed uptime SLAs. All paid plans are production-ready.
Can I use Sunrise Sunset from a browser?
What happens if I exceed my Sunrise Sunset credit limit?
When you reach your monthly credit limit, Sunrise Sunset API requests will return an error until you upgrade your plan or wait for the next billing cycle. You'll receive notifications at 80% and 95% usage to give you time to upgrade if needed.
Other ways to use Sunrise Sunset
Set up Sunrise Sunset on APIVerve, or reach the same source a different way. Your APIVerve account and credits work on all of them β one key, one balance.








