LIVE API

Sunrise and Sunset Tracker API

Get accurate sunrise and sunset times for today and tomorrow based on geographical coordinates.

GET https://suntracker.freeapi.me/?lat=18.4642825&lon=73.8058053

{
  "today": {
    "sunrise": "6:12 AM",
    "sunset": "6:55 PM"
  },
  "tomorrow": {
    "sunrise": "6:11 AM",
    "sunset": "6:55 PM"
  }
}

Documentation

Base URL

https://suntracker.freeapi.me/

All API requests should be made to this endpoint. HTTPS is required for all API calls.

Request Methods

The Sunrise and Sunset Tracker API accepts GET requests only.

Parameters

This API requires the following query parameters:

Parameter Description Example
lat The latitude of the location (decimal format) 18.4642825
lon The longitude of the location (decimal format) 73.8058053

Example Requests

# Get sunrise and sunset times for Pune, India
curl "https://suntracker.freeapi.me/?lat=18.4642825&lon=73.8058053"
// Get sunrise and sunset times for Pune, India
fetch('https://suntracker.freeapi.me/?lat=18.4642825&lon=73.8058053')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
import requests

# Get sunrise and sunset times for Pune, India
response = requests.get('https://suntracker.freeapi.me/?lat=18.4642825&lon=73.8058053')
data = response.json()
print(data)
// Get sunrise and sunset times for Pune, India
$response = file_get_contents('https://suntracker.freeapi.me/?lat=18.4642825&lon=73.8058053');
$data = json_decode($response, true);
print_r($data);

Response Format

The API returns a JSON object containing the sunrise and sunset times for today and tomorrow.

{
  "today": {                // object | Contains today's sunrise and sunset data
    "sunrise": "6:12 AM",   // string | Time of sunrise in 12-hour format
    "sunset": "6:55 PM"     // string | Time of sunset in 12-hour format
  },
  "tomorrow": {             // object | Contains tomorrow's sunrise and sunset data
    "sunrise": "6:11 AM",   // string | Time of sunrise in 12-hour format
    "sunset": "6:55 PM"     // string | Time of sunset in 12-hour format
  }
}

Key Response Properties

  • today - Object containing sunrise and sunset times for today.
    • sunrise - The time of sunrise in 12-hour format (e.g., "6:12 AM").
    • sunset - The time of sunset in 12-hour format (e.g., "6:55 PM").
  • tomorrow - Object containing sunrise and sunset times for tomorrow.
    • sunrise - The time of sunrise in 12-hour format (e.g., "6:11 AM").
    • sunset - The time of sunset in 12-hour format (e.g., "6:55 PM").

Error Responses

The API may return the following error responses:

  • 400 Bad Request - Returned if the latitude or longitude parameters are missing or invalid.
  • 403 Forbidden - Returned if the request is made over HTTP instead of HTTPS.
  • 500 Internal Server Error - Returned if the service encounters an unexpected error or cannot calculate the times. The response body may contain more details in a JSON format: `{"error": "...", "details": "..."}`.