API Reference / Vedic Astrology / Panchang
/v1/panchang/sunrise-sunset
Sunrise and sunset JD for location.
What this tells you
Sunrise and sunset anchor every location-based panchang value. Rahu Kaal, Yamaganda, Gulika, Abhijit, hora, choghadiya and durmuhurta are all computed from them, and the five limbs (tithi, nakshatra, yoga, karana, vara) are read at sunrise. The API returns the first sunrise after local midnight on `date` and the sunset that follows it. Times are for the upper edge of the Sun's disc with atmospheric refraction, at the given `alt`.
Request
All requests require an Authorization header with your dv_live_* API key.
curl "https://api.lifeastroapi.com/v1/panchang/sunrise-sunset?date=2027-01-15&tz=Asia%2FKolkata&lat=28.6139&lon=77.209" \
-H "Authorization: Bearer YOUR_API_KEY"Query parameters
Checked against the API: a parameter is marked required when the request fails without it.
| Name | Required | Example | Description |
|---|---|---|---|
date | yes | 2027-01-15 | Date (YYYY-MM-DD). |
tz | yes | Asia/Kolkata | Timezone: IANA name (Asia/Kolkata) or UTC offset (+05:30). |
lat | yes | 28.6139 | Latitude in decimal degrees. |
lon | yes | 77.209 | Longitude in decimal degrees. |
Response (200 OK)
The real response to the example request above, generated from the API itself. Long arrays are trimmed to their first two items. Field names are stable across versions.
{
"date": "2027-01-15",
"location": {
"lat": 28.6139,
"lon": 77.209,
"alt": 0
},
"tz": "Asia/Kolkata",
"has_sunrise": true,
"has_sunset": true,
"sunrise_jd": 2461420.572762,
"sunset_jd": 2461421.011285,
"sunrise_local": "2027-01-15 07:14:47",
"sunset_local": "2027-01-15 17:46:15"
}Field reference
Every field in the response, with its type, a real example, and what it means.
| Field | Type | Meaning |
|---|---|---|
| date | string | Echo of the `date` parameter (local date). example: "2027-01-15" |
| location | object | Echo of `lat`, `lon` and `alt` (metres, default 0). Altitude shifts rise and set times slightly. example: { "lat": 28.6139, "lon": 77.209, "alt": 0 } |
| tz | string | Echo of the `tz` parameter. The `*_local` times are in this zone. example: "Asia/Kolkata" |
| has_sunrise | boolean | False when the Sun does not rise on this date (polar day or night). `sunrise_jd` and `sunrise_local` are then left out. example: true |
| has_sunset | boolean | False when no sunset follows the sunrise. `sunset_jd` and `sunset_local` are then left out. example: true |
| sunrise_jd | number | Sunrise as a Julian Day in UT. example: 2461420.572762 |
| sunset_jd | number | Sunset as a Julian Day in UT. example: 2461421.011285 |
| sunrise_local | string (YYYY-MM-DD HH:MM:SS) | Sunrise in local time (request `tz`), with no offset suffix. example: "2027-01-15 07:14:47" |
| sunset_local | string (YYYY-MM-DD HH:MM:SS) | Sunset in local time (request `tz`), with no offset suffix. example: "2027-01-15 17:46:15" |
Usage tips
How to use it
- Cache per date and locationThe times depend only on `date`, `lat`, `lon`, `alt` and `tz`. The `time` parameter does not change them. Cache them as long as you like.
- Polar latitudesWhen the Sun does not rise or set, the response is still 200: `has_sunrise` / `has_sunset` are false, the matching time fields are left out (not null), and a `reason` string ("polar day/night") is added. Check the booleans before reading the times.
- Local strings carry no offset`sunrise_local` and `sunset_local` are already in the request `tz` but have no offset, so do not parse them as UTC. To build a JavaScript Date, convert from the JD: Unix ms = (jd − 2440587.5) × 86400000.
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://lifeastroapi.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 1,500 free credits. Sign up.