API


Sun & Moon

Basic Flow

Image

https://astroapi-moonphase-svc.astro-api.workers.dev/?year=2021&month=1&day=1

Replace the year, month and day with the desired date.

Info

To generate a sun & moon information from AstroAPI, the system (your implementation) makes a POST-request to the /api/sunmoon endpoint with the necessary parameters. With correct parameters the AstroAPI will provide a the sun & moon information in JSON-format.

Request

POST /api/sunmoon

Header Value
Accept-Encoding application/json
Content-Type application/json
Authorization Bearer [accessToken]


body

{
  "date": "2021-01-01",
  "time": "14:00",
  "place_id": 3
}


Params explanation

Header Value
date The date in format YYYY-mm-dd
time The time in format HH:mm
place_id The place retrieved from the /api/places request

Response

{
  "year": "2021",
  "month": "01",
  "day": "01",
  "moon": {
    "phase": 0.5757298627870684,
    "phaseName": "Waning Gibbous",
    "age": 17,
    "stage": "waning",
    "distance": 383198.69,
    "illumination": 0.9444576121035353,
    "diameterInDegrees": 0.5197255645958753
  },
  "moonPhases": {
    "newMoon": {
      "name": "New Moon",
      "current": {
        "date": "2020-12-14 16:18:45"
      },
      "next": {
        "date": "2021-01-13 05:02:37"
      }
    },
    "fullMoon": {
      "name": "Full Moon",
      "current": {
        "date": "2020-12-30 03:30:24"
      },
      "next": {
        "date": "2021-01-28 19:18:35"
      }
    },
    "firstQuarter": {
      "name": "First Quarter",
      "current": {
        "date": "2020-12-21 23:42:31"
      },
      "next": {
        "date": "2021-01-20 21:03:35"
      }
    },
    "lastQuarter": {
      "name": "Last Quarter",
      "current": {
        "date": "2021-01-06 09:38:35"
      },
      "next": {
        "date": "2021-02-04 17:38:42"
      }
    }
  },
  "sun": {
    "distance": 147098169.45328185,
    "diameterInDegrees": 0.5421899497758884,
    "sunrise": "03:44:25",
    "sunset": "13:51:05",
    "transit": "08:47:45",
    "civilTwilightBegin": "03:18:48",
    "civilTwilightEnd": "14:16:43",
    "nauticalTwilightBegin": "02:48:12",
    "nauticalTwilightEnd": "14:47:19",
    "astronomicalTwilightBegin": "02:18:18",
    "astronomicalTwilightEnd": "15:17:13"
  }
}