Sunset and sunrise times API

We offer a free API that provides sunset and sunrise times for a given latitude and longitude.

Please note that attribution is required if you use our API. Check "Usage limits and attribution" section below for more information.

API documentation

Ours is a very simple REST api, you only have to do a GET request to No need to sign up or get an API Key.

Request parameters

Sample requests

These are three sample requests for getting sunset and sunrise information from our API for a given location:


The API response include the times for the sun events in the given location. Data is formatted using JSON.

Note that unless you provide a tzid, all times are in UTC and summer time adjustments are not included in the returned data.

An example response:

        "sunrise":"7:27:02 AM",
        "sunset":"5:05:55 PM",
        "solar_noon":"12:16:28 PM",
        "civil_twilight_begin":"6:58:14 AM",
        "civil_twilight_end":"5:34:43 PM",
        "nautical_twilight_begin":"6:25:47 AM",
        "nautical_twilight_end":"6:07:10 PM",
        "astronomical_twilight_begin":"5:54:14 AM",
        "astronomical_twilight_end":"6:38:43 PM"
       "tzid": "UTC"

Response without date formatting:

       "tzid": "UTC"

Consult our glossary of astronical definitions to understand each element of the response object.

Status codes

The "status" field within the API response object contains the status of the request. The "status" field may contain the following values:

How to use the API from an AJAX request?

Use the parameter callback to receive a JSONP response and avoid cross domain boundaries:

Usage limits and attribution

The sunrise and sunset API can be used free of charge. You may not use this API in a manner that exceeds reasonable request volume, constitutes excessive or abusive usage. We require that you show attribution to us with a link to our site.


Subscribe to our API newsletter to keep up to date with changes and announcements about the service:

💡 Got a cool idea? 🤦 Found any errors?

We're always improving this website!

If you have an idea of some content or information to include in this page or found an error, please let us know!



Please contact us for all your API questions.

If you enjoy using our API please consider supporting the project by buying us a coffe!