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 foremangem with:
% gem install foremanTo 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/setupscript
- Lift the server foreman start
Or by hand
- First clone the project git clone https://github.com/IcaliaLabs/sepomex.git
- Under the sepomexdirectory run thebundle installcommand to download all the dependencies
- Set up the database.ymlto 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=monterreycurl -X GET https://sepomex-api.herokuapp.com/api/v1/zip_codes -d state=nuevo%20leoncurl -X GET https://sepomex-api.herokuapp.com/api/v1/zip_codes -d colony=punta%20contrycurl -X GET https://sepomex-api.herokuapp.com/api/v1/zip_codes -d zip_code=67173curl -X GET https://sepomex-api.herokuapp.com/api/v1/zip_codes \
-d colony=punta%20contry \
-d state=nuevo%20leon \
-d city=guadalupeNote: 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/statescurl -X GET https://sepomex-api.herokuapp.com/api/v1/states/1curl -X GET https://sepomex-api.herokuapp.com/api/v1/states/1/municipalitiescurl -X GET https://sepomex-api.herokuapp.com/api/v1/municipalitiescurl -X GET https://sepomex-api.herokuapp.com/api/v1/municipalities/1curl -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/citiescurl -X GET https://sepomex-api.herokuapp.com/api/v1/cities/1Please 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.