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.

    • stringip:"216.73.216.139",
    • 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-03-05",
      • stringcurrent_time:"07:52:52.402",
      • stringmid_night:"00:43",
      • stringnight_end:"05:29",
      • objectmorning:Object,
        • stringastronomical_twilight_begin:"05:29",
        • stringastronomical_twilight_end:"06:00",
        • stringnautical_twilight_begin:"06:00",
        • stringnautical_twilight_end:"06:32",
        • stringcivil_twilight_begin:"06:32",
        • stringcivil_twilight_end:"06:56",
        • stringblue_hour_begin:"06:21",
        • stringblue_hour_end:"06:42",
        • stringgolden_hour_begin:"06:42",
        • stringgolden_hour_end:"07:35",
      • stringsunrise:"06:56",
      • stringsunset:"18:31",
      • objectevening:Object,
        • stringgolden_hour_begin:"17:52",
        • stringgolden_hour_end:"18:45",
        • stringblue_hour_begin:"18:45",
        • stringblue_hour_end:"19:05",
        • stringcivil_twilight_begin:"18:31",
        • stringcivil_twilight_end:"18:55",
        • stringnautical_twilight_begin:"18:55",
        • stringnautical_twilight_end:"19:26",
        • stringastronomical_twilight_begin:"19:26",
        • stringastronomical_twilight_end:"19:58",
      • stringnight_begin:"19:58",
      • stringsun_status:"-",
      • stringsolar_noon:"12:43",
      • stringday_length:"11:34",
      • numbersun_altitude:9.265648936679678,
      • numbersun_distance:148278274.79446396,
      • numbersun_azimuth:105.84739619293885,
      • stringmoon_phase:"WANING_GIBBOUS",
      • stringmoonrise:"21:02",
      • stringmoonset:"07:50",
      • stringmoon_status:"-",
      • numbermoon_altitude:-0.7908243228431209,
      • numbermoon_distance:391542.45220691425,
      • numbermoon_azimuth:262.4647094298505,
      • numbermoon_parallactic_angle:49.85695389615073,
      • stringmoon_illumination_percentage:"-95.45",
      • numbermoon_angle:204.6268880887492,
  • 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
    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-12-09",
    13    "current_time": "07:25:35.777",
    14    "mid_night": "23:48",
    15    "night_end": "05:30",
    16    "morning": {
    17      "astronomical_twilight_begin": "05:30",
    18      "astronomical_twilight_end": "06:03",
    19      "nautical_twilight_begin": "06:03",
    20      "nautical_twilight_end": "06:37",
    21      "civil_twilight_begin": "06:37",
    22      "civil_twilight_end": "07:08",
    23      "blue_hour_begin": "06:26",
    24      "blue_hour_end": "06:49",
    25      "golden_hour_begin": "06:49",
    26      "golden_hour_end": "07:51"
    27    },
    28    "sunrise": "07:08",
    29    "sunset": "16:28",
    30    "evening": {
    31      "golden_hour_begin": "15:45",
    32      "golden_hour_end": "16:47",
    33      "blue_hour_begin": "16:47",
    34      "blue_hour_end": "17:10",
    35      "civil_twilight_begin": "16:28",
    36      "civil_twilight_end": "16:59",
    37      "nautical_twilight_begin": "16:59",
    38      "nautical_twilight_end": "17:33",
    39      "astronomical_twilight_begin": "17:33",
    40      "astronomical_twilight_end": "18:06"
    41    },
    42    "night_begin": "18:06",
    43    "sun_status": "-",
    44    "solar_noon": "11:48",
    45    "day_length": "09:20",
    46    "sun_altitude": 1.9394705633583513,
    47    "sun_distance": 147366924.6229829,
    48    "sun_azimuth": 122.82255749721617,
    49    "moon_phase": "NEW_MOON",
    50    "moonrise": "07:58",
    51    "moonset": "16:41",
    52    "moon_status": "-",
    53    "moon_altitude": -4.890702157978301,
    54    "moon_distance": 404824.1088149897,
    55    "moon_azimuth": 122.68808398205493,
    56    "moon_parallactic_angle": -45.99383596680553,
    57    "moon_illumination_percentage": "0.21",
    58    "moon_angle": 5.258133787788791
    59  }
    60}

    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
    curl 'https://api.ipgeolocation.io/v3/astronomy?apiKey=API_KEY&lat=40.76473&long=-74.00084'
    Response
    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": "2025-07-17",
    13    "current_time": "08:03:36.532",
    14    "mid_night": "01:02",
    15    "night_end": "03:40",
    16    "morning": {
    17      "astronomical_twilight_begin": "03:40",
    18      "astronomical_twilight_end": "04:27",
    19      "nautical_twilight_begin": "04:27",
    20      "nautical_twilight_end": "05:07",
    21      "civil_twilight_begin": "05:07",
    22      "civil_twilight_end": "05:39",
    23      "blue_hour_begin": "04:54",
    24      "blue_hour_end": "05:20",
    25      "golden_hour_begin": "05:20",
    26      "golden_hour_end": "06:19"
    27    },
    28    "sunrise": "05:39",
    29    "sunset": "20:24",
    30    "evening": {
    31      "golden_hour_begin": "19:44",
    32      "golden_hour_end": "20:44",
    33      "blue_hour_begin": "20:44",
    34      "blue_hour_end": "21:09",
    35      "civil_twilight_begin": "20:24",
    36      "civil_twilight_end": "20:56",
    37      "nautical_twilight_begin": "20:56",
    38      "nautical_twilight_end": "21:37",
    39      "astronomical_twilight_begin": "21:37",
    40      "astronomical_twilight_end": "22:23"
    41    },
    42    "night_begin": "22:23",
    43    "sun_status": "-",
    44    "solar_noon": "13:02",
    45    "day_length": "14:45",
    46    "sun_altitude": 24.957683470850487,
    47    "sun_distance": 152059278.3394745,
    48    "sun_azimuth": 82.93803947255543,
    49    "moon_phase": "LAST_QUARTER",
    50    "moonrise": "-:-",
    51    "moonset": "13:04",
    52    "moon_status": "-",
    53    "moon_altitude": 50.865120808868284,
    54    "moon_distance": 371690.2207058187,
    55    "moon_azimuth": 224.27457358894264,
    56    "moon_parallactic_angle": 32.4113797557535,
    57    "moon_illumination_percentage": "-55.99",
    58    "moon_angle": 263.11859022190265
    59  }
    60}

    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
    curl 'https://api.ipgeolocation.io/v3/astronomy?apiKey=API_KEY&ip=8.8.8.8'
    Response
    1{
    2  "ip": "8.8.8.8",
    3  "location": {
    4    "continent_code": "NA",
    5    "continent_name": "North America",
    6    "country_code2": "US",
    7    "country_code3": "USA",
    8    "country_name": "United States",
    9    "country_name_official": "United States of America",
    10    "is_eu": false,
    11    "state_prov": "California",
    12    "state_code": "US-CA",
    13    "district": "Santa Clara",
    14    "city": "Mountain View",
    15    "zipcode": "R3C 3Z5",
    16    "latitude": "37.42240",
    17    "longitude": "-122.08421",
    18    "locality": "Charleston Terrace",
    19    "elevation": "3"
    20  },
    21  "astronomy": {
    22    "date": "2025-07-17",
    23    "current_time": "05:18:39.638",
    24    "mid_night": "01:14",
    25    "night_end": "04:13",
    26    "morning": {
    27      "astronomical_twilight_begin": "04:13",
    28      "astronomical_twilight_end": "04:54",
    29      "nautical_twilight_begin": "04:54",
    30      "nautical_twilight_end": "05:31",
    31      "civil_twilight_begin": "05:31",
    32      "civil_twilight_end": "06:01",
    33      "blue_hour_begin": "05:19",
    34      "blue_hour_end": "05:43",
    35      "golden_hour_begin": "05:43",
    36      "golden_hour_end": "06:39"
    37    },
    38    "sunrise": "06:01",
    39    "sunset": "20:27",
    40    "evening": {
    41      "golden_hour_begin": "19:49",
    42      "golden_hour_end": "20:45",
    43      "blue_hour_begin": "20:45",
    44      "blue_hour_end": "21:09",
    45      "civil_twilight_begin": "20:27",
    46      "civil_twilight_end": "20:57",
    47      "nautical_twilight_begin": "20:57",
    48      "nautical_twilight_end": "21:34",
    49      "astronomical_twilight_begin": "21:34",
    50      "astronomical_twilight_end": "22:15"
    51    },
    52    "night_begin": "22:15",
    53    "sun_status": "-",
    54    "solar_noon": "13:14",
    55    "day_length": "14:26",
    56    "sun_altitude": -8.065470874567971,
    57    "sun_distance": 152059278.33947453,
    58    "sun_azimuth": 55.51866495593282,
    59    "moon_phase": "LAST_QUARTER",
    60    "moonrise": "-:-",
    61    "moonset": "13:21",
    62    "moon_status": "-",
    63    "moon_altitude": 57.75697897229163,
    64    "moon_distance": 371670.433117456,
    65    "moon_azimuth": 145.37574157276907,
    66    "moon_parallactic_angle": -27.227697843907947,
    67    "moon_illumination_percentage": "-55.87",
    68    "moon_angle": 263.25532237911756
    69  }
    70}

    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.

    Photography image

    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."

    Sports image

    Travelers

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

    For travelers

    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.

    astronomy use case

    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.

    Solar panel placement image

    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.

    CTA Illustration
    CTA Illustration

    Subscribe Our Newsletter

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