Postal Code

Look up city, state, and geographic coordinates for any postal code worldwide. Covers 100+ countries using the GeoNames postal code dataset.

Get API Key

Vue d'ensemble

Cas d'utilisation

  • Auto-fill city and state fields from a zip/postal code
  • Validate postal codes during checkout or registration
  • Geocode postal codes to display on a map
  • Calculate distances between postal code areas

Fonctionnalités

100+ countries supported (US, CA, GB, DE, AU, and more)
Returns city, state/province, country, latitude, and longitude
Default country: US (omit the country param for US lookups)
ISO 3166-1 alpha-2 country codes

Points de terminaison de l'API

Lookup Postal Code

Returns city, state, country, and coordinates for the given postal code.

GET
https://requiems.xyz/v1/places/postal/{code}

Paramètres

Nom Type Requis Description
code string Requis The postal code to look up (e.g. 10001 for New York, SW1A 1AA for London)
country string Facultatif ISO 3166-1 alpha-2 country code (default: US)

Essayez-le

Démo en direct
Requête

The postal code to look up (e.g. 10001 for New York, SW1A 1AA for London)

ISO 3166-1 alpha-2 country code (default: US)

Champs de réponse

Champ Type Description
postal_code string The postal code as stored in the dataset
city string Primary city or place name for the postal code
state string State, province, or administrative region name
country string ISO 3166-1 alpha-2 country code (uppercase)
lat number Latitude of the postal code centroid
lon number Longitude of the postal code centroid

Exemples de code

# US zip code (default country)
curl "https://requiems.xyz/v1/places/postal/10001" \
  -H "requiems-api-key: YOUR_API_KEY"

# UK postcode
curl "https://requiems.xyz/v1/places/postal/SW1A1AA?country=GB" \
  -H "requiems-api-key: YOUR_API_KEY"

Réponses d'erreur

not_found

The postal code was not found for the given country.

internal_error

Unexpected server error.

Batch Lookup Postal Codes

Look up city, state, and coordinates for up to 50 postal codes in a single request. Results are returned in input order.

POST
https://requiems.xyz/v1/places/postal/batch

Paramètres

Nom Type Requis Description
items array<object> Requis List of postal code lookups (1–50 items).
items[].code string Requis The postal code to look up.
items[].country string Facultatif ISO 3166-1 alpha-2 country code (default: US).

Essayez-le

Démo en direct
Requête

List of postal code lookups (1–50 items).

The postal code to look up.

ISO 3166-1 alpha-2 country code (default: US).

Champs de réponse

Champ Type Description
results array<object> Per-item results in input order.
results[].code string The postal code as provided in the request.
results[].country string The country code used for the lookup (defaulted to US when omitted).
results[].found boolean Whether the postal code was found in the dataset.
results[].result object Postal code details (omitted when found is false).
total integer Total number of items processed.

Exemples de code

curl -X POST https://requiems.xyz/v1/places/postal/batch \
  -H "requiems-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"items": [{"code": "10001", "country": "US"}, {"code": "SW1A1AA", "country": "GB"}]}'

Réponses d'erreur

validation_failed

The items array is missing, empty, or exceeds 50 items.

bad_request

The request body is missing or malformed.

Foire aux questions