Skip to content

🇧🇷 Minimalist and easy-to-use python library designed to query CEP (Postal Address Code) data.

License

Notifications You must be signed in to change notification settings

mstuttgart/brazilcep

Repository files navigation


BrazilCEP

GitHub Workflow Status Codecov Downloads Ratings Version

About | Install | How to Use | Documentation | Contribute | Credits

About

BrazilCEP is a minimalist and easy-to-use python library designed to query CEP (Postal Address Code) data.

Its objective is to provide a common query interface to all these search services, facilitating the integration of Python applications with these services.

Currently supports several CEP API's:

Note

BrazilCEP is the new name of former PyCEPCorreio python library. If you want to migrate the old code to the new version, please see the migrate section in docs.

Tip

CEP or Código de Endereçamento Postal (Postal Address Code), as it is also known, is a system of numeric codes, created, maintained and organized by Correios do Brazil for organizing addresses and deliveries of letters and parcels.

Install

The recommended way to get BrazilCEP is to install the latest stable release via pip:

pip install brazilcep

Important

We currently support Python 3.8+ only. Users on older interpreter versions are urged to upgrade.

How to Use

Making a request is very simple. Begin by importing the BrazilCEP module:

>>> import brazilcep

Now, call the get_address_from_cep to query any CEP:

>>> address = brazilcep.get_address_from_cep('37503-130')

Now, we have a dict object called address. We can get all the address information we need from this object:

 >>> address
{
    'district': 'rua abc',
    'cep': '37503130',
    'city': 'city ABC',
    'street': 'str',
    'uf': 'str',
    'complement': 'str',
}

The CEP always must be a string.

Tip

BrazilCEP was developed to integrate on-demand queries into web pages. Querying CEP in bulk through scripts or any other means is not recommended.

Important

BrazilCEP is not responsible for the functioning, availability and support of any of these query API's. All of them are provided by third parties, and this library just provides a handy way to centralize the CEP search on these services.

Documentation

Documentation for the current version of BrazilCEP is available from the official docs here.

Contribute

See this guideline here.

Credits

Copyright (C) 2016-2024 by Michell Stuttgart