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

Descripción general

Casos de uso

  • 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

Funcionalidades

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

Puntos finales de la API

Lookup Postal Code

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

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

Parámetros

Nombre Tipo Obligatorio Descripción
code string Obligatorio The postal code to look up (e.g. 10001 for New York, SW1A 1AA for London)
country string Opcional ISO 3166-1 alpha-2 country code (default: US)

Pruébalo

Demostración en vivo
Solicitud

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)

Campos de respuesta

Campo Tipo Descripción
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

Ejemplos de código

# 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"

Respuestas de error

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

Parámetros

Nombre Tipo Obligatorio Descripción
items array<object> Obligatorio List of postal code lookups (1–50 items).
items[].code string Obligatorio The postal code to look up.
items[].country string Opcional ISO 3166-1 alpha-2 country code (default: US).

Pruébalo

Demostración en vivo
Solicitud

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

The postal code to look up.

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

Campos de respuesta

Campo Tipo Descripción
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.

Ejemplos de código

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"}]}'

Respuestas de error

validation_failed

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

bad_request

The request body is missing or malformed.

Preguntas frecuentes