Moon Phase API Documentation

The Moon Phase API provides detailed information about the current phase of the Moon and related astronomical data, including the moon’s illumination, age, distance from Earth, the zodiac sign it occupies, and even the distance between the Sun and Moon.

By offering a full week of data (covering the current day, three days prior, and three days in the future), the API serves as a valuable tool for astrologers, astronomers, and enthusiasts interested in the Moon’s position, its effects, and its relationship with the Sun.

Whether tracking lunar cycles for astrological readings or simply keeping up with the phases of the Moon, this API delivers accurate, calculated data for various use cases.

Contents

  1. Object Properties
  2. Operating Modes
  3. Use Limits

1. Object Properties

A Moon Phase object has the following properties:

PropertyDescription
dateDate for moon phase data
phaseThe Moon’s current phase for the selected date
illuminationThe Moon’s illumination for the selected phase
moon_ageThe Moon’s age at current phase
moon_angleThe Moon’s angle in relation to its rotational cycle
moon_distanceThe Moon’s distance from earth at current phase
sun_distanceThe Sun’s distance from the moon at current phase
moon_signThe Moon’s position in the zodiac signs

Example Moon Phase Object

{
    "date": "2024-10-26",
    "phase": "Last Quarter",
    "illumination": "40.6%",
    "moon_age": "23.04 days",
    "moon_distance": "335102.17 km",
    "sun_distance": "145092026.52 km",
    "moon_angle": 105.6,
    "moon_sign": "Capricorn"
  }

2. Operating Modes

The Moon Phase API operates in two main modes:

i. Get the current date moon phase

https://api.viewbits.com/v1/moonphase

This will return the Moon Phase object for the current day, along with the previous three days, and next three days. The current day is object id [3].

Response

[
{Moon Phase object today -3},
{Moon Phase object today -2},
{Moon Phase object today -1},
{Moon Phase object today},
{Moon Phase object today +1},
{Moon Phase object today +2},
{Moon Phase object today +3},
]

ii. Get a specific date

https://api.viewbits.com/v1/moonphase?startdate=2001-02-14

This will return the Moon Phase object for the date specified. You must adhere to the format YYYY-MM-DD. The requested date will be array object id [3].

Response

[
{Moon Phase object date -3},
{Moon Phase object date -2},
{Moon Phase object date -1},
{Moon Phase object date},
{Moon Phase object date +1},
{Moon Phase object date +2},
{Moon Phase object date +3},
]

3. Use Limits

When no API key is provided, calls are limited to 5 per 30 second period. Its recommended that you use batch mode to cache the data in a local file, then updating only as needed. To increase rate limits and disable CORS, you must provide an API key by adding &key=[YOUR_KEY] to the end of your call.

API Key Example

https://api.viewbits.com/v1/moonphase?startdate=2001-01-24&key=[YOUR_KEY]
https://api.viewbits.com/v1/moonphase?key=[YOUR_KEY]