---
title: "API for sunrise, sunset, moonrise and moonset timing"
slug: "/astronomy-api.html"
parent: "IP Geolocation API"
description: "Astronomy API provides timings for sunrise, sunset, moonrise, moonset, sun and moon azimuth, their altitude and distance from the earth."
---

# API for Sunset, Sunrise, Moonset and Moonrise timings

Our Astronomy API provides timings for sunrise, sunset, moonrise, moonset, sun azimuth, moon azimuth, sun altitude, moon altitude, sun distance from the earth and moon distance from the earth from latitude and longitude or an IPv4 or IPv6 address for a given date.

[Get Free API Access](https://app.ipgeolocation.io/signup)[Explore Documentation](https://ipgeolocation.io/documentation/astronomy-api.html)

## Comprehensive Sun and Moon Data

The Astronomy API provides a detailed dataset about twilight timings, different sun and moon parameters for a given date and location.

**Response Preview**

```json
{
  "location": {
    "latitude": "40.76473",
    "longitude": "-74.00084",
    "country_name": "United States",
    "state_prov": "New York",
    "city": "New York",
    "locality": "Midtown West",
    "elevation": "9"
  },
  "astronomy": {
    "date": "2026-12-09",
    "current_time": "07:25:35.777",
    "mid_night": "23:48",
    "night_end": "05:30",
    "morning": {
      "astronomical_twilight_begin": "05:30",
      "astronomical_twilight_end": "06:03",
      "nautical_twilight_begin": "06:03",
      "nautical_twilight_end": "06:37",
      "civil_twilight_begin": "06:37",
      "civil_twilight_end": "07:08",
      "blue_hour_begin": "06:26",
      "blue_hour_end": "06:49",
      "golden_hour_begin": "06:49",
      "golden_hour_end": "07:51"
    },
    "sunrise": "07:08",
    "sunset": "16:28",
    "evening": {
      "golden_hour_begin": "15:45",
      "golden_hour_end": "16:47",
      "blue_hour_begin": "16:47",
      "blue_hour_end": "17:10",
      "civil_twilight_begin": "16:28",
      "civil_twilight_end": "16:59",
      "nautical_twilight_begin": "16:59",
      "nautical_twilight_end": "17:33",
      "astronomical_twilight_begin": "17:33",
      "astronomical_twilight_end": "18:06"
    },
    "night_begin": "18:06",
    "sun_status": "-",
    "solar_noon": "11:48",
    "day_length": "09:20",
    "sun_altitude": 1.9394705633583513,
    "sun_distance": 147366924.6229829,
    "sun_azimuth": 122.82255749721617,
    "moon_phase": "NEW_MOON",
    "moonrise": "07:58",
    "moonset": "16:41",
    "moon_status": "-",
    "moon_altitude": -4.890702157978301,
    "moon_distance": 404824.1088149897,
    "moon_azimuth": 122.68808398205493,
    "moon_parallactic_angle": -45.99383596680553,
    "moon_illumination_percentage": "0.21",
    "moon_angle": 5.258133787788791
  }
}
```

## Getting Astronomical Information from a Location Coordinates

You can pass the latitude and longitude of a location as query parameters to get the astronomical information.

**Request**

```shell
curl 'https://api.ipgeolocation.io/v3/astronomy?apiKey=API_KEY&lat=40.76473&long=-74.00084'
```

**Response Preview**

```json
{
  "location": {
    "latitude": "40.76473",
    "longitude": "-74.00084",
    "country_name": "United States",
    "state_prov": "New York",
    "city": "New York",
    "locality": "Midtown West",
    "elevation": "9"
  },
  "astronomy": {
    "date": "2025-07-17",
    "current_time": "08:03:36.532",
    "mid_night": "01:02",
    "night_end": "03:40",
    "morning": {
      "astronomical_twilight_begin": "03:40",
      "astronomical_twilight_end": "04:27",
      "nautical_twilight_begin": "04:27",
      "nautical_twilight_end": "05:07",
      "civil_twilight_begin": "05:07",
      "civil_twilight_end": "05:39",
      "blue_hour_begin": "04:54",
      "blue_hour_end": "05:20",
      "golden_hour_begin": "05:20",
      "golden_hour_end": "06:19"
    },
    "sunrise": "05:39",
    "sunset": "20:24",
    "evening": {
      "golden_hour_begin": "19:44",
      "golden_hour_end": "20:44",
      "blue_hour_begin": "20:44",
      "blue_hour_end": "21:09",
      "civil_twilight_begin": "20:24",
      "civil_twilight_end": "20:56",
      "nautical_twilight_begin": "20:56",
      "nautical_twilight_end": "21:37",
      "astronomical_twilight_begin": "21:37",
      "astronomical_twilight_end": "22:23"
    },
    "night_begin": "22:23",
    "sun_status": "-",
    "solar_noon": "13:02",
    "day_length": "14:45",
    "sun_altitude": 24.957683470850487,
    "sun_distance": 152059278.3394745,
    "sun_azimuth": 82.93803947255543,
    "moon_phase": "LAST_QUARTER",
    "moonrise": "-:-",
    "moonset": "13:04",
    "moon_status": "-",
    "moon_altitude": 50.865120808868284,
    "moon_distance": 371690.2207058187,
    "moon_azimuth": 224.27457358894264,
    "moon_parallactic_angle": 32.4113797557535,
    "moon_illumination_percentage": "-55.99",
    "moon_angle": 263.11859022190265
  }
}
```

## Getting Astronomical Information from an IPv4 or IPv6 Address

You can pass any IPv4 or IPv6 address as a query parameter to get the astronomical information.

**Request**

```shell
curl 'https://api.ipgeolocation.io/v3/astronomy?apiKey=API_KEY&ip=8.8.8.8'
```

**Response Preview**

```json
{
  "ip": "8.8.8.8",
  "location": {
    "continent_code": "NA",
    "continent_name": "North America",
    "country_code2": "US",
    "country_code3": "USA",
    "country_name": "United States",
    "country_name_official": "United States of America",
    "is_eu": false,
    "state_prov": "California",
    "state_code": "US-CA",
    "district": "Santa Clara",
    "city": "Mountain View",
    "zipcode": "R3C 3Z5",
    "latitude": "37.42240",
    "longitude": "-122.08421",
    "locality": "Charleston Terrace",
    "elevation": "3"
  },
  "astronomy": {
    "date": "2025-07-17",
    "current_time": "05:18:39.638",
    "mid_night": "01:14",
    "night_end": "04:13",
    "morning": {
      "astronomical_twilight_begin": "04:13",
      "astronomical_twilight_end": "04:54",
      "nautical_twilight_begin": "04:54",
      "nautical_twilight_end": "05:31",
      "civil_twilight_begin": "05:31",
      "civil_twilight_end": "06:01",
      "blue_hour_begin": "05:19",
      "blue_hour_end": "05:43",
      "golden_hour_begin": "05:43",
      "golden_hour_end": "06:39"
    },
    "sunrise": "06:01",
    "sunset": "20:27",
    "evening": {
      "golden_hour_begin": "19:49",
      "golden_hour_end": "20:45",
      "blue_hour_begin": "20:45",
      "blue_hour_end": "21:09",
      "civil_twilight_begin": "20:27",
      "civil_twilight_end": "20:57",
      "nautical_twilight_begin": "20:57",
      "nautical_twilight_end": "21:34",
      "astronomical_twilight_begin": "21:34",
      "astronomical_twilight_end": "22:15"
    },
    "night_begin": "22:15",
    "sun_status": "-",
    "solar_noon": "13:14",
    "day_length": "14:26",
    "sun_altitude": -8.065470874567971,
    "sun_distance": 152059278.33947453,
    "sun_azimuth": 55.51866495593282,
    "moon_phase": "LAST_QUARTER",
    "moonrise": "-:-",
    "moonset": "13:21",
    "moon_status": "-",
    "moon_altitude": 57.75697897229163,
    "moon_distance": 371670.433117456,
    "moon_azimuth": 145.37574157276907,
    "moon_parallactic_angle": -27.227697843907947,
    "moon_illumination_percentage": "-55.87",
    "moon_angle": 263.25532237911756
  }
}
```

## Use Cases

### Photography

With every sunrise and sunset, nature creates a masterpiece. Take advantage of them and plan your photography sessions ahead of time for the perfect capture with our sunrise-sunset API.

### Sports

Planning a game of golf? Make sure you plan your tee for the right light. Because you know what they say,"The most important shot is the first one."

### Travelers

Plan the perfect sunset romantic dinner, hiking trip or star-gazing party by taking advantage of the best star API you can find.

### Astronomy

"Twilight is the time of the day when the sky looks like it has been painted by a graffiti artist". Use our astronomy API to plan the perfect time to view this breath-taking phenomenon and explore one of the most over-whelming covers of the heavens.

### Solar panel placement...?

Trying to figure out the optimal angle for your solar panels? Use our API to get the exact solar azimuth and calculate the best solar panel angle by street address.

## Ready to get started? Get Started with Astronomy API Today

Enrich every request with precise geolocation and real-time threat intelligence, delivered on a global edge with a 99.99% uptime SLA. Start free and scale when you’re ready.

[Get Started](https://app.ipgeolocation.io/signup)
