Time Zone API for Sunrise & Sunset Apps

Supporting JSON time-zone data for apps that display sunrise, sunset, twilight, golden hour and daylight information anywhere on Earth.

Every solar event must be shown in the correct local time. Handling time zones, DST transitions and geo-IP lookups requires heavy libraries. This supporting Sunrise.am Time API does that work on our servers and returns a clean JSON response for solar dashboards, daylight planners, IoT devices, smart mirrors and web applications.

  • ✅ Free supporting time-zone API for sunrise and sunset projects.
  • ✅ No API Key required – just start fetching.
  • ✅ CORS Enabled – Access directly from frontend JavaScript frameworks (React, Vue, etc.).
  • ✅ Accurate Atomic Time synchronized continuously.

❤️ Support This Free API (Required)

We provide this service completely free of charge. In exchange, we kindly ask that you provide a link back to Sunrise.am on your website footer, README, or application "About" screen.

Copy this snippet:

<a href="https://sunrise.am">Sunrise &amp; Sunset data by Sunrise.am</a>

Want to support us further?

Maintaining the servers for millions of API requests costs money. If you love this tool, consider becoming a sponsor. Your logo will be featured below and on our Sponsors page.

Base URL

All API requests should be made via HTTPS to:

https://sunrise.am/developer/api

API Endpoints

GET /timezone/:area/:location

Request the current time object for a specific IANA timezone.

Example Request:

GET https://sunrise.am/developer/api/timezone/Europe/London

Example JSON Response:

{
  "abbreviation": "BST",
  "datetime": "2023-10-05T14:30:00.123456+01:00",
  "day_of_week": 4,
  "day_of_year": 278,
  "dst": true,
  "dst_offset": 3600,
  "timezone": "Europe/London",
  "unixtime": 1696512600,
  "utc_datetime": "2023-10-05T13:30:00.123456Z",
  "utc_offset": "+01:00",
  "week_number": 40
}

GET /ip

Get the current time based on the public IP address of the requester. This is useful for auto-detecting a user's local time without asking for location permissions.

Auto-Detect IP Request:

GET https://sunrise.am/developer/api/ip

Specific IP Lookup Request:

GET https://sunrise.am/developer/api/ip/8.8.8.8

GET /timezone

Returns a list of all available valid IANA timezone strings as a JSON array.

GET https://sunrise.am/developer/api/timezone

JSON Response Schema

The API returns a JSON object with the following fields:

Key Type Description
timezone String The IANA timezone name (e.g., America/New_York).
datetime String Current local time in ISO8601 format with offset.
unixtime Integer Seconds since the Unix Epoch (UTC).
utc_offset String The offset from UTC as a string (e.g., +05:30).
abbreviation String Short timezone name (e.g., EST, JST, CST).
dst Boolean True if Daylight Saving Time is currently active.
dst_offset Integer Seconds added due to DST (usually 0 or 3600).
client_ip String The IP address used for the geo-lookup.

Code Examples

JavaScript (Fetch)

fetch('https://sunrise.am/developer/api/ip')
  .then(response => response.json())
  .then(data => {
    console.log('Current time:', data.datetime);
    console.log('Timezone:', data.timezone);
  });

Python (Requests)

Example request for Asia/Tokyo:

import requests

response = requests.get('https://sunrise.am/developer/api/timezone/Asia/Tokyo')
data = response.json()
print(f"Current time in Tokyo: {data['datetime']}")

cURL

curl "https://sunrise.am/developer/api/timezone/Europe/Paris"