Sunset and sunrise times API (Version 2)

Download OpenAPI specification:

Our free API tells you when the sun rises and sets anywhere on Earth, plus twilight, golden hour, solar position and moon data. All you need is a latitude and longitude; you make a simple GET request and get the answer as JSON.

Time come in the local timezone of the place, and you can ask for a single day or up to a whole year in one request.

The API is free to use; no sign up or API key required.

getSunriseSunset

Returns when the sun rises and sets anywhere on Earth, plus twilight, golden hour, solar position and moon data.

query Parameters
lat
required
number <float> [ -90 .. 90 ]
Example: lat=36.72016

Latitude in decimal degrees, -90 to 90.

lng
required
number <float> [ -180 .. 180 ]
Example: lng=4.42034

Longitude in decimal degrees, -180 to 180.

date
string
Example: date=tomorrow

Date in YYYY-MM-DD format, today or tomorrow. Defaults to today in the local timezone of the coordinates.

date_start
string <date>
Example: date_start=2026-01-01

Start date in YYYY-MM-DD format, paired with date_end, the requested date range cannot exceed 366 days in a single request. You can request days up to a full year in the same location once instead of one request per day.

date_end
string <date>
Example: date_end=2026-12-31

End date in YYYY-MM-DD format, paired with date_start, the requested date range cannot exceed 366 days in a single request. You can request days up to a full year in the same location once instead of one request per day.

tz
string
Example: tz=Europe/Madrid

Timezone of the location. You usually don't need this as the default time comes in the location's time zone. Set it if only you want the times expressed in a different time zone, using a standard time zone name, such as Europe/Madrid or America/Los_Angeles (abbreviations like PST are rejected).

Coordinates in international waters resolves to nautical etc/GMT zones.

time_format
string
Default: "iso8601"
Enum: "iso8601" "unix"
Example: time_format=iso8601

The time format of events. By default, the response would be in iso8601, but you can use unix. If unix, all event times are Unix epoch seconds (UTC by definition, handy for embedded clients). tzid/utc_offset are still included as context in the response, and the date/tz parameters still determine which local calendar day is computed. Events that do not occur stay null.

Responses

Response samples

Content type
application/json
{
  • "sunrise": "2026-08-07T07:27:08+02:00",
  • "sunset": "2026-08-07T21:19:49+02:00",
  • "solar_noon": "2026-08-07T14:23:28+02:00",
  • "day_length": 49961,
  • "sun_status": "normal",
  • "civil_twilight_begin": "2026-08-09T07:02:15+02:00",
  • "civil_twilight_end": "2026-08-09T21:44:10+02:00",
  • "nautical_twilight_begin": "2026-08-07T06:26:26+02:00",
  • "nautical_twilight_end": "2026-08-07T22:20:30+02:00",
  • "astronomical_twilight_begin": "2026-08-09T05:52:33+02:00",
  • "astronomical_twilight_end": "2026-08-09T22:53:51+02:00",
  • "dawn": "2026-08-07T07:00:27+02:00",
  • "dusk": "2026-08-07T21:46:29+02:00",
  • "first_light": "2026-08-07T05:50:09+02:00",
  • "last_light": "2026-08-07T22:56:48+02:00",
  • "golden_hour": {
    },
  • "blue_hour": {
    },
  • "solar_position": {
    },
  • "moonrise": "2026-08-07T01:27:00+02:00",
  • "moonset": "2026-08-07T16:47:30+02:00",
  • "moon_phase": "Last Quarter",
  • "moon_illumination": 100
}