AstrologyAPI

Timezone with DST

POSThttps://json.astrologyapi.com/v1/timezone_with_dst
Copy

Returns the timezone offset (including DST) for a specific latitude and longitude  (based on country/timezone ID from geo_details) on a given date.

POST/timezone_with_dst
Copy
1import requests
2import json
3
4# Your API key
5api_key = "<YOUR_API_KEY>"
6
7# API endpoint URL
8api_url = "https://json.astrologyapi.com/v1/timezone_with_dst"
9
10# Request data
11data = {
12        "latitude": 25.7464,
13        "longitude": 82.6837,
14        "date": "06-27-2000"
15    }
16
17headers = {
18    'x-astrologyapi-key': api_key,
19    'Content-Type': 'application/json'
20    # Add 'Accept-Language': '<language_code>' if needed
21}
22
23try:
24    response = requests.post(api_url, headers=headers, json=data)
25    response.raise_for_status()  # Raise an exception for bad status codes (4xx or 5xx)
26
27    # Process the response
28    response_data = response.json()
29    print(json.dumps(response_data, indent=4))
30
31except requests.exceptions.RequestException as e:
32    print(f"Error making API request: {e}")
33    if hasattr(e, 'response') and e.response is not None:
34        try:
35            print(f"Error response: {e.response.json()}")
36        except json.JSONDecodeError:
37             print(f"Error response (non-JSON): {e.response.text}")
38
39
200Response
Copy
1{
2  "status": true,
3  "timezone": 5.5,
4  "timezone_in_ms": 19800000,
5  "date": "1992-12-01T00:00:00.000Z"
6}

Request Headers

Authorization

string

required

Basic Authorization via header

Accept-Language

string

Preferred language for the response content

Properties

English - en

Request Parameters

latitude

float

required

latitude , eg: 19.23232

longitude

float

required

longitude, eg: 72.23234

date

string

date, eg: '12-5-1993' // 'mm-dd-yyyy'

Errors

400
Bad Request

Something is wrong with your request format or parameters.

401
Unauthorized

Your API key is missing or invalid.

403
Forbidden

You don't have permission to access this specific resource.

404
Not Found

The API endpoint you're trying to reach doesn't exist.

500
Internal Server Error

Our server is having a temporary glitch.