Skip to content
POST/api/astro/eclipse/1 credit

Eclipse

Serializer for Eclipse and its related calculations.

https://yogataraapi.prahlad.app/api/astro/eclipse/
Test Request

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/json

Request fields

FieldTypeRequiredNotes
date_timestring (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).

elevationnumber (double)required
keysarrayrequired

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
tznumber (double)required

min -12 · max 14

attrstringoptional
centralnon-central

Case-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'.

latitudenumber (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

longitudenumber (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

typestringoptional
totalannularpartialhybridany

Case-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.

whenstringoptional
afterbefore

Case-insensitive (the engine calls.lower; also lowercases). Engine default is 'after'. 'after' searches forward from date_time, 'before' searches backward.

Available keys (8)

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.

KeyExtra fields neededDescription
lunar_eclipse_attributesdate_time, geopos
lunar_eclipse_globaldate_time, type, attr, tz, when
lunar_eclipse_localdate_time, geopos, tz, when
lunar_eclipse_whendate_time, when
solar_eclipse_attributesdate_time, geopos
solar_eclipse_globaldate_time, type, attr, tz, when
solar_eclipse_localdate_time, geopos, tz, when
solar_eclipse_wheredate_time

Example request

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"}'

Response

{
  "data": {
    "solar_eclipse_global": [
      {
        "type": "total",
        "attr": "central"
      },
      [
        "2026-08-12T23:15:57+05:30",
        "2026-08-12T22:33:51+05:30",
        "2026-08-12T21:04:30+05:30",
        "2026-08-13T01:27:57+05:30",
        "2026-08-12T22:28:05+05:30",
        "2026-08-13T00:04:00+05:30",
        "2026-08-12T22:30:06+05:30",
        "2026-08-13T00:02:01+05:30",
        0,
        0
      ]
    ]
  },
  "status": 200,
  "is_error": false,
  "message": "successful"
}

Captured from a real call using the exact request above. Results sit under data, keyed by what you requested.

Errors

Metering errors return { "error": "…", "message": "<code>", "is_error": true }. Show error to people and branch on message. See the error reference.