Skip to content
Endpoint reference · v1

Moon API

Calculate moon phase, illumination, lunar age and approximate moonrise/moonset.

GET/api/v1/moon

What It Does

Calculate moon phase, illumination, lunar age and approximate moonrise/moonset.

HTTP method
GET
Authentication
Public read-only; Bearer keys supported
Version
v1

Parameters

NameTypeRequiredDescription
citystringNoCity lookup alternative to coordinates.
Example: Karachi
latitudenumberNoLatitude.
Example: 24.86
longitudenumberNoLongitude.
Example: 67.01
datedateNoLocal date.
Example: 2026-09-09
timezonestringNoOutput timezone.
Example: Asia/Karachi

Request Examples

cURL
curl -s 'https://worldclock.to/api/v1/moon?city=Karachi&latitude=24.86&longitude=67.01&date=2026-09-09&timezone=Asia/Karachi'
JavaScript
const response = await fetch("https:\/\/worldclock.to\/api\/v1\/moon?city=Karachi&latitude=24.86&longitude=67.01&date=2026-09-09&timezone=Asia\/Karachi");
const result = await response.json();
console.log(result.data);
PHP
$response = wp_remote_get('https://worldclock.to/api/v1/moon?city=Karachi&latitude=24.86&longitude=67.01&date=2026-09-09&timezone=Asia/Karachi');
 = json_decode(wp_remote_retrieve_body(), true);
Python
import requests

response = requests.get("https:\/\/worldclock.to\/api\/v1\/moon?city=Karachi&latitude=24.86&longitude=67.01&date=2026-09-09&timezone=Asia\/Karachi")
response.raise_for_status()
print(response.json()["data"])

Example Response

The values below illustrate the response shape. Live current-time fields are generated dynamically by the endpoint.

JSON
{
    "success": true,
    "data": {
        "date": "2026-09-09",
        "latitude": 24.8599999999999994315658113919198513031005859375,
        "longitude": 67.0100000000000051159076974727213382720947265625,
        "timezone": "Asia/Karachi",
        "phase": "Waning crescent",
        "phase_fraction": 0.9210000000000000408562073062057606875896453857421875,
        "illumination": 0.060999999999999998667732370449812151491641998291015625,
        "illumination_percent": 6.0999999999999996447286321199499070644378662109375,
        "lunar_age_days": 27.199999999999999289457264239899814128875732421875,
        "moonrise": "2026-09-09T04:19:00+05:00",
        "moonset": "2026-09-09T17:14:00+05:00"
    },
    "meta": {
        "version": "v1",
        "timezone": "Asia/Karachi",
        "timestamp": 1788946200
    }
}

Response Properties

Every successful response contains success: true, endpoint-specific data, and a meta object. The table below documents the public fields for this endpoint.

PropertyMeaning
successBoolean indicating whether the request completed successfully.
meta.versionPublished API response version.
meta.timestampUnix timestamp for the API response instant.
meta.timezoneTimezone context used by the response.
meta.rate_limitPer-client fair-use limit and remaining-request information on public transports.
data.dateLocal calculation date.
data.latitudeCalculation latitude.
data.longitudeCalculation longitude.
data.timezoneTimezone used for output.
data.phaseNamed lunar phase.
data.phase_fractionApproximate cycle position from 0 to 1.
data.illuminationApproximate illuminated fraction from 0 to 1.
data.illumination_percentApproximate illuminated percentage.
data.lunar_age_daysApproximate age in the current synodic month.
data.moonriseApproximate timezone-aware moonrise datetime when calculable.
data.moonsetApproximate timezone-aware moonset datetime when calculable.

Errors use success: false with a stable machine-readable error code and a safe human-readable message.

Errors & HTTP Status Codes

  • 400 — invalid or missing parameter.
  • 401 — API key required or invalid when key-only access is enabled.
  • 404 — unknown city, country or endpoint.
  • 429 — configured rate limit reached.
  • 503 — API disabled or maintenance mode.

Rate Limits & Caching

Current fair-use configuration is 60 requests per minute and 5000 requests per day. Cache stable directory/calculation responses where appropriate; treat current-time output as point-in-time data.

Related Endpoints