Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false

matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
Comment thread
mstuttgart marked this conversation as resolved.
os: [ubuntu-latest]
Comment thread
mstuttgart marked this conversation as resolved.

runs-on: ${{ matrix.os }}
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exclude: "docs/"
repos:
# Pre-commit hooks for general code quality checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
Comment thread
mstuttgart marked this conversation as resolved.
- id: check-yaml # Validate YAML files
- id: debug-statements # Detect debug statements (e.g., print, pdb)
Expand All @@ -17,31 +17,31 @@ repos:

# Sort imports automatically
- repo: https://github.com/PyCQA/isort
rev: 6.0.1
rev: 5.12.0
hooks:
- id: isort

# Format Python code with Black
- repo: https://github.com/psf/black
rev: 25.1.0
rev: 23.12.1
hooks:
- id: black

# Lint Python code with Ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.2
rev: v0.15.0
hooks:
- id: ruff

# Format tox.ini files
- repo: https://github.com/tox-dev/tox-ini-fmt
rev: "1.5.0"
rev: "1.7.1"
hooks:
- id: tox-ini-fmt

# Upgrade Python syntax to modern versions
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py39-plus] # Target Python 3.9+ syntax
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"

python:
install:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
Changelog
=========

7.2.0 (2026-02-08)

- Add support to Python 3.14
- Improce README and docs text

7.0.1 (2025-03-16)
------------------

- Fixes #104
- Fixes #103
Expand Down
169 changes: 20 additions & 149 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,18 @@

## Features

✨ **Simple and Intuitive API** - Easy-to-use interface for CEP queries
- Easy-to-use interface for CEP queries
- Full support for asynchronous operations
- Support for **ViaCEP**, **ApiCEP**, and **OpenCEP**
- Minimal dependencies and optimized performance
- Full type annotation support for better IDE experience
- Configure timeout, proxies, and preferred web service
- Comprehensive test coverage

🚀 **Async/Await Support** - Full support for asynchronous operations

🔄 **Multiple Web Services** - Support for ViaCEP, ApiCEP, and OpenCEP

⚡ **Fast and Lightweight** - Minimal dependencies and optimized performance

🛡️ **Type Hints** - Full type annotation support for better IDE experience
## About CEP

🔧 **Customizable** - Configure timeout, proxies, and preferred web service
**CEP** (Código de Endereçamento Postal) or **Postal Address Code** is the Brazilian postal code system created, maintained, and organized by Correios do Brasil (Brazilian Post Office). It consists of eight digits and helps streamline address organization and delivery of mail and packages across Brazil.

📦 **Well Tested** - Comprehensive test coverage

## Installation

Expand All @@ -80,12 +79,6 @@ Install using [pip](https://pip.pypa.io/):
pip install brazilcep
```

Or using [poetry](https://python-poetry.org/):

```bash
poetry add brazilcep
```

## Quick Start

### Synchronous Usage
Expand Down Expand Up @@ -140,85 +133,6 @@ address = get_address_from_cep('37503-130', webservice=WebService.APICEP)
address = get_address_from_cep('37503-130', webservice=WebService.OPENCEP)
```

### Configuring Timeout

Set a custom timeout for requests (default is 5 seconds):

```python
# Set timeout to 10 seconds
address = get_address_from_cep('37503-130', timeout=10)
```

### Using Proxies

Configure proxy settings for requests:

```python
proxies = {
'http': 'http://10.10.1.10:3128',
'https': 'http://10.10.1.10:1080',
}

address = get_address_from_cep('37503-130', proxies=proxies)
```

### Handling Exceptions

```python
from brazilcep import get_address_from_cep, exceptions

try:
address = get_address_from_cep('00000-000')
except exceptions.CEPNotFound:
print('CEP not found!')
except exceptions.InvalidCEP:
print('Invalid CEP format!')
except exceptions.ConnectionError:
print('Connection error!')
except exceptions.Timeout:
print('Request timeout!')
except exceptions.BrazilCEPException as e:
print(f'An error occurred: {e}')
```

### Complete Async Example

```python
import asyncio
from brazilcep import async_get_address_from_cep, WebService, exceptions

async def fetch_multiple_ceps():
"""Fetch multiple CEPs concurrently."""
ceps = ['37503-130', '01310-100', '20040-020']

tasks = [
async_get_address_from_cep(cep, webservice=WebService.OPENCEP)
for cep in ceps
]

try:
addresses = await asyncio.gather(*tasks)
for cep, address in zip(ceps, addresses):
print(f"\nCEP {cep}:")
print(f" Street: {address['street']}")
print(f" City: {address['city']}/{address['uf']}")
except exceptions.BrazilCEPException as e:
print(f"Error fetching addresses: {e}")

asyncio.run(fetch_multiple_ceps())
```

## Supported Web Services

| Service | Website | Status | Rate Limit |
|---------|---------|--------|------------|
| [OpenCEP](https://opencep.com) | https://opencep.com | ✅ Active | Yes |
| [ViaCEP](https://viacep.com.br) | https://viacep.com.br | ✅ Active | Yes |
| [ApiCEP](https://apicep.com) | https://apicep.com | ✅ Active | Yes |

> [!IMPORTANT]
> BrazilCEP does not guarantee the availability or support of any third-party query APIs. This library serves as a convenient interface for accessing these services. Please check each service's terms of use and rate limits.

## Response Format

All queries return a dictionary with the following structure:
Expand All @@ -232,7 +146,18 @@ All queries return a dictionary with the following structure:
'uf': str, # State abbreviation (e.g., 'MG')
'complement': str # Additional information (may be empty)
}

```
## Supported Web Services

| Service | Website | Status | Rate Limit |
| ------------------------------- | --------------------- | -------- | ---------- |
| [OpenCEP](https://opencep.com) | https://opencep.com | ✅ Active | Yes |
| [ViaCEP](https://viacep.com.br) | https://viacep.com.br | ✅ Active | Yes |
| [ApiCEP](https://apicep.com) | https://apicep.com | ✅ Active | Yes |

> [!IMPORTANT]
> BrazilCEP does not guarantee the availability or support of any third-party query APIs. This library serves as a convenient interface for accessing these services. Please check each service's terms of use and rate limits.

## Documentation

Expand All @@ -258,62 +183,8 @@ Contributions are welcome! Here's how you can help:

Please read our [Contributing Guide](https://brazilcep.readthedocs.io/contributing.html) before submitting a pull request.

### Development Setup

```bash
# Clone the repository
git clone https://github.com/mstuttgart/brazilcep.git
cd brazilcep

# Install dependencies
make setup

# Run tests
make test

# Run linting
make lint

# Run all checks
make check
```

## About CEP

**CEP** (Código de Endereçamento Postal) or **Postal Address Code** is the Brazilian postal code system created, maintained, and organized by Correios do Brasil (Brazilian Post Office). It consists of eight digits and helps streamline address organization and delivery of mail and packages across Brazil.

## Migration from PyCEPCorreios

BrazilCEP is the successor to PyCEPCorreios. To migrate your code:

**Old (PyCEPCorreios):**
```python
from pycepcorreios import get_address_from_cep
```

**New (BrazilCEP):**
```python
from brazilcep import get_address_from_cep
```

For detailed migration instructions, see the [migration guide](https://brazilcep.readthedocs.io/api.html#migrate-from-pycepcorreios).

## License

BrazilCEP is released under the [MIT License](https://github.com/mstuttgart/brazilcep/blob/main/LICENSE).

## Credits

Created and maintained by [Michell Stuttgart](https://github.com/mstuttgart).

## Support

- 📧 Issues: [GitHub Issues](https://github.com/mstuttgart/brazilcep/issues)
- 💬 Discussions: [GitHub Discussions](https://github.com/mstuttgart/brazilcep/discussions)
- 📖 Documentation: [ReadTheDocs](https://brazilcep.readthedocs.io/)

---

<p align="center">
Made with ❤️ in Brazil
</p>
2 changes: 1 addition & 1 deletion brazilcep/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "7.0.1"
__version__ = "7.2.0"
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ classifiers = [
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Software Development :: Build Tools",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires =
env_list =
lint
type
py3{13, 12, 11, 10, 9}
py3{14, 13, 12, 11, 10, 9}
skip_missing_interpreters = true

[testenv]
Expand Down
Loading