Places for a postal code in ~120 countries (full codes for the UK, Canada and the Netherlands): place name, region and code, county and code, district, coordinates and accuracy. A longer code than the data holds (ZIP+4, a full code where only outward codes exist) returns its parent (match: parent); a partial code returns codes starting with it (match: prefix). Data: GeoNames (CC BY 4.0).
Every response includes credits_used: the credits this call cost.
Parameters
name
type
description
coderequired
string
Postal code, any spacing or case: 90210, SW1A 1AA, 75008. Example: 90210
country
string
ISO country code or English name (default US). See /geo/v1/postal-code-countries. Example: US
import os, requests
res = requests.get(
"https://api.api.sh/geo/v1/postal-code",
params={"code": "90210"},
headers={"x-api-key": os.environ["APISH_KEY"]},
timeout=120,
)
res.raise_for_status()
data = res.json()
const url = new URL("https://api.api.sh/geo/v1/postal-code");
url.searchParams.set("code", "90210");
const res = await fetch(url, { headers: { "x-api-key": process.env.APISH_KEY } });
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const data = await res.json();
Response
A JSON object with the fields described above, plus raw (the source's own data), cached, fetched_at and credits_used. Errors return {"success": false, "error": "…"} with the HTTP status (see errors). A lookup that ran but found nothing (404) costs the price above; refused calls and errors on our side are free (what's charged).
The fastest way to see the full response is the playground: it runs this endpoint with your account and shows the exact JSON.