Astronomy API for Sunrise, Sunset, and Moon Phase Data

One Astronomy API call returns sun, moon, twilight, and golden hour data for any date, past or future, by coordinates, city, address, or IP. Free for 1,000 requests a day.

    • stringip:"216.73.216.82",
    • objectlocation:Object,
      • stringcontinent_code:"NA",
      • stringcontinent_name:"North America",
      • stringcountry_code2:"US",
      • stringcountry_code3:"USA",
      • stringcountry_name:"United States",
      • stringcountry_name_official:"United States of America",
      • booleanis_eu:false,
      • stringstate_prov:"Ohio",
      • stringstate_code:"US-OH",
      • stringdistrict:"Franklin",
      • stringcity:"Columbus",
      • stringzipcode:"43215",
      • stringlatitude:"39.96199",
      • stringlongitude:"-83.00275",
      • stringlocality:"Mile on High",
      • stringelevation:"235",
    • objectastronomy:Object,
      • stringdate:"2026-09-01",
      • stringcurrent_time:"04:04:48.900",
      • stringmid_night:"01:32",
      • stringnight_end:"05:24",
      • objectmorning:Object,
        • stringastronomical_twilight_begin:"05:24",
        • stringastronomical_twilight_end:"05:59",
        • stringnautical_twilight_begin:"05:59",
        • stringnautical_twilight_end:"06:32",
        • stringcivil_twilight_begin:"06:32",
        • stringcivil_twilight_end:"06:57",
        • stringblue_hour_begin:"06:21",
        • stringblue_hour_end:"06:43",
        • stringgolden_hour_begin:"06:43",
        • stringgolden_hour_end:"07:36",
      • stringsunrise:"06:57",
      • stringsunset:"20:05",
      • objectevening:Object,
        • stringgolden_hour_begin:"19:27",
        • stringgolden_hour_end:"20:20",
        • stringblue_hour_begin:"20:20",
        • stringblue_hour_end:"20:41",
        • stringcivil_twilight_begin:"20:05",
        • stringcivil_twilight_end:"20:31",
        • stringnautical_twilight_begin:"20:31",
        • stringnautical_twilight_end:"21:04",
        • stringastronomical_twilight_begin:"21:04",
        • stringastronomical_twilight_end:"21:38",
      • stringnight_begin:"21:38",
      • stringsun_status:"-",
      • stringsolar_noon:"13:31",
      • stringday_length:"13:08",
      • numbersun_altitude:-30.29403338075661,
      • numbersun_distance:151012390.3223616,
      • numbersun_azimuth:45.11596558304723,
      • stringmoon_phase:"WANING_GIBBOUS",
      • stringmoonrise:"22:00",
      • stringmoonset:"11:54",
      • stringmoon_status:"-",
      • numbermoon_altitude:64.9301303148046,
      • numbermoon_distance:377333.0780838015,
      • numbermoon_azimuth:162.58375318240337,
      • numbermoon_parallactic_angle:-13.791241048822041,
      • stringmoon_illumination_percentage:"-81.38",
      • numbermoon_angle:231.11971548901832,
  • Trusted by teams at

    Spacex logoAmazon logoCheckout logoIntuit logoPfizer logoIkea logoAvast logoTencent logoFord logoReversing Labs logoOpen Vpn logoAtlassian logo
    What API Offers

    One request, every sun and moon field

    The Astronomy API returns sunrise, sunset, moonrise, moonset, moon phase, twilight, golden hour, and blue hour times for any location and any date. Query it with coordinates, an IPv4 or IPv6 address, a city name, or a street address, and every time in the response is local to that place.

    Astronomy By Location Coordinates

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

    Full API Docs
    Request
    curl 'https://api.ipgeolocation.io/v3/astronomy?apiKey=API_KEY&lat=40.76473&long=-74.00084'
    Response Preview
    1{
    2  "location": {
    3    "latitude": "40.76473",
    4    "longitude": "-74.00084",
    5    "country_name": "United States",
    6    "state_prov": "New York",
    7    "city": "New York",
    8    "locality": "Midtown West",
    9    "elevation": "9"
    10  },
    11  "astronomy": {
    12    "date": "2026-08-19",
    13    "current_time": "02:25:42.544",
    14    "mid_night": "00:59",
    15    "night_end": "04:28",
    16    "morning": {
    17      "astronomical_twilight_begin": "04:28",
    18      "astronomical_twilight_end": "05:06",
    19      "nautical_twilight_begin": "05:06",
    20      "nautical_twilight_end": "05:41",
    21      "civil_twilight_begin": "05:41",
    22      "civil_twilight_end": "06:09",
    23      "blue_hour_begin": "05:29",
    24      "blue_hour_end": "05:52",
    25      "golden_hour_begin": "05:52",
    26      "golden_hour_end": "06:47"
    27    },
    28    "sunrise": "06:09",
    29    "sunset": "19:48",
    30    "evening": {
    31      "golden_hour_begin": "19:11",
    32      "golden_hour_end": "20:05",
    33      "blue_hour_begin": "20:05",
    34      "blue_hour_end": "20:28",
    35      "civil_twilight_begin": "19:48",
    36      "civil_twilight_end": "20:17",
    37      "nautical_twilight_begin": "20:17",
    38      "nautical_twilight_end": "20:52",
    39      "astronomical_twilight_begin": "20:52",
    40      "astronomical_twilight_end": "21:29"
    41    },
    42    "night_begin": "21:29",
    43    "sun_status": "-",
    44    "solar_noon": "12:59",
    45    "day_length": "13:39",
    46    "sun_altitude": -32.909747839506174,
    47    "sun_distance": 151434594.7878357,
    48    "sun_azimuth": 25.198749383374206,
    49    "moon_phase": "FIRST_QUARTER",
    50    "moonrise": "13:46",
    51    "moonset": "23:03",
    52    "moon_status": "-",
    53    "moon_altitude": -41.94173517451815,
    54    "moon_distance": 398747.92917074164,
    55    "moon_azimuth": 276.65671450158897,
    56    "moon_parallactic_angle": 54.11011524338014,
    57    "moon_illumination_percentage": "41.74",
    58    "moon_angle": 80.48957371739807
    59  }
    60}
    Data Shape

    What the Astronomy API returns

    Four groups of fields provide a complete view of astronomical events for any point and time on Earth.

    12 AM3 AM6 AM9 AM12 PM3 PM6 PM9 PM12 AMSunMoonSunrise & Sunset5:25 AM6:49 PM

    Location context

    Every response resolves the place you asked about: city, state, country, coordinates, and elevation. Ask by IP and the API geolocates it first; ask by address and it geocodes it. Times come back in that location's own time zone.

    See the Astronomy API documentation for a complete field-by-field reference

    Moon phases and Lunar Data

    Four groups of fields cover the sky for any point on Earth. The docs list every field.


    Today

    Waning Gibbous

    Illumination Waning

    84.31%

    Moonrise21:38
    MoonsetMoon sets after MidnightThe moon slips below the horizon at 10:03 the following calendar day.

    View the full moon fields reference in the Astronomy API documentation.

    Methodology and Accuracy

    How sunrise and sunset times are calculated

    The Astronomy API computes Sun and Moon events from their position relative to your local horizon, using your coordinates, date, elevation, and time zone to produce accurate local event times.

    Standard solar depression angles, as defined by the U.S. Naval Observatory, govern our twilight fields.

    • Civil twilight spans zero to six degrees below horizon.
    • Nautical twilight spans six to twelve degrees below horizon.
    • Astronomical twilight spans twelve to eighteen degrees below horizon.
    Date Ranges in One Call

    Astronomy data for any date, or 90 days at once

    Pass date and the same request returns any past or future day. Need a range? The timeSeries endpoint returns up to 90 days of sunrise, sunset, twilight, and moon data in a single call, one row per day, for calendars, almanac features, and solar planning.

    Request
    curl -X GET 'https://api.ipgeolocation.io/v3/astronomy/timeSeries?apiKey=<YOUR_API_KEY>&lat=40.76473&long=-74.00084&dateStart=2026-08-18&dateEnd=2026-08-20'
    Response Preview
    1{
    2  "location": {
    3    "latitude": "40.76473",
    4    "longitude": "-74.00084",
    5    "country_name": "United States",
    6    "state_prov": "New York",
    7    "city": "New York",
    8    "locality": "Midtown West",
    9    "elevation": "9"
    10  },
    11  "astronomy": [
    12    {
    13      "date": "2026-08-18",
    14      "mid_night": "01:00",
    15      "night_end": "04:27",
    16      "morning": {
    17        "astronomical_twilight_begin": "04:27",
    18        "astronomical_twilight_end": "05:04",
    19        "nautical_twilight_begin": "05:04",
    20        "nautical_twilight_end": "05:40",
    21        "civil_twilight_begin": "05:40",
    22        "civil_twilight_end": "06:08",
    23        "blue_hour_begin": "05:28",
    24        "blue_hour_end": "05:51",
    25        "golden_hour_begin": "05:51",
    26        "golden_hour_end": "06:46"
    27      },
    28      "sunrise": "06:08",
    29      "sunset": "19:50",
    30      "evening": {
    31        "golden_hour_begin": "19:12",
    32        "golden_hour_end": "20:07",
    33        "blue_hour_begin": "20:07",
    34        "blue_hour_end": "20:30",
    35        "civil_twilight_begin": "19:50",
    36        "civil_twilight_end": "20:18",
    37        "nautical_twilight_begin": "20:18",
    38        "nautical_twilight_end": "20:53",
    39        "astronomical_twilight_begin": "20:53",
    40        "astronomical_twilight_end": "21:31"
    41      },
    42      "night_begin": "21:31",
    43      "sun_status": "-",
    44      "solar_noon": "12:59",
    45      "day_length": "13:41",
    46      "moon_phase": "FIRST_QUARTER",
    47      "moonrise": "12:41",
    48      "moonset": "22:31",
    49      "moon_status": "-"
    50    },
    51    {
    52      "date": "2026-08-19",
    53      "mid_night": "00:59",
    54      "night_end": "04:28",
    55      "morning": {
    56        "astronomical_twilight_begin": "04:28",
    57        "astronomical_twilight_end": "05:06",
    58        "nautical_twilight_begin": "05:06",
    59        "nautical_twilight_end": "05:41",
    60        "civil_twilight_begin": "05:41",
    61        "civil_twilight_end": "06:09",
    62        "blue_hour_begin": "05:29",
    63        "blue_hour_end": "05:52",
    64        "golden_hour_begin": "05:52",
    65        "golden_hour_end": "06:47"
    66      },
    67      "sunrise": "06:09",
    68      "sunset": "19:48",
    69      "evening": {
    70        "golden_hour_begin": "19:11",
    71        "golden_hour_end": "20:05",
    72        "blue_hour_begin": "20:05",
    73        "blue_hour_end": "20:28",
    74        "civil_twilight_begin": "19:48",
    75        "civil_twilight_end": "20:17",
    76        "nautical_twilight_begin": "20:17",
    77        "nautical_twilight_end": "20:52",
    78        "astronomical_twilight_begin": "20:52",
    79        "astronomical_twilight_end": "21:29"
    80      },
    81      "night_begin": "21:29",
    82      "sun_status": "-",
    83      "solar_noon": "12:59",
    84      "day_length": "13:39",
    85      "moon_phase": "FIRST_QUARTER",
    86      "moonrise": "13:46",
    87      "moonset": "23:03",
    88      "moon_status": "-"
    89    },
    90    {
    91      "date": "2026-08-20",
    92      "mid_night": "00:59",
    93      "night_end": "04:30",
    94      "morning": {
    95        "astronomical_twilight_begin": "04:30",
    96        "astronomical_twilight_end": "05:07",
    97        "nautical_twilight_begin": "05:07",
    98        "nautical_twilight_end": "05:42",
    99        "civil_twilight_begin": "05:42",
    100        "civil_twilight_end": "06:10",
    101        "blue_hour_begin": "05:30",
    102        "blue_hour_end": "05:53",
    103        "golden_hour_begin": "05:53",
    104        "golden_hour_end": "06:48"
    105      },
    106      "sunrise": "06:10",
    107      "sunset": "19:47",
    108      "evening": {
    109        "golden_hour_begin": "19:09",
    110        "golden_hour_end": "20:04",
    111        "blue_hour_begin": "20:04",
    112        "blue_hour_end": "20:27",
    113        "civil_twilight_begin": "19:47",
    114        "civil_twilight_end": "20:15",
    115        "nautical_twilight_begin": "20:15",
    116        "nautical_twilight_end": "20:50",
    117        "astronomical_twilight_begin": "20:50",
    118        "astronomical_twilight_end": "21:27"
    119      },
    120      "night_begin": "21:27",
    121      "sun_status": "-",
    122      "solar_noon": "12:59",
    123      "day_length": "13:36",
    124      "moon_phase": "FIRST_QUARTER",
    125      "moonrise": "14:48",
    126      "moonset": "23:41",
    127      "moon_status": "-"
    128    }
    129  ]
    130}
    Astronomy Data for Any Date or 90 Days at Once

    See the Astronomy API documentation for a complete field-by-field reference

    Use Cases

    Prayer time applications

    Daily prayer schedules are anchored to the sun: dawn and dusk prayers to twilight boundaries, midday to solar noon, sunset prayers to the sunset itself. The API returns each boundary per location per date for a perfect prayer times app.

    Prayer time applications image

    Photography and golden hour planning

    Golden hour and blue hour windows, per date, per location, in local time. A photo-planning app can tell a photographer in Santorini exactly when the light turns and how long it lasts, from one request made with nothing more than the town's name.

    Photography and golden hour planning image

    Solar energy and panel placement

    sun_altitude and sun_azimuth by street address make panel orientation a lookup instead of a site survey. Pull a 90-day timeSeries to model seasonal sun paths, estimate yield windows, and point fixed installations where the payback math says they should face.

    Solar energy and panel placement image

    Smart home and IoT scheduling

    Lights at sunset, blinds at golden hour, irrigation before dawn. Because the API accepts an IP address, a hub can schedule against real local sun times with no GPS hardware and no user setup, and re-resolve automatically when the device changes networks.

    Smart home and IoT scheduling image

    Travel and outdoor apps

    Day length and daylight windows by city power safe-hiking cutoffs, sunrise summit alerts, and itinerary planning. Add moonrise, moonset, and phase for stargazing features: a WANING_CRESCENT sky is dark enough for the Milky Way, a FULL_MOON night is not.

    Travel and outdoor apps image

    Astronomy API FAQs

    Yes. The ipgeolocation.io Astronomy API is free for 1,000 requests per day, with no credit card and no attribution requirement. The free tier includes every astronomy field: sunrise, sunset, moonrise, moonset, moon phase, twilight, golden hour, and the timeSeries range endpoint. Paid plans start at $19 per month when you need more volume.
    Local time, by default. The API resolves the IANA time zone of the location you query and expresses every value in it, so sunset in Tokyo reads as Tokyo time. To re-express results in another zone, pass the time_zone parameter with any IANA name, and timestamps then include the full date.
    Yes. The date parameter returns any single past or future date, and the timeSeries endpoint returns up to 90 days in one call: pass dateStart and dateEnd with your location and you get one entry per day, covering sun, twilight, and moon fields. It is the practical way to build calendars and seasonal charts.
    The API tells you instead of guessing. On dates with continuous daylight or continuous night, sunrise and sunset return "-:-" and sun_status reads "Always above the twilight angle" or "Always below the twilight angle". The moon behaves the same way through moon_status . Your code can branch on the status fields rather than parsing sentinel times.
    Call the astronomy endpoint with the ip parameter, or with no parameter to use the caller's own IP. The API geolocates the address, resolves its time zone, and returns sunrise, sunset, twilight, and moon data for that place in local time. One request does the whole chain: no separate geolocation lookup, no coordinate handling.
    Each response includes moonrise, moonset, the named moon phase (eight values from NEW_MOON to WANING_CRESCENT), a signed illumination percentage that is positive while waxing and negative while waning, plus the moon's altitude, azimuth, distance from Earth, and parallactic angle. On days when the moon does not rise or set, the fields return "-:-" with an explanatory status.
    The API computes events using the standard astronomical conventions: the sun's upper edge at the horizon under average refraction, twilight at 6, 12, and 18 degrees of solar depression. Observed times can differ by a minute or so because real atmospheric refraction varies day to day, an inherent limit the U.S. Naval Observatory documents for all rise and set computations. Passing elevation tightens results for observers above sea level. For details, see our practical guide.
    No. There is no attribution requirement on the free plan or any paid plan. The free tier is 1,000 requests per day for life, and the response you get is identical in shape to paid plans, so you can ship a commercial product on it and upgrade only when your volume demands it.

    Start with 1,000 free astronomy lookups a day

    Sunrise to moonset in one request. Get sun, moon, twilight, and golden hour data for any place and date on Earth, backed by a 99.99% uptime SLA. No credit card required.

    Subscribe to Our Newsletter

    Get the latest in geolocation tech, straight to your inbox.