Simple web service that collects zip code informations from a public API and stores in a database.
$ git clone https://github.com/mdsrosa/iclinic_cep_webservices.git iclinic_webservices
$ cd iclinic_webservices
$ mkvirtualenv iclinic_webservices
$ pip install -r requirements/development.txt
$ python manage.py migrate
$ python manage.py createapikey
API Key created: d41d8cd98f00b204e9800998ecf8427e
$ python manage.py runserver
This endpoint lists all routes in the database.
$ curl -i http://localhost:8000/zipcodes/?api_key=d41d8cd98f00b204e9800998ecf8427e
{
"objects": [
{
"city": "Araraquara",
"neighborhood": "Centro",
"state": "SP",
"address": "Rua Padre Duarte",
"id": 1,
"zip_code": "14800360"
},
{
"city": "Ribeirão Preto",
"neighborhood": "Jardim América",
"state": "SP",
"address": "Avenida Presidente Vargas",
"id": 2,
"zip_code": "14020260"
}
]
}
This endpoint lists all routes in the database limited by limit
parameter.
$ curl -i http://localhost:8000/zipcodes/?limit=1&api_key=d41d8cd98f00b204e9800998ecf8427e
{
"objects": [
{
"city": "Araraquara",
"neighborhood": "Centro",
"state": "SP",
"address": "Rua Padre Duarte",
"id": 1,
"zip_code": "14800360"
},
]
}
This endpoint returns the details of a zipcode.
$ curl -i http://localhost:8000/zipcode/14020260/?api_key=d41d8cd98f00b204e9800998ecf8427e
{
"city": "Araraquara",
"neighborhood": "Centro",
"state": "SP",
"address": "Rua Padre Duarte",
"id": 1,
"zip_code": "14800360"
}
This endpoint creates a new zipcode.
Name | Type | Description | Example |
---|---|---|---|
zipcode | string | The zip code | "14800360" |
$ curl -i -H "Content-Type: application/json" -X POST http://localhost:8000/zipcodes/?api_key=d41d8cd98f00b204e9800998ecf8427e -d '{"zip_code":"14800360"}'
{
"city": "Araraquara",
"neighborhood": "Centro",
"state": "SP",
"address": "Rua Padre Duarte",
"id": 1,
"zip_code": "14800360"
}
This endpoint deletes a zipcode.
$ curl -X DELETE http://localhost:8000/zipcodes/14800360?api_key=d41d8cd98f00b204e9800998ecf8427e
python manage.py --pattern=*_test.py