Standard APIGET /v1/astronomy

Astronomy API

Sunrise, sunset, moonrise, moonset, and moon phase for any location and date.

Get precise astronomical event times — sunrise, sunset, moonrise, moonset — and the current moon phase (New Moon through Full Moon) for any date from today onwards. Query any location worldwide using the same flexible q parameter as the rest of the WeatherAI.io API suite. Ideal for apps where natural light and lunar conditions influence user behaviour.

What You Get with the Astronomy API

Sunrise & sunset to the minute

Calculated using high-precision astronomical algorithms accounting for elevation and atmospheric refraction.

Moon phase included

Returns the named moon phase (New Moon, Waxing Crescent, First Quarter, etc.) for the requested date.

Moonrise & moonset times

Complete lunar event schedule alongside solar events in a single, lightweight response.

Any location, any date

Query future or past dates — not just today — making this ideal for planning dashboards and calendars.

Moon illumination

Percentage of the moon's visible disk that is illuminated — useful for night-sky photography and wildlife planning.

No extra cost

Astronomy data is included in the Standard tier — part of your 1,000 free daily calls.

Who Uses This API

From startups to enterprise teams, the Astronomy API powers a wide range of real-world applications.

Photography & astrophotography

Plan golden-hour shoots and night-sky sessions by finding the exact time of sunrise, sunset, and full moon for any location.

Agriculture & horticulture

Schedule planting, pruning, and harvesting around moon phases, a centuries-old practice now accessible via API.

Fishing & outdoor recreation

Display solunar tables and peak activity periods based on moon position to help anglers and hunters plan their trips.

Energy & solar management

Use precise sunrise and sunset times to control automated lighting, solar inverters, and building energy systems.

Request Parameters

ParameterTypeRequiredDescriptionExample
qstringRequiredLocation — city, lat/lon, postcode, or IATA codeDubai
dtstringOptionalDate in YYYY-MM-DD (defaults to today)2024-06-21

Authenticate every request with the X-API-Key header.

Code Example

Request

cURL
curl "https://api.weatherai.io/v1/astronomy?q=Dubai&dt=2024-06-21" \
  -H "X-API-Key: your-api-key"

Response

200 OKapplication/json
{
  "location": { "name": "Dubai", "country": "UAE" },
  "astronomy": {
    "sunrise": "05:31 AM",
    "sunset": "07:16 PM",
    "moonrise": "10:42 PM",
    "moonset": "09:55 AM",
    "moonPhase": "Waxing Gibbous",
    "moonIllumination": 68
  }
}

Response Fields

FieldTypeDescription
locationobjectLocation details
astronomy.sunrisestringSunrise time in local time
astronomy.sunsetstringSunset time in local time
astronomy.moonrisestringMoonrise time in local time
astronomy.moonsetstringMoonset time in local time
astronomy.moonPhasestringNamed moon phase (e.g. Waxing Gibbous)
astronomy.moonIlluminationnumberVisible moon illumination %

Start Using the Astronomy API Today

Create a free account and get your API key in under a minute. 1,000 free calls per day. No credit card required.

Get Your Free API Key