Skip to content

Simple web service that collects zip code informations from a public API and stores in a database

Notifications You must be signed in to change notification settings

Cazuky/iclinic_cep_webservice

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iClinic ZipCode API

Build Status Coverage Status Django version Restless version

Simple web service that collects zip code informations from a public API and stores in a database.

Installation

Considering you already have a Python development environment setup.
$ git clone https://github.com/mdsrosa/iclinic_cep_webservices.git iclinic_webservices
$ cd iclinic_webservices
$ mkvirtualenv iclinic_webservices
$ pip install -r requirements/development.txt

Migrations

$ python manage.py migrate

Generate your API Key

$ python manage.py createapikey
API Key created: d41d8cd98f00b204e9800998ecf8427e

Running Locally

$ python manage.py runserver

Endpoints

GET /zipcodes/

This endpoint lists all routes in the database.

cURL Example

$ curl -i http://localhost:8000/zipcodes/?api_key=d41d8cd98f00b204e9800998ecf8427e

Response Example

{
    "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"
        }
    ]
}

GET /zipcodes/?limit=XXX

This endpoint lists all routes in the database limited by limit parameter.

cURL Example

$ curl -i http://localhost:8000/zipcodes/?limit=1&api_key=d41d8cd98f00b204e9800998ecf8427e

Response Example

{
    "objects": [
        {
            "city": "Araraquara",
            "neighborhood": "Centro",
            "state": "SP",
            "address": "Rua Padre Duarte",
            "id": 1,
            "zip_code": "14800360"
        },
    ]
}

GET /zipcodes/<zip_code>

This endpoint returns the details of a zipcode.

cURL Example
$ curl -i http://localhost:8000/zipcode/14020260/?api_key=d41d8cd98f00b204e9800998ecf8427e
Response Example
{
    "city": "Araraquara",
    "neighborhood": "Centro",
    "state": "SP",
    "address": "Rua Padre Duarte",
    "id": 1,
    "zip_code": "14800360"
}

POST /zipcodes/

This endpoint creates a new zipcode.

Fields

Name Type Description Example
zipcode string The zip code "14800360"
cURL Example
$ curl -i -H "Content-Type: application/json" -X POST http://localhost:8000/zipcodes/?api_key=d41d8cd98f00b204e9800998ecf8427e -d '{"zip_code":"14800360"}'
Response Example
{
    "city": "Araraquara",
    "neighborhood": "Centro",
    "state": "SP",
    "address": "Rua Padre Duarte",
    "id": 1,
    "zip_code": "14800360"
}

DELETE /zipcodes/<zip_code>

This endpoint deletes a zipcode.

cURL Example
$ curl -X DELETE http://localhost:8000/zipcodes/14800360?api_key=d41d8cd98f00b204e9800998ecf8427e

Tests

python manage.py --pattern=*_test.py

About

Simple web service that collects zip code informations from a public API and stores in a database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%