/api/astro/moonrise/1 creditMoonrise and moonset
Moonrise and moonset for a date and place, with the time the moon spends above the horizon in seconds. For the sun, use /api/astro/sunrise/. Send a date, a latitude, a longitude and the UTC offset. As with sunrise, the same instants are reachable through /api/astro/celestial/ only if you know to pass planet_names=["MOON"], to put the rising switch first in the keys array, and to unwrap a nested array. The moonset returned is always the one that FOLLOWS the moonrise, so the pair is a usable interval. That matters more for the moon than the sun: it rises about fifty minutes later each day, so on many dates the moonset that falls inside your calendar day belongs to the previous moonrise. Both fields can be null. Above about 61 degrees of latitude the moon can stay above or below the horizon for more than a day - at Reykjavik in December it does - and there is then no rise or set to report. Null says that; /api/astro/celestial/ returns "2000-11-24T12:00:00Z", which is julian day zero from a search that failed rather than a real instant, and is easy to mistake for an answer. For the moon's phase and paksha, see /api/astro/panchang/.
https://yogataraapi.prahlad.app/api/astro/moonrise/Authentication
Send your key in the X-API-Key header. Keys are server-side credentials — never put one in browser JavaScript or a mobile app.
X-API-Key: yt_live_a1b2c3d4_…
Content-Type: application/jsonRequest fields
| Field | Type | Required | Notes |
|---|---|---|---|
| date_time | string (date-time) | required | The moment to calculate for, ISO 8601. ALWAYS include an offset or a trailing Z - a value with no zone is read as Asia/Kolkata (UTC+05:30), not UTC, and can return the previous day's result with a 200. '2026-09-01T06:00:00Z' and '2026-09-01 06:00:00' are different instants and give different answers. |
| latitude | number (double) | required | Latitude of the place, in decimal degrees. Positive is north, negative is south. Example: 26.9124 for Jaipur, 40.7128 for New York. Minutes and seconds are not accepted - convert first. min -89.9 · max 89.9 |
| longitude | number (double) | required | Longitude of the place, in decimal degrees. Positive is east, negative is west. Example: 75.7873 for Jaipur, -74.0060 for New York. Note the sign: a missing minus puts New York in China. min -180 · max 180 |
| timezone_as_float | number (double) | required | UTC offset of the place, in hours, as a decimal. Example: 5.5 for India (UTC+05:30), -5 for New York in winter, 5.75 for Nepal. This is NOT validated against date_time - if the two disagree you get a successful response for the wrong moment, so derive both from the same source. Use the offset in force on that date, not today's: a summer birth in a country with daylight saving needs the summer offset. min -12 · max 14 |
| keys | array | optional | Which calculations to return, as a list of names. See the key table for this endpoint; an unrecognised name rejects the whole request. One call costs one credit however many keys you ask for, so request everything you need at once rather than making several calls. |
Example request
curl -X POST https://yogataraapi.prahlad.app/api/astro/moonrise/ \
-H "X-API-Key: $OCCULT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"date_time":"2026-09-01T06:00:00+05:30","timezone_as_float":5.5,"latitude":26.9124,"longitude":75.7873}'Response
{
"data": {
"moonrise": "2026-09-01T21:09:00+05:30",
"moonset": "2026-09-02T10:57:09+05:30",
"moon_above_horizon_seconds": 49689
},
"status": 200,
"is_error": false,
"message": "successful"
}Captured from a real call using the exact request above. Results sit under data.
Errors
Metering errors return { "error": "…", "message": "<code>", "is_error": true }. Show error to people and branch on message. See the error reference.