curl -X POST https://yogataraapi.prahlad.app/api/astro/eclipse/ \
-H "X-API-Key: $OCCULT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"keys":["solar_eclipse_global"],"date_time":"2026-01-01T00:00:00+00:00","latitude":26.9124,"longitude":75.7873,"tz":5.5,"elevation":0,"type":"total","attr":"central","when":"after"}'Serializer for Eclipse and its related calculations.
| 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. FORMAT constraint. DRF DateTimeField: ISO-8601 only (DRF default input formats), e.g. "2026-09-01T06:00:00+05:30", "2026-09-01T06:00:00Z" or "2026-09-01 06:00:00" (no timezone = UTC assumed). |
| elevation | number (double) | required | |
| keys | array | required | 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. solar_eclipse_globalsolar_eclipse_localsolar_eclipse_attributessolar_eclipse_wherelunar_eclipse_globallunar_eclipse_locallunar_eclipse_attributeslunar_eclipse_when |
| tz | number (double) | required | min -12 · max 14 |
| attr | string | optional | centralnon-centralCase-sensitive lowercase; note the hyphen in 'non-central'. Only meaningful for 'solar_eclipse_global'. Any other value (including null) falls through the else branch with no filter applied and no error. Ignored entirely by 'lunar_eclipse_global'. |
| latitude | number (double) | optional | 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) | optional | 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 |
| type | string | optional | totalannularpartialhybridanyCase-sensitive lowercase. REQUIRED for keys 'solar_eclipse_global' and 'lunar_eclipse_global'; omitting it while requesting those keys returns 400 "Invalid eclipse type: None". 'hybrid' maps to swisseph ECL_ANNULAR_TOTAL and 'any' to no type filter. NOTE: get_lunar_eclipse_global accepts `type` in its signature but ignores it, so for 'lunar_eclipse_global' the value only has to be one of these strings - it does not actually filter. |
| when | string | optional | afterbeforeCase-insensitive (the engine calls.lower; also lowercases). Engine default is 'after'. 'after' searches forward from date_time, 'before' searches backward. |
Ask for exactly the calculations you want by listing them in keys. An unknown key rejects the whole request, and you are charged 1 credit however many you ask for — so batch them.
| Key | Extra fields needed | Description | |
|---|---|---|---|
| lunar_eclipse_attributes | date_time, geopos | ||
| lunar_eclipse_global | date_time, type, attr, tz, when | ||
| lunar_eclipse_local | date_time, geopos, tz, when | ||
| lunar_eclipse_when | date_time, when | ||
| solar_eclipse_attributes | date_time, geopos | ||
| solar_eclipse_global | date_time, type, attr, tz, when | ||
| solar_eclipse_local | date_time, geopos, tz, when | ||
| solar_eclipse_where | date_time |