Timezone API
The Timezone API provides timezone and time offset data for any latitude/longitude coordinates or city in the world.
From 7,662 users
Applications using this API
API Status
API Response Times
Average | P50 | P75 | P90 | P95 |
|---|---|---|---|---|
| 172ms | 221ms | 232ms | 450ms | 844ms |
Similar APIs
Didn't find what you were looking for? Suggest an improvement
/v1/timezone GET
https://api.api-ninjas.com/v1/timezone
Get timezone info by city/state/country or location coordinates (latitude/longitude). Returns the timezone name of the specified input location and the time offset in seconds.
Parameters
Note: at least one of the following must be provided: timezone, lat and lon, or city.
timezoneoptionalTimezone name.
latoptional premiumLatitude of desired location.
lonoptional premiumLongitude of desired location.
cityoptional premiumCity name.
stateoptional premiumUS state (for United States cities only).
countryoptional premiumCountry name.
Headers
X-Api-KeyrequiredAPI Key associated with your account.
Response
A JSON object with the following fields or an error if the request is unsuccessful.
timezoneTimezone name.
utc_offsetTime offset in seconds from GMT.
local_timeLocal time in the specified timezone.
cityCity name. Only available for lat/lon or city/state/country inputs.
Sample Request Live Demo!
https://api.api-ninjas.com/v1/timezone?timezone=Europe%2FLondonHeaders
X-Api-KeyLog in or sign up to get your API KeySample Response
Code Examples
1
2
curl -X GET "https://api.api-ninjas.com/v1/timezone?city=London" \
-H "X-Api-Key: YOUR_API_KEY"If your programming language is not listed in the Code Example above, you can still make API calls by using a HTTP request library written in your programming language and following the above documentation.
Frequently Asked Questions
Can I use the Timezone API for commercial purposes?
Yes, but you must have a premium subscription. Commercial use of the Timezone API is not permitted on the free tier. See our pricing page to choose a plan that fits your needs.How do I get an API key and start using the Timezone API?
Sign up for a free account to instantly get your API key, then pass it in theX-Api-Keyheader on every request. The documentation above includes ready-to-run examples in cURL, Python, JavaScript, Node.js, and more.What happens if I exceed my quota for the month?
Your API requests will simply be denied once you hit your monthly quota — you will never be charged more than the plan you signed up for. To increase your quota, you can upgrade your plan any time on our pricing page.What happens if a request to the Timezone API fails?
The API responds with a standard HTTP status code and a JSON error message describing the problem. See our error codes reference for the full list of codes and how to resolve each one, or contact support if you need help.How do I look up a timezone by city or by coordinates?
Send a GET request to/v1/timezonewith at least one of the following: atimezonename, acity(optionally narrowed withstatefor US cities andcountry), or alatandloncoordinate pair. If you need to resolve a place name or coordinates first, pair it with the Geocoding API or City API.What does the Timezone API response include?
Each response is a JSON object containing thetimezonename, theutc_offset(the time offset in seconds from GMT), and thelocal_timein that timezone, plus acityfield when you query bylat/lonor city/state/country. See the error codes page for responses to unsuccessful requests.What are some use cases for the Timezone API?
It is ideal for scheduling apps, displaying local times for users in different regions, and converting between zones for global teams. For just the current time in a named zone you can also use the World Time API, and browse other location data tools under our APIs.Are the latitude, longitude, and city lookups free?