oslew docs
Console
Menu

GeocodingaddressoperationId postcode

GET/v1/postcode

A postcode: the centroid of its addresses, their extent, how many there are, and the administrative chain it sits in.

The position is the mean of the code's own address points, not a published centroid, so it is where the addresses actually are; precision_m is half the diagonal of what they cover, which for a rural code is kilometres. Without country, a code that two countries share comes back twice rather than being guessed at. admin is filled from the divisions layer, which is where the locality comes from for a country whose address rows carry none — Mexico's do not.

Send Authorization: Bearer sk_live_…. The key's plan must include theaddress product; which plans do.

Explained in Postcodes.

Example

One postcode, narrowed to a country.

curl
curl -G "https://api.oslew.com/v1/postcode" \
  -H "Authorization: Bearer $GEO_API_KEY" \
  --data-urlencode 'code=03940' \
  --data-urlencode 'country=MX'
Python
from oslew import Client

# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")

answer = client.postcode("03940", country="MX")
TypeScript
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.postcode("03940", { country: "MX" });
Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 298
ratelimit-reset: 1

{
  "query": "03940",
  "results": [
    {
      "code": "03940",
      "country": "MX",
      "lat": 19.365164,
      "lon": -99.180155,
      "bbox": [
        19.362674,
        19.367267,
        -99.182424,
        -99.178061
      ],
      "addresses": 271,
      "locality": null,
      "region": "Ciudad de México",
      "precision_m": 342.89968972092777,
      "precision": "postcode",
      "admin": [
        {
          "doc": 2174,
          "id": "7f1f3634-1218-43e7-9538-ac3d1f43fc1c",
          "name": "México",
          "subtype": "country",
          "country": "MX",
          "region": null,
          "admin_level": null,
          "via": "interior",
          "provenance": {
            "name": "overture-divisions",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 61,
          "id": "0831989a-c65b-47db-802e-f930af64b9e4",
          "name": "México",
          "subtype": "country",
          "country": "MX",
          "region": null,
          "admin_level": null,
          "via": "interior",
          "provenance": {
            "name": "overture-divisions-maritime",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 1560,
          "id": "bc8dbc34-544b-47c4-bdb1-d3f5ecfc6af7",
          "name": "Ciudad de México",
          "subtype": "region",
          "country": "MX",
          "region": "MX-CMX",
          "admin_level": 1,
          "via": "boundary",
          "provenance": {
            "name": "overture-divisions",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 1621,
          "id": "57c3f700-1244-4858-b97d-0980a217b02e",
          "name": "Benito Juárez",
          "subtype": "county",
          "country": "MX",
          "region": "MX-CMX",
          "admin_level": 2,
          "via": "boundary",
          "provenance": {
            "name": "overture-divisions",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 1522,
          "id": "2b1d49e2-98ef-4665-b9f6-1ce96c9f015b",
          "name": "Ciudad de México",
          "subtype": "locality",
          "country": "MX",
          "region": "MX-CMX",
          "admin_level": null,
          "via": "boundary",
          "provenance": {
            "name": "overture-divisions",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 147,
          "id": "America/Mexico_City",
          "name": "America/Mexico_City",
          "subtype": "timezone",
          "country": null,
          "region": null,
          "admin_level": null,
          "via": "interior",
          "provenance": {
            "name": "timezone-boundary-builder",
            "release": "2026d",
            "license": "ODbL-1.0"
          }
        }
      ]
    }
  ],
  "layers": 1,
  "provenance": {
    "name": "overture-addresses",
    "release": "postcodes",
    "license": "CDLA-Permissive-2.0"
  },
  "took_us": 468
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

Query

NameTypeDescription
code
queryrequired
string
Any spelling: 03940, SW1A 1AA, sw1a1aa.
country
query
string
ISO code, to narrow a shared code.
prefix
query
boolean
Treat code as a prefix: the codes that begin with it.
limit
query
integer
≤ 50
default 10

Responses

200 — Matches, or none.

  • layersintegerrequired
  • querystringrequired
  • resultsobject[]required
    • addressesintegerrequired
      How many addresses the centroid is the mean of.
    • adminHit[]required
      • docintegerrequired
        Ordinal in the segment.
      • idstringrequired
        Overture id.
      • namestringrequired
      • provenanceSourcerequired
        • licensestringrequired
        • namestringrequired
        • releasestringrequired
      • subtypestringrequired
        country | dependency | region | county | localadmin | locality | macrohood | neighborhood | microhood | timezone
      • viastringrequired
        interior: the point's cell is provably inside, no geometry read; boundary: the polygon decided.
        interior | boundary
      • admin_levelinteger | null
      • countrystring | null
        ISO code.
      • regionstring | null
        ISO region code, MX-JAL.
    • bboxnumber[]required4 items
      lat_lo, lat_hi, lng_lo, lng_hi of the addresses behind the code.
    • codestringrequired
      As the source spells it.
    • countrystringrequired
    • latnumberrequired
    • lonnumberrequired
    • precisionPrecisionrequired
      What the position locates, finest first. rooftop is an address point with a house number, as its source recorded it — never a building footprint we snapped to, which would contaminate the permissive bundle. interpolated is a point placed between the two recorded numbers that bracket the one asked for, which is what Google calls RANGE_INTERPOLATED. street is an address row with no number to place along it. precision_m carries the honest radius alongside: the label says what was matched, the metres say how wrong it can be.
      rooftop | interpolated | address | street | postcode | locality | region | country | poi
    • precision_mnumberrequired
      Half the diagonal of the bounding box.
    • localitystring | null
    • regionstring | null
  • took_usintegerrequired
  • provenanceSource
    • licensestringrequired
    • namestringrequired
    • releasestringrequired

With RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset(and their X-RateLimit-* aliases); see rate limits.

Refusals

Every refusal is a JSON object with an error string, except where noted.

400No code, or no postcode layer loaded.
401No key, or one that is unknown, revoked or suspended.
403The key's plan does not include this route's product, or the request is larger than the plan allows. The body names the plan that does.
429This product's bucket is empty: the key is going faster than its plan's sustained rate. Wait Retry-After seconds; nothing is used up. Carries Retry-After.
503The pod cannot reach the control plane and its entitlements are too old to trust. Retry.

A malformed query string or JSON body is refused by the framework before this route runs, in plain text rather than JSON; see errors.

More examples

Every code that begins with a prefix
curl
curl -G "https://api.oslew.com/v1/postcode" \
  -H "Authorization: Bearer $GEO_API_KEY" \
  --data-urlencode 'code=0394' \
  --data-urlencode 'country=MX' \
  --data-urlencode 'prefix=true' \
  --data-urlencode 'limit=3'
Python
from oslew import Client

# The key is read from GEO_API_KEY.
client = Client(base_url="https://api.oslew.com")

answer = client.postcode("0394", country="MX", prefix=True, limit=3)
TypeScript
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.postcode("0394", { country: "MX", prefix: true, limit: 3 });
Response
HTTP/1.1 200 OK
content-type: application/json
ratelimit-limit: 100
ratelimit-remaining: 297
ratelimit-reset: 1

{
  "query": "0394",
  "results": [
    {
      "code": "03940",
      "country": "MX",
      "lat": 19.365164,
      "lon": -99.180155,
      "bbox": [
        19.362674,
        19.367267,
        -99.182424,
        -99.178061
      ],
      "addresses": 271,
      "locality": null,
      "region": "Ciudad de México",
      "precision_m": 342.89968972092777,
      "precision": "postcode",
      "admin": [
        {
          "doc": 2174,
          "id": "7f1f3634-1218-43e7-9538-ac3d1f43fc1c",
          "name": "México",
          "subtype": "country",
          "country": "MX",
          "region": null,
          "admin_level": null,
          "via": "interior",
          "provenance": {
            "name": "overture-divisions",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 61,
          "id": "0831989a-c65b-47db-802e-f930af64b9e4",
          "name": "México",
          "subtype": "country",
          "country": "MX",
          "region": null,
          "admin_level": null,
          "via": "interior",
          "provenance": {
            "name": "overture-divisions-maritime",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 1560,
          "id": "bc8dbc34-544b-47c4-bdb1-d3f5ecfc6af7",
          "name": "Ciudad de México",
          "subtype": "region",
          "country": "MX",
          "region": "MX-CMX",
          "admin_level": 1,
          "via": "boundary",
          "provenance": {
            "name": "overture-divisions",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 1621,
          "id": "57c3f700-1244-4858-b97d-0980a217b02e",
          "name": "Benito Juárez",
          "subtype": "county",
          "country": "MX",
          "region": "MX-CMX",
          "admin_level": 2,
          "via": "boundary",
          "provenance": {
            "name": "overture-divisions",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 1522,
          "id": "2b1d49e2-98ef-4665-b9f6-1ce96c9f015b",
          "name": "Ciudad de México",
          "subtype": "locality",
          "country": "MX",
          "region": "MX-CMX",
          "admin_level": null,
          "via": "boundary",
          "provenance": {
            "name": "overture-divisions",
            "release": "2026-08-19.0",
            "license": "ODbL-1.0"
          }
        },
        {
          "doc": 147,
          "id": "America/Mexico_City",
          "name": "America/Mexico_City",
          "subtype": "timezone",
          "country": null,
          "region": null,
          "admin_level": null,
          "via": "interior",
          "provenance": {
            "name": "timezone-boundary-builder",
            "release": "2026d",
            "license": "ODbL-1.0"
          }
        }
      ]
    }
  ],
  "layers": 1,
  "provenance": {
    "name": "overture-addresses",
    "release": "postcodes",
    "license": "CDLA-Permissive-2.0"
  },
  "took_us": 96
}

A real response, captured from the service at commit b8f4bde-dirty. Timing fields such as took_us differ on every call.

Rendered from the OpenAPI document at commit b8f4bde-dirty; the same document is served at/v1/openapi.json and generates both clients.