Skip to endpoints

07/1 endpoints

Reverse geocoding API

Turn a latitude and longitude pair into the nearest Mexican postal code, with its state and municipio. This endpoint is live, but no postal code in the catalog carries coordinates yet.

No data behind this endpoint yet

Every endpoint on this page is deployed and answers requests, but the catalog behind it is not loaded, so results come back empty. The request and response shapes below are the contract and will not change when the data lands. Nothing else in the API is affected.

Base URL https://api.postalkit.mx
Authentication
GET /v1/geocode/reverse

Reverse Geocode

Find the nearest postal code to the given latitude and longitude coordinates.

Query Parameters

Param Type Description
lat number Latitude (-90 to 90)
lng number Longitude (-180 to 180)

Request

curl
curl -H "Authorization: Bearer YOUR_API_KEY" \
  "https://api.postalkit.mx/v1/geocode/reverse?lat=19.4233&lng=-99.1637"

Response

200 Success
{
  "data": {
    "id": 384,
    "code": "06600",
    "state": { "id": 1, "name": "Ciudad de México", "code": "09" },
    "municipality": { "id": 6, "name": "Cuauhtémoc", "code": "015" },
    "city": null,
    "settlements": [],
    "latitude": "19.4233000",
    "longitude": "-99.1637000"
  }
}
404 No Results
{ "message": "No geocoded postal codes found near the given coordinates." }
422 Validation Error
{ "message": "The given data was invalid.", "errors": { "lat": ["The lat field is required."], "lng": ["The lng field is required."] } }

Ready to build?

Start querying the full postal catalog in minutes.

curl -s https://api.postalkit.mx/v1/postal-codes/06600 -H "Authorization: Bearer YOUR_API_KEY"