World Time API Documentation
Introduction
Endpoints
The get_world_time endpoint delivers the location’s time, date, and timezone when it receives a location in the form of an IP address, location name, or latitude and longitude.
Endpoint | URL | Method |
GET World Time | /v1/worldtime/ | GET |
Base URL
https://world-time-by-based-api.p.rapidapi.com/v1/worldtime/
Validation Endpoint
https://world-time-by-based-api.p.rapidapi.com/v1/worldtime/?location=Brisbane
Headers
X-RapidAPI-Key
Your RapidAPI account key. The same key can be used across all of our APIs. You can create or find your existing Key here.
X-RapidAPI-Host
This is RapidAPIs base URL for the api:
world-time-by-based-api.p.rapidapi.com
Request Parameters
location
This parameter accepts a string. For example you could use city, or country, IP or lat/long coordinates. Here are some examples:
location | example |
city | New York |
city + state | New York, NY |
country | United States |
IP | 45.88.222.41 |
Lat / Long | 40.720230, -73.998630 |
Example Request
Python:
import http.client conn = http.client.HTTPSConnection("world-time-by-based-api.p.rapidapi.com") headers = { 'x-rapidapi-key': "YOUR_RAPID_API_KEY", 'x-rapidapi-host': "world-time-by-based-api.p.rapidapi.com" } conn.request("GET", "/v1/worldtime/?location=New%20York", headers=headers) res = conn.getresponse() data = res.read() print(data.decode("utf-8"))
Example Response
{ "datetime":"2024-07-22 07:45:43", "timezone_name":"Eastern Daylight Time", "timezone_location":"America/New_York", "timezone_abbreviation":"EDT", "gmt_offset":-4,"is_dst":true, "requested_location":"New York", "latitude":40.7127281, "longitude":-74.0060152 }