Mexico zipcodes micro service with NodeJS & MongoDB using HapiJS framework.
Data taken from the Mexico postal service (SEPOMEX).
- Total documents: 144,826
- Unique zipcodes: 32,147
You can find and already hosted version of the api here: http://mexico-zipcodes.herokuapp.com/
http://mexico-zipcodes.herokuapp.com/zipcode/03100
/zipcode/{ZIPCODE}
http://mexico-zipcodes.herokuapp.com/zipcode/03100
/state/{STATE}
http://mexico-zipcodes.herokuapp.com/state/Tamaulipas
/colony/{COLONY}
http://mexico-zipcodes.herokuapp.com/colony/Centro
/municipality/{MUNICIPALITY}
http://mexico-zipcodes.herokuapp.com/municipality/Benito%20Juárez
/zone/{ZONE_TYPE}
http://mexico-zipcodes.herokuapp.com/zone/Urbano
All search terms have case-insensitive and RegExp search (not accent insensitive, though)
Add at the end of the url:
-
?page={PAGE}&limit={LIMIT}
http://mexico-zipcodes.herokuapp.com/zone/Urbano?page=1&limit=5You'll get back the following additional arguments:
- total (total of documents per the search term)
- limit (limit of data per page)
- page (current page)
- pages (total of pages per the search terms)
Use instructions below to setup the repo and run the project:
The following dependencies are required to setup and run this project locally:
- NodeJS
- NPM/Yarn
- MongoDB
git clone https://github.com/saraileon/mexico-zipcodes.git
cd mexico-zipcodes
From shell run once:
DB=db_index node server.js
npm install OR yarn
If you are in a Linux/Unix shell
cd data
for filename in *; do mongoimport -d mexico_zipcodes -c zipcodes --type json --file $filename; done
cd ..
node server.js --port=5899
- Open localhost:5899
Service: localhost:5899/zipcode/03100