---
title: Sun and Moon Position API
slug: sun-and-moon-position-api
url: https://apyhub.com/modernsoftware-pro/service/sun-and-moon-position-api
provider: ModernSoftware.pro
categories: [Verification Kit, Output Kit]
tags: [sun-times, moon-times, astronomy, solar-calculations, geolocation]
auth: api_key
version: 1.0
service_type: sync
endpoints: 1
atoms: 20
mcp: true
---

# Sun and Moon Position API

Get sunrise, twilight, solar noon, nadir, and moon position data for a latitude, longitude, and datetime. Useful for location-aware scheduling and astronomy apps.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| GET | `https://api.eu.apyhub.com/modernsoftware-pro/sun-and-moon-position-api/sunrise` | What it does Calculates sun and moon information for a given location and time. It accepts latitude… | 20 |

## Endpoint reference

### Calculates sun and moon information for a given location and time.

`GET https://api.eu.apyhub.com/modernsoftware-pro/sun-and-moon-position-api/sunrise` · 20 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `datetime` | query | string | yes | Date and time to check, as `yyyy-MM-ddTHH:mm:ss` |
| `latitude` | query | number (double) | yes | Location latitude to check |
| `longitude` | query | number (double) | yes | Location longitude to check |
| `utcOffset` | query | string | no | Optional UTC timezone prefix (leave empty to auto-detect) |

#### Quickstart

Fetch sun, moon, and twilight times for a specific location and datetime using query parameters.

```bash
curl -X GET "https://api.eu.apyhub.com/modernsoftware-pro/sun-and-moon-position-api/sunrise?latitude=40.7128&longitude=-74.006&datetime=2026-10-28T12:00:00" \
  -H "apy-token: $APY_TOKEN"
```

#### What you'll get back

Returns a JSON object with top-level timing fields for the day, plus `sun` and `moon` objects. Arrays like `day`, `morningGoldenHour`, and `civilTwilight` contain zero or more `{ "from": "HH:MM", "to": "HH:MM" }` entries; `solarNoon`, `nadir`, and the various dawn/dusk fields are `HH:MM` strings, while `sun` and `moon` include the numeric position details.

```json
{
  "day": [],
  "morningGoldenHour": [],
  "civilTwilight": [],
  "nauticalTwilight": [],
  "astronomicalTwilight": [],
  "eveningGoldenHour": [],
  "civilDusk": [],
  "nauticalDusk": [],
  "astronomicalDusk": [],
  "night": [],
  "solarNoon": "12:00",
  "nadir": "00:00",
  "sun": { "altitude": 0, "azimuth": 0 },
  "moon": {
    "altitude": 0,
    "azimuth": 0,
    "distance": 0,
    "parallacticAngle": 0,
    "moonrise": [],
    "moonset": []
  }
}
```

## About

## What it does
Sun and Moon Times gives you sun and moon position data for a specific location and moment. Send `latitude`, `longitude`, and `datetime`, and get back the current solar and lunar angles plus the key daylight phases for that day.

Use it when your app needs to know more than just sunrise and sunset. The response includes `day`, `morningGoldenHour`, `civilTwilight`, `nauticalTwilight`, `astronomicalTwilight`, `eveningGoldenHour`, `civilDusk`, `nauticalDusk`, `astronomicalDusk`, `night`, `solarNoon`, and `nadir`, along with `sun` and `moon` objects. The sun data includes `altitude` and `azimuth`. The moon data includes `altitude`, `azimuth`, `distance`, `parallacticAngle`, `moonrise`, and `moonset`.

The phase fields are returned as local-time ranges in `HH:MM` format, so you can render photography planning tools, astronomy views, outdoor activity schedules, or weather apps without converting timestamps yourself. If you need to account for a specific timezone, you can also pass `utcOffset` in the request.

Sun and Moon Times is useful anywhere you need time-aware lighting or sky-position data tied to coordinates: planning shoots around golden hour, showing when twilight ends, or checking whether the moon rises on a given calendar day.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/modernsoftware-pro/service/sun-and-moon-position-api
