/v1/panchang/sunrise-sunset
Sunrise and sunset JD for location.
What this tells you
Sunrise and sunset are the cornerstones of every location-sensitive panchang calculation. Almost every other endpoint (Rahu Kaal, hora, choghadiya, durmuhurta, brahma muhurat) is computed relative to sunrise/sunset. Accuracy matters: DivyAstroAPI uses Swiss Ephemeris' `swe_rise_trans` with atmospheric refraction correction — accurate to ±30 seconds.
Request
All requests require an Authorization header with your dv_live_* API key.
curl "https://api.divyastroapi.com/v1/panchang/sunrise-sunset?date=2026-04-19&time=06%3A30&tz=%2B05%3A30&lat=28.61&lon=77.21" \
-H "Authorization: Bearer dv_live_0123456789abcdef0123456789abcdef"Response (200 OK)
Successful requests return a JSON body. Field names are stable across versions.
{
"sunrise": {
"jd": 2461137.2,
"local": "2026-04-19T06:18:42+05:30",
"epoch_ms": 1776637122000
},
"sunset": {
"jd": 2461137.725,
"local": "2026-04-19T18:51:20+05:30",
"epoch_ms": 1776682280000
},
"solar_noon": {
"jd": 2461137.4625,
"local": "2026-04-19T12:35:01+05:30"
},
"day_length_hours": 12.543,
"civil_twilight_start": "2026-04-19T05:53:10+05:30",
"civil_twilight_end": "2026-04-19T19:16:52+05:30"
}Field reference
Every field in the response, with its type, a real example, and what it means.
| Field | Type | Meaning |
|---|---|---|
| sunrise.jd | number | Sunrise moment as Julian Day (UT). example: 2461137.2 |
| sunrise.local | string (ISO 8601) | Sunrise in local time with offset. example: "2026-04-19T06:18:42+05:30" |
| sunrise.epoch_ms | number | Unix epoch milliseconds — pass directly to JS `new Date()`. example: 1776637122000 |
| sunset.* | object | Same shape as sunrise. example: … |
| solar_noon | object | Local solar noon — midpoint between sunrise and sunset. example: … |
| day_length_hours | number | Daylight duration. Varies with season and latitude. example: 12.543 |
| civil_twilight_start | string | Sun 6° below horizon — pre-dawn light begins (used for Brahma Muhurat). example: "2026-04-19T05:53:10+05:30" |
| civil_twilight_end | string | Sun 6° below horizon post-sunset. example: "2026-04-19T19:16:52+05:30" |
Usage tips
How to use it
- Always cache per (date, lat, lon)Sunrise and sunset are deterministic for a day and location. Cache indefinitely.
- Polar regionsFor latitudes above 66.5° near solstices, the sun may not rise or set. The API returns `null` for `sunrise.jd` and `sunset.jd` in those cases — handle gracefully.
- Convert to user tz before displayAlways show `*.local` (or convert from epoch_ms to the user's tz) — never show raw UT times.
Errors
Every error follows the same envelope. Use the error.code field (not the message) for conditional logic in your integration.
401 Unauthorized
{
"error": {
"code": "unauthorized",
"message": "missing or invalid API key",
"request_id": "req_01hqy7k8c3e7m1n"
}
}402 Payment Required
{
"error": {
"code": "trial_exhausted",
"message": "your free trial credits are exhausted — pick a plan to continue",
"top_up_url": "https://divyastroapi.com/pricing",
"request_id": "req_01hqy7k8c3e7m1n"
}
}429 Too Many Requests
{
"error": {
"code": "rate_limited",
"message": "rate limit exceeded; retry after 12 seconds",
"request_id": "req_01hqy7k8c3e7m1n"
}
}Try it
Get a dv_live_* key from your dashboard and paste into the cURL snippet above. New accounts get 500 free credits. Sign up.