Sepomex is a REST API build in elixir that maps all the data from the current zip codes in Mexico. You can get the CSV or Excel files from the official site
We build this API in order to provide a way to developers query the zip codes, states and municipalities across the country.
The base URI to start consuming the JSON response is under:
http://localhost:4000/api/v1/zip_codesThere are currently 146,934 records on the database which were extracted from the CSV file included in the project.
Records are paginated with 50 records per page.
mix deps.getconfig :sepomex, Sepomex.Repo,
username: "USERNAME",
password: "PASSWORD",
database: "sepomex_dev",
hostname: "localhost",
...mix ecto.setupmix phx.serverWe currently provide 1 kind of resources:
- Zip Codes: http://localhost:4000/zip_codes
In order to provide more flexibility to search a zip code, whether is by city, colony, state or zip code you can now send multiple parameters to make the appropiate search. You can fetch the:
curl -X GET http://localhost:4000/api/v1/zip_codes {
"zip_codes": [
{
"id": 1,
"d_codigo": "01000",
"d_asenta": "San Ángel",
"d_tipo_asenta": "Colonia",
"d_mnpio": "Álvaro Obregón",
"d_estado": "Ciudad de México",
"d_ciudad": "Ciudad de México",
"d_cp": "01001",
"c_estado": "09",
"c_oficina": "01001",
"c_cp": null,
"c_tipo_asenta": "09",
"c_mnpio": "010",
"id_asenta_cpcons": "0001",
"d_zona": "Urbano",
"c_cve_ciudad": "01"
},
...
],
"meta": {
"pagination": {
"per_page": 15,
"total_pages": 9728,
"total_objects": 145906,
"links": {
"first": "/zip_code?page=1",
"last": "/zip_code?page=9728",
"next": "/zip_code?page=2"
}
}
}
}curl -X GET http://localhost:4000/api/v1/zip_codes?city=monterreycurl -X GET http://localhost:4000/api/v1/zip_codes?state=nuevo%20leoncurl -X GET http://localhost:4000/api/v1/zip_codes?colony=punta%20contrycurl -X GET http://localhost:4000/api/v1/zip_codes?zip_code=67173Where:
per_pageis the amount of elements per page.total_pagesis the total number of pages.total_objectsis the total objects of all pages.linkscontains links for pages.firstis the url for the first page.lastis the url for the last page.previs the url for the previous page.nextis the url for the next page.