Astronomy API
DataMAINTAINED1 token / call

Astronomy API

Sunrise, sunset, twilight, golden hour, moon phase and moonrise for any coordinates and date, computed in-worker

Sun and moon, computed for any point on Earth and any date: sunrise, sunset, solar noon, day length, civil/nautical/astronomical twilight, the golden-hour window photographers plan around, live solar position (azimuth and elevation), moonrise and moonset, moon phase with its name and illumination percentage, lunar distance, and the dates of the next full and new moon. Pure computation with the standard astronomical algorithms β€” no upstream services, no rate-limited providers, answers in milliseconds at the lowest token cost. Accuracy is almanac-grade: New York''s 2026 summer-solstice sunrise lands within a minute of the published time, the equator gets its 12.1-hour equinox day, Tromso correctly reports polar night in January and midnight sun in June, and the computed next new and full moons match the real 2026 lunar calendar to the day. The almanac endpoint returns up to 31 days of combined sun and moon data in one call. Built for photography and drone apps (golden hour), fitness and outdoor products, agriculture, astronomy and stargazing tools, religious observance apps, and smart-home automations.

Every call needs an X-Api-Key header. A free key includes 500 tokens a month, no card required. 1 token per call, so the free plan covers about 500 calls a month.

No credit card requiredAccess to 125+ APIsCancel anytime
response.json
{
  "ok": true,
  "lat": 40.7128,
  "lon": -74.006,
  "date": "2026-06-21",
  "times_utc": {
    "solar_noon": "2026-06-21T16:59:03Z",
    "sunrise": "2026-06-21T09:26:14Z",
    "sunset": "2026-06-22T00:31:52Z",
    "civil_twilight_begin": "2026-06-21T08:52:49Z",
    "civil_twilight_end": "2026-06-22T01:05:18Z",
    "nautical_twilight_begin": "2026-06-21T08:10:09Z",
    "nautical_twilight_end": "2026-06-22T01:47:57Z",
    "astronomical_twilight_begin": "2026-06-21T07:19:44Z",
    "astronomical_twilight_end": "2026-06-22T02:38:22Z",
    "golden_hour_morning_end": "2026-06-21T10:07:34Z",
    "golden_hour_evening_begin": "2026-06-21T23:50:33Z",
    "day_length_seconds": 54338,
    "polar": null
  },
  "position_now": {
    "at": "2026-06-21T12:00:00Z",
    "azimuth_deg": 80.9,
    "elevation_deg": 26.44
  }
}
Production Ready
Battle-tested infrastructure with a 99.9% uptime SLA. Rate limits are generous, responses are consistent.
Simple Integration
Standard REST + JSON. Works with any HTTP client. Copy-ready code snippets in 4 languages.
One Key, 125+ APIs
Your DataAndAPIs subscription unlocks every API on the platform β€” anime, finance, sports, and more.

Use cases for Astronomy API

  • Show sunrise, sunset and golden hour on a photography, outdoor or travel app for any location.

  • Schedule lighting, irrigation or signage around civil twilight instead of fixed clock times.

  • Display tonight's moon phase, illumination and moonrise for stargazing or fishing products.

  • Compute day length and solar position for solar-energy and shading calculations.

Astronomy API endpoints

Every endpoint with its parameters and a real example response.

GETMoon Phase & Times

https://api-astronomy.dataandapis.com/v1/moon

Query parameters

ParameterExample
date2026-09-05Optional
lat51.5Required
lon-0.12Required

Example request

curl "https://api-astronomy.dataandapis.com/v1/moon?date=2026-09-05&lat=51.5&lon=-0.12" \
  -H "X-Api-Key: YOUR_API_KEY"
Example response
{
  "ok": true,
  "lat": 51.5,
  "lon": -0.12,
  "date": "2026-09-05",
  "phase": {
    "value": 0.796,
    "name": "Waning Crescent",
    "illumination_pct": 35.8,
    "next_full_moon": "2026-09-26",
    "next_new_moon": "2026-09-11"
  },
  "times_utc": {
    "moonrise": "2026-09-05T22:45:58Z",
    "moonset": "2026-09-05T15:54:55Z",
    "always_up": false,
    "always_down": false
  },
  "position_now": {
    "at": "2026-09-05T12:00:00Z",
    "azimuth_deg": 277.41,
    "elevation_deg": 30.62,
    "distance_km": 364096
  }
}

GETMulti-Day Almanac

https://api-astronomy.dataandapis.com/v1/almanac

Query parameters

ParameterExample
date2026-09-05Optional
days7Optional
lat34.05Required
lon-118.24Required

Example request

curl "https://api-astronomy.dataandapis.com/v1/almanac?date=2026-09-05&days=7&lat=34.05&lon=-118.24" \
  -H "X-Api-Key: YOUR_API_KEY"
Example response
{
  "ok": true,
  "lat": 34.05,
  "lon": -118.24,
  "days": 7,
  "count": 7,
  "results": [
    {
      "date": "2026-09-05",
      "sun": {
        "solar_noon": "2026-09-05T19:53:09Z",
        "sunrise": "2026-09-05T13:30:44Z",
        "sunset": "2026-09-06T02:15:34Z",
        "civil_twilight_begin": "2026-09-05T13:05:21Z",
        "civil_twilight_end": "2026-09-06T02:40:56Z",
        "nautical_twilight_begin": "2026-09-05T12:35:25Z",
        "nautical_twilight_end": "2026-09-06T03:10:52Z",
        "astronomical_twilight_begin": "2026-09-05T12:04:45Z",
        "astronomical_twilight_end": "2026-09-06T03:41:33Z",
        "golden_hour_morning_end": "2026-09-05T14:03:56Z",
        "golden_hour_evening_begin": "2026-09-06T01:42:22Z",
        "day_length_seconds": 45890,
        "polar": null
      },
      "moon": {
        "moonrise": "2026-09-05T07:17:26Z",
        "moonset": "2026-09-05T22:41:46Z",
        "always_up": false,
…
Show full response
{
  "ok": true,
  "lat": 34.05,
  "lon": -118.24,
  "days": 7,
  "count": 7,
  "results": [
    {
      "date": "2026-09-05",
      "sun": {
        "solar_noon": "2026-09-05T19:53:09Z",
        "sunrise": "2026-09-05T13:30:44Z",
        "sunset": "2026-09-06T02:15:34Z",
        "civil_twilight_begin": "2026-09-05T13:05:21Z",
        "civil_twilight_end": "2026-09-06T02:40:56Z",
        "nautical_twilight_begin": "2026-09-05T12:35:25Z",
        "nautical_twilight_end": "2026-09-06T03:10:52Z",
        "astronomical_twilight_begin": "2026-09-05T12:04:45Z",
        "astronomical_twilight_end": "2026-09-06T03:41:33Z",
        "golden_hour_morning_end": "2026-09-05T14:03:56Z",
        "golden_hour_evening_begin": "2026-09-06T01:42:22Z",
        "day_length_seconds": 45890,
        "polar": null
      },
      "moon": {
        "moonrise": "2026-09-05T07:17:26Z",
        "moonset": "2026-09-05T22:41:46Z",
        "always_up": false,
        "always_down": false,
        "phase": 0.796,
        "phase_name": "Waning Crescent",
        "illumination_pct": 35.8
      }
    },
    {
      "date": "2026-09-06",
      "sun": {
        "solar_noon": "2026-09-06T19:52:48Z",
        "sunrise": "2026-09-06T13:31:25Z",
        "sunset": "2026-09-07T02:14:12Z",
        "civil_twilight_begin": "2026-09-06T13:06:05Z",
        "civil_twilight_end": "2026-09-07T02:39:32Z",
        "nautical_twilight_begin": "2026-09-06T12:36:12Z",
        "nautical_twilight_end": "2026-09-07T03:09:24Z",
        "astronomical_twilight_begin": "2026-09-06T12:05:37Z",
        "astronomical_twilight_end": "2026-09-07T03:39:59Z",
        "golden_hour_morning_end": "2026-09-06T14:04:35Z",
        "golden_hour_evening_begin": "2026-09-07T01:41:01Z",
        "day_length_seconds": 45767,
        "polar": null
      },
      "moon": {
        "moonrise": "2026-09-06T08:26:00Z",
        "moonset": "2026-09-06T23:36:05Z",
        "always_up": false,
        "always_down": false,
        "phase": 0.834,
        "phase_name": "Waning Crescent",
        "illumination_pct": 24.9
      }
    }
  ]
}

GETSun Times & Position

https://api-astronomy.dataandapis.com/v1/sun

Query parameters

ParameterExample
date2026-06-21Optional
lat40.7128Required
lon-74.006Required

Example request

curl "https://api-astronomy.dataandapis.com/v1/sun?date=2026-06-21&lat=40.7128&lon=-74.006" \
  -H "X-Api-Key: YOUR_API_KEY"
Example response
{
  "ok": true,
  "lat": 40.7128,
  "lon": -74.006,
  "date": "2026-06-21",
  "times_utc": {
    "solar_noon": "2026-06-21T16:59:03Z",
    "sunrise": "2026-06-21T09:26:14Z",
    "sunset": "2026-06-22T00:31:52Z",
    "civil_twilight_begin": "2026-06-21T08:52:49Z",
    "civil_twilight_end": "2026-06-22T01:05:18Z",
    "nautical_twilight_begin": "2026-06-21T08:10:09Z",
    "nautical_twilight_end": "2026-06-22T01:47:57Z",
    "astronomical_twilight_begin": "2026-06-21T07:19:44Z",
    "astronomical_twilight_end": "2026-06-22T02:38:22Z",
    "golden_hour_morning_end": "2026-06-21T10:07:34Z",
    "golden_hour_evening_begin": "2026-06-21T23:50:33Z",
    "day_length_seconds": 54338,
    "polar": null
  },
  "position_now": {
    "at": "2026-06-21T12:00:00Z",
    "azimuth_deg": 80.9,
    "elevation_deg": 26.44
  }
}

Where the data comes from

Source
Standard solar and lunar algorithms (NOAA and Meeus family), pure computation.
Freshness
Computed on every call.

One install. Every endpoint.

No proprietary SDKs needed. Any HTTP client works. Pick your language and paste.

3languages
3endpoints
RESTarchitecture
1key for all APIs
  • Fully typed responses β€” auto-completion in your IDE
  • Tracks the API in lockstep β€” new endpoints land same day
  • One key works across 125+ APIs on the platform
import axios from 'axios';

const { data } = await axios.get(
  'https://api-astronomy.dataandapis.com/v1/moon',
  { headers: { 'X-Api-Key': process.env.API_KEY } }
);

Astronomy API Β· X-Api-Key

Explore the endpoints

Browse request parameters and inspect live example responses.

Available Endpoints

Request Parameters

API URL

Headers

X-Api-Key

Query Parameters

date(Optional)
lat(Required)
lon(Required)
import axios from 'axios';

const url = 'https://api-astronomy.dataandapis.com/v1/moon';
const { data } = await axios.get(url, {
  headers: { 'X-Api-Key': 'YOUR_API_KEY' }
});

One subscription. Every API.

Tokens unlock this API and 125+ others on DataAndAPIs. Switch APIs any time β€” we promote.

FREE

$0/mo

500 tokens / month

  • Access to all APIs
  • Tokens reset monthly
  • Community support
Start free
Most Popular

STARTER

$6.99/mo

25,000 tokens / month

  • Access to all APIs
  • Tokens reset monthly
  • Email support
Subscribe

PRO

$24.99/mo

100,000 tokens / month

  • Access to all APIs
  • Tokens reset monthly
  • Priority email support
Subscribe

ULTRA

$99.99/mo

1,000,000 tokens / month

  • Access to all APIs
  • Tokens reset monthly
  • Priority support
Subscribe

Need higher volume, dedicated infra, or a custom contract? Talk to sales β†’

Questions about Astronomy API

Ship Astronomy API this afternoon.

500 free tokens. No card. Plus 125+ other APIs on the same key.