Sepomex is a REST API 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:
https://sepomex-api.herokuapp.com/api/v1/
There are currently 145,481
records on the database which were extracted from the CSV file included in the project.
Records are paginated with 50 records per page.
- Install the
foreman
gem with:
% gem install foreman
To run the api locally you can follow the next steps:
- First clone the project
git clone https://github.com/IcaliaLabs/sepomex.git
- Run the
bin/setup
script - Lift the server
foreman start
Or by hand
- First clone the project
git clone https://github.com/IcaliaLabs/sepomex.git
- Under the
sepomex
directory run thebundle install
command to download all the dependencies - Set up the
database.yml
to meet your requirements and create it - Migrate the database,
rake db:migrate
- We have provided a rake task to migrate the CSV data:
rake db:migrate:zip_codes
- Lift the server
foreman start
We currently provide 4 kind of resources:
- Zip Codes: https://sepomex-api.herokuapp.com/api/v1/zip_codes
- States: https://sepomex-api.herokuapp.com/api/v1/states
- Municipalities: https://sepomex-api.herokuapp.com/api/v1/municipalities
- Cities: https://sepomex-api.herokuapp.com/api/v1/cities
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 https://sepomex-api.herokuapp.com/api/v1/zip_codes -d city=monterrey
curl -X GET https://sepomex-api.herokuapp.com/api/v1/zip_codes -d state=nuevo%20leon
curl -X GET https://sepomex-api.herokuapp.com/api/v1/zip_codes -d colony=punta%20contry
curl -X GET https://sepomex-api.herokuapp.com/api/v1/zip_codes -d zip_code=67173
curl -X GET https://sepomex-api.herokuapp.com/api/v1/zip_codes \
-d colony=punta%20contry \
-d state=nuevo%20leon \
-d city=guadalupe
Note: A link for the json attributes description is provided here
The states
resources can be fetch through several means:
curl -X GET https://sepomex-api.herokuapp.com/api/v1/states
curl -X GET https://sepomex-api.herokuapp.com/api/v1/states/1
curl -X GET https://sepomex-api.herokuapp.com/api/v1/states/1/municipalities
curl -X GET https://sepomex-api.herokuapp.com/api/v1/municipalities
curl -X GET https://sepomex-api.herokuapp.com/api/v1/municipalities/1
curl -X GET https://sepomex-api.herokuapp.com/api/v1/municipalities -d zip_code=67173
### Cities
curl -X GET https://sepomex-api.herokuapp.com/api/v1/cities
curl -X GET https://sepomex-api.herokuapp.com/api/v1/cities/1
Please submit all pull requests against a separate branch.
This project adheres to the Contributor Covenant 1.2. By participating, you are expected to honor this code.
Abraham Kuri
Code and documentation copyright 2013-2016 Icalia Labs. Code released under the MIT license.