Mexico Postal Codes API
144,655 postal codes for Mexico, from GeoNames. Filter the collection with country=MX and you get the same JSON shape as every other country.
Request and response
Add country filtering to the collection endpoint and you get Mexico records back. The response below is the example from our OpenAPI document, so it shows the exact shape you get, though the record itself may come from another country.
curl 'https://api.apifor.dev/v1/postal-codes' \
-G -d country=MX \
-H 'x-api-key: YOUR_API_KEY'{
"success": true,
"data": [
{
"id": 1,
"country_code": "AD",
"postal_code": "AD100",
"place_name": "Canillo",
"admin1_name": "Canillo",
"admin1_code": "02",
"admin2_name": null,
"admin2_code": null,
"admin3_name": null,
"admin3_code": null,
"lat": 42.5833,
"lng": 1.6667,
"accuracy": 6
}
]
}Fields
Each record in data has these fields. Types are read from the example values; a nullable field can hold null for some records.
| Field | Type | Example |
|---|---|---|
| id | integer | 1 |
| country_code | string | "AD" |
| postal_code | string | "AD100" |
| place_name | string | "Canillo" |
| admin1_name | string | "Canillo" |
| admin1_code | string | "02" |
| admin2_name | nullable | null |
| admin2_code | nullable | null |
| admin3_name | nullable | null |
| admin3_code | nullable | null |
| lat | number | 42.5833 |
| lng | number | 1.6667 |
| accuracy | integer | 6 |
Filters and paging
Query parameters accepted by GET /v1/postal-codes. Full detail, including the single-record route, is in the endpoint reference.
| Parameter | Type | Rules |
|---|---|---|
| page | integer | min 1 · default 1 |
| limit | integer | 1 to 200 · default 50 |
| country | string | ISO 3166-1 alpha-2 |
| q | string | 2 to 100 chars |
| postal_code | string | None |