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"
}
}
https://suntracker.freeapi.me/
All API requests should be made to this endpoint. HTTPS is required for all API calls.
The Sunrise and Sunset Tracker API accepts GET requests only.
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 |
# 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);
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 } }
The API may return the following error responses: