You have a latitude and a longitude. You need to know what time it is there, or more precisely, which IANA time zone applies, so you can schedule a notification, label a GPS track, or show a delivery window in local time. This guide covers how to do that with the Timezone by Coordinates API on API.market: the exact request, what comes back, what goes wrong, how to cache sensibly, what it costs, and when a different tool is the better pick.
A note on what was tested, because it matters for how much you should trust the code below. Three calls were run through the API.market MCP call_api path on 2026-11-29: a Madrid lookup, a mid-Atlantic ocean point, and an out-of-range latitude. Those responses are pasted below as they came back. The curl, Python and Node.js snippets were not executed from a shell, since the environment that wrote this had no API key available outside the MCP path. They use the same URL, parameters and header as the tested calls, but treat them as documentation-based examples and run them once with your own key before you ship anything.
What the API does
You send one GET request with lat and lon. You get back one JSON object with the IANA zone name (for example Europe/Madrid), the local time at that moment, the UTC offset as both a string and a number of minutes, a short abbreviation, a daylight saving flag, and the UTC timestamp and Unix time the answer was computed for.
You can also pass an optional datetime in ISO 8601 form. That tells the API to evaluate the offset and DST state at that moment instead of "now". This is the parameter that makes the endpoint useful for more than a clock widget. If you are processing historical GPS records or planning a future event, "now" is the wrong instant.
The listing describes the lookup as running at the edge and using the public tz-lookup boundary dataset. Those are seller claims from the listing documentation. They were not independently tested, so this article does not rely on them for anything below.
Before you start: key, plan and cost
Create an account at API.market, subscribe to the listing, and generate a key. Send the key in the x-api-market-key header on every request.
The plan used for testing was pay as you go: $0 per month and $0.0005 per successful call, with a limit of 10 requests per second. There is no free plan on this listing. That is worth saying plainly because many geolocation listings do have a trial, and you may expect one here. The paid options on the listing are Pro at $4.99 per month for 25,000 calls and Ultra at $14.99 per month for 150,000 calls. Check the listing for what happens past those allowances, since overage behavior is a per-plan setting and should not be assumed.
Some quick arithmetic helps you pick:
| Monthly calls | PAYG at $0.0005 | Pro ($4.99, 25,000 calls) | Ultra ($14.99, 150,000 calls) |
|---|---|---|---|
| 1,000 | $0.50 | $4.99 | $14.99 |
| 10,000 | $5.00 | $4.99 | $14.99 |
| 25,000 | $12.50 | $4.99 | $14.99 |
| 100,000 | $50.00 | over the allowance | $14.99 |
PAYG is cheaper until you pass roughly 9,980 calls a month, where Pro starts winning. Ultra beats PAYG once you pass about 29,980 calls a month. Those break-evens assume you stay inside each plan's included volume. They also assume every call succeeds, since PAYG is billed per successful call. The three test calls cost about $0.001 in total on the PAYG subscription, which fits the per-call price (the lat=200 error is not expected to bill, but that was not separately audited).
Your first request with curl
curl -G "https://prod.api.market/api/v1/tidydata/timezone-by-coordinates/v1/timezone/by-coordinates" \
--data-urlencode "lat=40.4168" \
--data-urlencode "lon=-3.7038" \
-H "x-api-market-key: YOUR_API_KEY"
The -G flag makes curl put the --data-urlencode values into the query string instead of sending a POST body. Forgetting -G is the most common reason a curl version of a GET API appears to fail.
To ask about a specific moment, add a datetime:
curl -G "https://prod.api.market/api/v1/tidydata/timezone-by-coordinates/v1/timezone/by-coordinates" \
--data-urlencode "lat=40.4168" \
--data-urlencode "lon=-3.7038" \
--data-urlencode "datetime=2026-07-01T12:00:00Z" \
-H "x-api-market-key: YOUR_API_KEY"
A real response: Madrid in July
This is the actual response from the tested call for Madrid with datetime=2026-07-01T12:00:00Z. The same call had been captured earlier on 2026-11-21, and the two results were identical.
{
"lat": 40.4168,
"lon": -3.7038,
"timezone": "Europe/Madrid",
"localTime": "2026-07-01T14:00:00",
"utcOffset": "+02:00",
"utcOffsetMinutes": 120,
"abbreviation": "GMT+2",
"isDst": true,
"utc": "2026-07-01T12:00:00.000Z",
"unix": 1782907200
}
Read it field by field.
timezone is the identifier you should store. Europe/Madrid carries the full rule history for that region, including future and past daylight saving changes, which a bare offset cannot.
utcOffset and utcOffsetMinutes describe the offset at the evaluated instant. In July, Madrid is two hours ahead of UTC, so +02:00 and 120. The same coordinates evaluated in January would give +01:00. This is why you should not store the offset next to a coordinate as if it were permanent.
isDst tells you whether daylight saving is in effect at that instant. true here, because Madrid is on summer time in July.
abbreviation deserves a warning. It came back as GMT+2, not CEST. If you were hoping to display a familiar abbreviation to users, this field will not do it. Build the label yourself from timezone with your platform's formatting library, or display the utcOffset directly. For anything that drives logic, use timezone and utcOffset.
localTime has no offset suffix. It is the wall-clock time in that zone, so parse it as a local time and do not treat it as UTC. The utc and unix fields are the unambiguous version of the same moment.
A second real response: the open ocean
Not every coordinate is on land. This is the tested response for lat=0 and lon=-30, in the mid-Atlantic, with no datetime supplied, so it was evaluated at the time of the call.
{
"lat": 0,
"lon": -30,
"timezone": "Etc/GMT+2",
"localTime": "2026-11-29T19:30:06",
"utcOffset": "-02:00",
"utcOffsetMinutes": -120,
"abbreviation": "GMT-2",
"isDst": false,
"utc": "2026-11-29T21:30:06.181Z",
"unix": 1795987806
}
Two things to notice. First, points over international waters resolve to Etc/GMT zones, which are fixed-offset zones with no daylight saving. Second, those names use the POSIX sign convention, which is inverted from what most people expect: Etc/GMT+2 means UTC minus two hours. The response confirms this with utcOffset of -02:00. If your code ever builds an offset from the zone name instead of reading utcOffset, you will get the sign wrong. Read the offset fields.
If you track ships, flights, or any device that can be offshore, handle Etc/GMT zones deliberately. Decide whether your product should show them as is, or fall back to showing UTC.
The error you will most likely hit
A latitude outside the valid range returns HTTP 400. The tested call used lat=200:
{ "error": "lat must be a number between -90 and 90" }
The fix is to send decimal degrees with latitude between -90 and 90 and longitude between -180 and 180. The usual real-world cause is a swapped pair. Some libraries and file formats put longitude first (GeoJSON does), while most map UIs and humans say latitude first. Swap Madrid and you send lat=-3.7038&lon=40.4168. Both values are in range, so you will not get an error. You will get a zone for some other place on the map, nowhere near Spain. A swap that stays in range is a silent bug, so validate with a known city in your test suite.
Two other status codes are worth planning for, though they were not triggered in testing and come from the listing documentation. A 401 means the x-api-market-key header is missing or wrong. A 429 means you exceeded 10 requests per second on the PAYG plan.
Python example
This version checks the status before parsing, sets a finite timeout, and retries only the cases where a retry is reasonable, with a ceiling. It was not run against the live API.
import time
import requests
BASE = "https://prod.api.market/api/v1/tidydata/timezone-by-coordinates/v1/timezone/by-coordinates"
API_KEY = "YOUR_API_KEY"
def zone_for(lat, lon, at_iso=None, max_attempts=3):
params = {"lat": str(lat), "lon": str(lon)}
if at_iso:
params["datetime"] = at_iso
for attempt in range(1, max_attempts + 1):
try:
resp = requests.get(
BASE,
params=params,
headers={"x-api-market-key": API_KEY},
timeout=10,
)
except requests.Timeout:
# A timed-out GET may still have been billed. Keep the attempt count low.
if attempt == max_attempts:
raise
time.sleep(2 ** attempt)
continue
if resp.status_code == 200:
data = resp.json()
if "timezone" not in data:
raise ValueError(f"unexpected body: {data}")
return data
if resp.status_code == 429 and attempt < max_attempts:
retry_after = resp.headers.get("Retry-After", "")
# Retry-After can be a number of seconds or an HTTP date. Only trust digits.
wait = int(retry_after) if retry_after.isdigit() else 2 ** attempt
time.sleep(min(wait, 30))
continue
# 400 and 401 will not be fixed by retrying.
raise RuntimeError(f"{resp.status_code}: {resp.text[:200]}")
raise RuntimeError("gave up")
if __name__ == "__main__":
info = zone_for(40.4168, -3.7038, "2026-07-01T12:00:00Z")
print(info["timezone"], info["utcOffset"], info["isDst"])
Two design choices to point out. The Retry-After header can legally be an HTTP date instead of a number of seconds, so the code only uses it when it is all digits and otherwise falls back to a short backoff. And the wait is capped at 30 seconds so a bad header can never stall a worker for minutes.
Node.js example (18 or later)
const BASE =
"https://prod.api.market/api/v1/tidydata/timezone-by-coordinates/v1/timezone/by-coordinates";
const API_KEY = process.env.API_MARKET_KEY;
export async function zoneFor(lat, lon, atIso) {
const params = new URLSearchParams({ lat: String(lat), lon: String(lon) });
if (atIso) params.set("datetime", atIso);
const res = await fetch(`${BASE}?${params}`, {
headers: { "x-api-market-key": API_KEY },
signal: AbortSignal.timeout(10_000),
});
if (!res.ok) {
throw new Error(`${res.status} ${await res.text()}`);
}
const data = await res.json();
if (!data.timezone) throw new Error(`unexpected body: ${JSON.stringify(data)}`);
return data;
}
zoneFor(40.4168, -3.7038, "2026-07-01T12:00:00Z").then((d) =>
console.log(d.timezone, d.utcOffset, d.isDst)
);
AbortSignal.timeout gives you a finite request deadline without extra libraries. Without it, fetch can wait a very long time on a stalled connection.
Use case 1: label a GPS track in local time
Say you have a list of timestamped points from a trip and you want to show each in local time. The tempting approach is to call the API once per point. A better approach exploits the fact that a time zone covers a large area.
- Look up the first point.
- For each following point, only look it up again if it has moved more than some distance from the last point that was looked up, say 25 kilometers, or if the time since that lookup is large.
- For every point in between, reuse the zone name, but compute the offset at that point's own timestamp using your language's time zone database.
Step 3 is the important one. Reuse the timezone string, not the offset. A trip that crosses a daylight saving change mid-journey needs a different offset for points on either side of the change, even though the zone is the same. Your platform's tz database (the zoneinfo module in Python, Intl.DateTimeFormat in JavaScript) can do that conversion locally and for free once you know the zone name.
Be honest about the limit of this shortcut. A fixed 25 km threshold is a design choice and was not validated against real tracks. Near a zone border, a smaller threshold is safer. If wrong labels near borders are costly for you, tighten it and accept more calls.
Use case 2: schedule something at 9 a.m. local time
You have a user's saved location and you want to send a reminder at 9 a.m. their time. Store two things: the coordinates (or better, the zone name derived from them) and the wall-clock time the user wants. Do not store a UTC timestamp for a recurring reminder, because 9 a.m. in Madrid is 07:00 UTC in summer and 08:00 UTC in winter.
When you compute the next send, take the zone name, build the next 9:00 local datetime in that zone with your language's library, and convert to UTC for the scheduler. The API gives you the zone. The library handles the rules. If you pass the datetime parameter for a future date, you can also ask the API what the offset will be then, which is a useful cross-check but not a replacement for a tz database, because rules can change by government decision after you cache the answer.
What to cache and what not to
Caching is where most of the cost savings are, and where most of the bugs are.
Cache the zone name by a rounded coordinate key. If you round latitude and longitude to two decimals (roughly 1.1 km at the equator), many nearby lookups collapse into one cached result. Whether that is safe depends on how close to a border your users are. In the middle of a country it is fine. Within a kilometer of a boundary it can return the neighbor's zone. Pick the precision from your own tolerance, and consider skipping the cache for points the API reports in border regions if you can identify them.
Do not cache the offset or the isDst flag against a coordinate. They change twice a year in most DST regions. Cache the zone name and derive the offset from your tz database at the time you need it.
Set a time to live. Time zone boundaries and rules change occasionally, when countries move or abolish daylight saving. A cache with no expiry will serve a stale zone forever. Something like 30 days is a reasonable starting point, and that figure is a judgment call, not a measured result. Also check the listing terms about storing results before building a permanent database of responses. The listing's own terms govern what retention is allowed, and this article does not grant any right to store beyond them.
Do not promise yourself a specific saving. The real saving depends on how clustered your coordinates are. A delivery app working inside one city will hit the cache constantly. A tool processing random global points will barely hit it. Measure your hit rate for a week on real traffic before you rely on a number.
Choosing between this and the alternatives
Different tools answer different questions, and choosing the wrong one is the real way to waste money here.
You have coordinates and need the zone. This API is the direct fit. One input type, one answer.
You have an address or a city name, not coordinates. You need to geocode first. The City Geocoding API from the same publisher turns a place name into coordinates, and the reverse geocoding guide, Reverse Geocoding API: Turn Coordinates Into a City in Python and Node.js, covers the opposite direction and mentions time zone in its response. If you only need a city and its zone from coordinates, that reverse geocoding route may already give you what you need in a single call. Compare it with this endpoint on your actual data before paying for two calls.
You have an IP address, not coordinates. An IP geolocation API returns an approximate location and usually a zone in one step. API.market lists several, and their trial sizes and prices differ, so look at the current listing pages rather than relying on a number in an article. IP-based answers are only as accurate as the IP database, and VPN or mobile carrier addresses will be wrong for a meaningful share of users. If the user can give you a real location, prefer coordinates.
You only need the current time in a named zone you already know. If you already hold Europe/Madrid as a string, you do not need an API at all. Your language's standard library has the answer, offline, for free. This is the most common over-engineering mistake with time zone APIs: calling a network service to answer something your runtime already knows.
You need the abbreviation, like CEST or PST. As shown in the Madrid response, this endpoint returns GMT+2. If a human-friendly abbreviation matters to your product, generate it locally from the zone name.
A reliable pipeline for a batch of coordinates
Putting the pieces together, here is a sound design for processing a file of coordinates, such as a CSV export from a fleet tracker. It describes the structure and was not benchmarked.
- Validate first. Reject any row where latitude is outside -90 to 90 or longitude is outside -180 to 180. Log the row number. This catches swapped or corrupted values before they cost money or return nonsense.
- Deduplicate by rounded key. Round to your chosen precision and build the set of unique keys. In many datasets this alone cuts the number of lookups sharply.
- Look up unique keys with a rate limiter. The PAYG plan allows 10 requests per second. A simple token bucket or a sleep of a little over 100 milliseconds between calls keeps you under it. Do not fire unbounded parallel requests and rely on retries to sort it out, because every extra attempt on a possibly accepted request is a chance of paying twice.
- Record failures with their inputs. Write failed keys and the status code to a separate file so you can re-run only those. Do not silently drop them.
- Join results back. Map each original row to its zone through the key. Compute offsets locally per row timestamp.
- Spot check. Pick five rows in cities you know and confirm the zone by eye. A zone that looks wrong on a city you know is a signal to check for swapped coordinates.
For a one-off file of 50,000 unique points on PAYG, the arithmetic is 50,000 times $0.0005, or $25. At 10 requests per second the lookups take around 83 minutes. If you will do this often, the Pro or Ultra plans make more sense. If you will do it once, PAYG is fine and there is no monthly commitment.
Handling edge cases
Disputed or unusual regions. Boundaries in contested areas follow whatever the underlying dataset chose. If your product serves those regions, test a few points there and decide whether you need a manual override table.
Points exactly on a border. The result is deterministic for a given dataset, but there is no way to say a point on a line belongs to one side. Accept some uncertainty here.
Polar regions. Time zone assignments near the poles are conventional. Research stations often use the zone of their home country. Do not expect a meaningful answer to match local practice at a specific base.
Historical dates. The datetime parameter lets you ask about the past, but the accuracy of old offsets depends on the rule history in the underlying data. If a historical offset has legal or financial weight, such as payroll or compliance records, verify it against an authoritative source rather than trusting any single API response.
Future dates. Governments do change daylight saving rules, sometimes with short notice. A future offset is the best current answer, not a guarantee.
A short checklist before you ship
- Store the IANA zone name, not an abbreviation and not a bare offset.
- Read
utcOffsetrather than parsing the sign out of anEtc/GMTname. - Treat
localTimeas wall-clock time with no offset attached. - Validate latitude and longitude ranges before you call, and test with a known city to catch a swapped pair.
- Set a request timeout and a total retry ceiling, and keep retries low on a billed endpoint.
- Cache the zone, not the offset, and give the cache a time to live.
- Run your own copy of the curl, Python or Node.js example once with a real key, since the snippets here were not executed from a shell.
Try it
The fastest way to confirm this fits your data is to make three calls: one city you know, one point in the ocean, and one deliberately invalid latitude. That is exactly the set tested for this guide, and it costs about a tenth of a cent on the PAYG plan. Subscribe on the Timezone by Coordinates listing, send the Madrid request from the curl section, and compare your response with the one above. If you also need to start from an address or city name, add the City Geocoding API in front and chain the two calls.
Sources and what was checked
- Listing page and plan prices: https://api.market/store/tidydata/timezone-by-coordinates (PAYG $0/month and $0.0005 per call, Pro $4.99/month for 25,000 calls, Ultra $14.99/month for 150,000 calls, 10 requests per second on PAYG), read 2026-11-29 through the API.market MCP.
- Tested: three
call_apirequests on 2026-11-29 (Madrid with datetime, ocean point at lat 0 lon -30, lat 200 returning HTTP 400). Responses above are verbatim. - Not tested: curl, Python and Node.js snippets from a shell; the 401 and 429 responses; edge execution and tz-lookup dataset claims from the listing docs; border, polar and historical behavior.
- Break-even figures are arithmetic on the listed prices, not measured bills.




