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": {
    "Waning Gibbous": {
      "name": "Waning Gibbous",
      "next": {
        "date": "2021-01-01 06:35:00"
      }
    },
    "Third Quarter": {
      "name": "Third Quarter",
      "next": {
        "date": "2021-01-04 21:27:00"
      }
    },
    "Waning Crescent": {
      "name": "Waning Crescent",
      "next": {
        "date": "2021-01-08 08:26:00"
      }
    },
    "New Moon": {
      "name": "New Moon",
      "next": {
        "date": "2021-01-11 17:11:00"
      }
    },
    "Waxing Crescent": {
      "name": "Waxing Crescent",
      "next": {
        "date": "2021-01-15 04:48:00"
      }
    },
    "First Quarter": {
      "name": "First Quarter",
      "next": {
        "date": "2021-01-19 01:21:00"
      }
    },
    "Full Moon": {
      "name": "Full Moon",
      "next": {
        "date": "2021-01-27 04:20:00"
      }
    }
  },
  "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"
  }
}