Skip to content
POST/api/astro/moon-illumination/1 credit

Moon illumination and phase

How much of the Moon is lit, as a real fraction. Computed from the elongation between the Sun and the Moon: lit = (1 - cos(elongation)) / 2, which is 0 at new moon, 0.5 at either quarter and 1 at full. Returned as both a fraction and a percentage, with the elongation, the phase angle, whether the Moon is waxing, and the conventional phase name. This endpoint exists because the engine key called `get_illumination` does not return illumination. It returns APPARENT MAGNITUDE — about -26.7 for the Sun and between -6 and -12 for the Moon depending on phase. A fraction cannot be negative and cannot be -26, and anything wiring that field to a "percent lit" display shows nonsense. That value is still returned here, under the name it deserves: apparent_magnitude, where smaller is brighter.

https://yogataraapi.prahlad.app/api/astro/moon-illumination/
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.

altitudenumber (double)optional

OBSERVER elevation in metres, not a body's altitude.

keysarrayoptional

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.

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

planet_namesarrayoptional

Ignored. This endpoint always reads the Sun and the Moon.

time_zonenumber (double)optional

UTC offset. Either this or timezone_as_float; they mirror.

min -12 · max 14

timezone_as_floatnumber (double)optional

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

Example request

curl -X POST https://yogataraapi.prahlad.app/api/astro/moon-illumination/ \
  -H "X-API-Key: $OCCULT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"date_time":"2026-09-09T12:00:00+00:00","latitude":26.9124,"longitude":75.7873,"timezone_as_float":0}'

Response

{
  "data": {
    "illuminated_fraction": 0.034082,
    "illuminated_percent": 3.4082,
    "elongation_degrees": 21.277,
    "phase_angle_degrees": 338.723,
    "waxing": false,
    "phase_name": "New moon",
    "apparent_magnitude": {
      "moon": -6.123776,
      "sun": -26.726421
    },
    "longitudes": {
      "sun": 166.834,
      "moon": 145.557
    },
    "notes": {
      "apparent_magnitude": "The engine key named get_illumination returns apparent magnitude, not illumination. Smaller is brighter; it is negative for both of these bodies. Use illuminated_fraction for how much of the disc is lit."
    }
  },
  "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.