/v1/localities
Search Localities
Search for localities within a state and municipality. Supports two filter modes: by name (state + municipality) with fuzzy matching, or by INEGI code (state_code + municipality_code) with exact matching. Returns paginated results ordered by name.
Query Parameters
| Param | Type | Description |
|---|---|---|
| state | string | State name (fuzzy match). Required if not using codes. |
| municipality | string | Municipality name (fuzzy match). Required if not using codes. |
| state_code | string | INEGI state code. Required if not using names. |
| municipality_code | string | INEGI municipality code. Required if not using names. |
| page | integer | Page number (20 results per page, default 1) |
Request
curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://api.postalkit.mx/v1/localities?state=Jalisco&municipality=Guadalajara"
Response
{
"data": [
{
"id": 1,
"locality_code": "0001",
"name": "Guadalajara",
"ambito": "Urbano",
"latitude": "20.6737800",
"longitude": "-103.3442300",
"altitude": "1566",
"state": { "id": 14, "name": "Jalisco", "code": "14" },
"municipality": { "id": 39, "name": "Guadalajara", "code": "039" }
}
],
"links": { "first": "...", "last": "...", "prev": null, "next": null },
"meta": { "current_page": 1, "total": 1, "per_page": 20 }
}
{ "message": "The given data was invalid.", "errors": { "filter": ["You must provide either (state and municipality) or (state_code and municipality_code)."] } }