Simple API for Sepomex zip codes using Sepomets under the hood.
You can see this at: https://elixir-sepomex-api.herokuapp.com/
Only for reference.
You can run asdf install
in the root folder of the project to install the required versions of Erlang and Elixir defined in the .tool-versions
file.
- Clone this repository
git clone git@github.com:Plus17/sepomex-api.git
- Go to the project dir
cd sepomex-api
- Install dependencies:
mix deps.get && mix deps.compile
- Run:
mix run --no-halt
Now server is running at: http://localhost:4001/
- Build image:
docker build . --tag sepomex_api
- Run
docker images
to get the id of the new image. - Run:
docker run --env PORT=80 -p 8081:80 <image-id>
Now docker image is running at: http://localhost:8081/
Make a get request to service with the zip code:
GET: http://localhost:8081/03100
❯ curl "http://localhost:8081/03100" | jq --indent 2
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 630 100 630 0 0 205k 0 --:--:-- --:--:-- --:--:-- 205k
[
{
"city": {
"code": "03",
"name": "Ciudad de México"
},
"municipality": {
"code": "014",
"name": "Benito Juárez"
},
"office": "03001",
"postal_code": "03100",
"settlement": {
"code": "0496",
"name": "Del Valle Centro"
},
"settlement_type": {
"code": "09",
"name": "Colonia"
},
"state": {
"code": "09",
"name": "Ciudad de México"
},
"zone": "Urbano"
},
{
"city": {
"code": "03",
"name": "Ciudad de México"
},
"municipality": {
"code": "014",
"name": "Benito Juárez"
},
"office": "03001",
"postal_code": "03100",
"settlement": {
"code": "2624",
"name": "Insurgentes San Borja"
},
"settlement_type": {
"code": "09",
"name": "Colonia"
},
"state": {
"code": "09",
"name": "Ciudad de México"
},
"zone": "Urbano"
}
]
- Download the last database in TXT format from correosdemexico.gob.mx
- Rename the file to
sepomex.zip
- Replace the file in
priv/sepomex.zip
- Deploy