Time zones
GET /v1/timezone answers two things about a point: which time zone it is in, and what that zone's offset from UTC is at a given moment. The first comes from zone boundary polygons, the second from the tz database. Both are needed, because a zone's name does not change often and its offset changes twice a year in much of the world.
curl -G "https://api.oslew.com/v1/timezone" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'at=19.4326,-99.1332' \
--data-urlencode 'timestamp=1790175600'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.timezone("19.4326,-99.1332", timestamp=1790175600)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.timezone("19.4326,-99.1332", { timestamp: 1790175600 });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 291
ratelimit-reset: 1
{
"at": [
19.4326,
-99.1332
],
"timestamp": 1790175600,
"tzid": "America/Mexico_City",
"utc_offset_s": -21600,
"raw_offset_s": -21600,
"dst_offset_s": 0,
"abbreviation": "CST",
"via": "interior",
"provenance": {
"name": "timezone-boundary-builder",
"release": "2026d",
"license": "ODbL-1.0"
},
"took_us": 144
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
Parameters
| Parameter | Default | What it does |
|---|---|---|
at | required | lat,lon, latitude first. |
timestamp | now | The moment the offsets are for, in unix seconds (UTC). Any instant, past or future; negative values are before 1970. |
What comes back
| Field | Is |
|---|---|
tzid | The IANA zone identifier, America/Mexico_City. The thing to store. |
utc_offset_s | Seconds to add to UTC to get local time at timestamp: raw_offset_s + dst_offset_s. Negative west of Greenwich. |
raw_offset_s | The zone's standard offset, without daylight saving. |
dst_offset_s | The daylight-saving shift in force at timestamp; 0 when none is. |
abbreviation | The abbreviation in force, CST, PDT. For display only: abbreviations are not unique — CST names more than one zone — so never parse one back into a zone. |
via | interior when the point's cell lies wholly inside the zone polygon, so no geometry was read; boundary when the cell straddles a zone edge and the polygon itself decided. |
timestamp, at | What the answer is for, echoed: the moment (now, if you sent none) and the point. |
provenance | The zone polygons' source, release and licence code. |
In the answer above, the Zócalo at 15:00 UTC on 23 September 2026 is in America/Mexico_City, six hours behind UTC (-21600), with no daylight saving in force: local time is 09:00 CST.
Daylight saving, split out
Where daylight saving is in force, the offset is the sum of two parts, and the answer gives all three numbers:
curl -G "https://api.oslew.com/v1/timezone" \
-H "Authorization: Bearer $GEO_API_KEY" \
--data-urlencode 'at=37.7929,-122.3971' \
--data-urlencode 'timestamp=1787756400'from oslew import Client
# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")
answer = client.timezone("37.7929,-122.3971", timestamp=1787756400)import { Client } from "@oslew/client";
// The key is read from GEO_API_KEY.
const client = new Client({ baseUrl: "https://api.oslew.com" });
const answer = await client.timezone("37.7929,-122.3971", { timestamp: 1787756400 });HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 290
ratelimit-reset: 1
{
"at": [
37.7929,
-122.3971
],
"timestamp": 1787756400,
"tzid": "America/Los_Angeles",
"utc_offset_s": -25200,
"raw_offset_s": -28800,
"dst_offset_s": 3600,
"abbreviation": "PDT",
"via": "interior",
"provenance": {
"name": "timezone-boundary-builder",
"release": "2026d",
"license": "ODbL-1.0"
},
"took_us": 7482
}A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.
San Francisco's standard offset is eight hours behind UTC (raw_offset_s: -28800). On 26 August 2026 an hour of daylight saving is in force (dst_offset_s: 3600), so the offset that applies is seven hours (utc_offset_s: -25200), and 15:00 UTC is 08:00 PDT. utc_offset_s is the one to do arithmetic with; the other two say why it is what it is.
Why the moment matters
An offset is true of an instant, not of a place. It changes twice a year where clocks go forward and back, and it changes when governments change the rules — Mexico ended daylight saving in most of the country in 2022, so the same point in Mexico City had a different September offset before then. The tz database keeps that history, and the answer is computed for the timestamp you send.
- For an event, send the event's time. A delivery slot next month, a meeting across a DST change, a log line from last year: ask for that instant, not for now. The default is now, which is right only for "what time is it there".
- Cache the zone, not the offset. A point's
tzidis stable; its offset is not. Storetzidper location and derive offsets for each instant — from this route, or from your platform's own tz database. - Many instants, one place: one request for the
tzid, then your language's tz support for each instant, rather than a request per instant. Your runtime's tz database may be older or newer than the service's; for a zone whose rules changed recently, check they agree.
A UTC instant to local time
utc_offset_s converts the one instant it was asked about. Adding it to a unix time and reading the result as if it were UTC gives the local wall-clock time; for any other instant, ask again or use thetzid.
from datetime import datetime, timedelta, timezone
from zoneinfo import ZoneInfo
from oslew import Client
client = Client(base_url="https://api.oslew.com")
when = 1787756400 # 2026-08-26 15:00 UTC
tz = client.timezone("37.7929,-122.3971", timestamp=when)
if tz["tzid"] is None:
raise LookupError("no time zone holds this point")
# The offset the service computed for that instant:
offset = timezone(timedelta(seconds=tz["utc_offset_s"]), tz["abbreviation"])
local = datetime.fromtimestamp(when, offset)
print(local.isoformat(), local.tzname()) # 2026-08-26T08:00:00-07:00 PDT
# Or, for other instants at the same place, the zone and your own tz database:
later = datetime.fromtimestamp(when + 90 * 86400, ZoneInfo(tz["tzid"]))import { Client } from "@oslew/client";
const client = new Client({ baseUrl: "https://api.oslew.com" });
const when = 1787756400; // 2026-08-26 15:00 UTC
const tz = await client.timezone("37.7929,-122.3971", { timestamp: when });
if (tz.tzid === null || tz.utc_offset_s === null) {
throw new Error("no time zone holds this point");
}
// Shift by the offset, then read the fields as UTC: that is local wall-clock time.
const wall = new Date((when + tz.utc_offset_s) * 1000);
console.log(wall.toISOString().slice(0, 19), tz.abbreviation); // 2026-08-26T08:00:00 PDT
// Or, for other instants at the same place, the zone and the runtime's tz database:
const later = new Intl.DateTimeFormat("en-GB", {
timeZone: tz.tzid,
dateStyle: "medium",
timeStyle: "short",
}).format(new Date((when + 90 * 86400) * 1000));A Date in JavaScript is always an instant; the shifted one above only prints the right wall-clock fields through its UTC accessors. Do not pass it back anywhere that expects a real instant.
Where there is no zone
Zone polygons cover land and territorial waters. A point outside every polygon — the open ocean — is answered200 with tzid, every offset, abbreviation, via andprovenance all null, rather than a nominal offset the data does not hold. So is every point on a deployment with no time zone layer loaded. Branch on tzid being null, not on an error.
Where it comes from, and on what terms
The zone at a point is decided by the polygons of timezone-boundary-builder — the planet's 419 zones, built from OpenStreetMap — and the offsets come from the tz database compiled into the service. The polygons are licensed ODbL-1.0, which is attribution and share-alike: that matters if you build a database of zone answers and distribute it. provenance.license says so on every answer, anddata and licensing says what it asks of you.
Because the two halves come from different places, a zone the polygons name but the compiled tz database does not know is refused with 400, unknown time zone …, rather than answered with a made-up offset.
The zone elsewhere in the API
- Reverse geocoding lists the zone in its
adminchain, as an entry of subtypetimezonewhose name is thetzid— no offsets. - Everything at a point returns the
tzidalongside every other layer. - Nearby places uses the point's zone to decide which places are open at an
open_attime, and refusesopen_atwhere no zone holds the point.
Errors
- A missing
at, or atimestampthat is not an integer, is refused by the framework as plain text. See errors. 400,near must be lat,lonornear is out of range—atis not two numbers, or is off the globe. The message saysnearwhatever the parameter was called.400,timestamp out of range— an instant too far from the present for a calendar to represent.400,unknown time zone …— above.