Busca por CEP integrada aos serviços dos Correios, ViaCEP, WideNet e BrasilAPI (sync e async). Python port do cep-promise.
Project description
cepx
Busca por CEP integrada aos serviços dos Correios, ViaCEP, WideNet e BrasilAPI.
Python port of cep-promise, with
both synchronous and asynchronous APIs.
Providers are queried concurrently and the first successful response wins. The lookup only fails once every provider fails, aggregating each error.
Usage
import cepx
cepx.cep("05010000")
# Address(cep='05010000', state='SP', city='São Paulo',
# neighborhood='Perdizes', street='Rua Caiubi', provider='brasilapi')
cepx.cep(5010000) # ints are left-padded
cepx.cep("05010000", providers=["viacep"]) # restrict providers
cepx.cep("05010000", timeout=5.0) # per-provider timeout (s)
import asyncio
import cepx
asyncio.run(cepx.acep("05010000"))
Errors
cepx.CepxError is raised with a type of either "validation_error"
(bad input, before any request) or "provider_error" (all providers failed).
Its errors list holds the underlying cepx.ProviderError entries.
Development
uv sync
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run ty check
uv run pre-commit install
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cepx-0.1.0.tar.gz.
File metadata
- Download URL: cepx-0.1.0.tar.gz
- Upload date:
- Size: 52.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b945b9724020ad6d9cfab1a4ce9c4696b8d3402afaf5020c312b270075a57924
|
|
| MD5 |
7c54885c43bc2f4b8405707183754817
|
|
| BLAKE2b-256 |
1ddcc73e040d987e3da30d2118327b88929df91b7eae99cb838260405984ecb5
|
File details
Details for the file cepx-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cepx-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96dc5a71c8d54d4973bb7bb0f719a27e997e4a5e2d348bf0d411c1f8a123b3c8
|
|
| MD5 |
85249902a551755fa29ca4b7ad31b3f3
|
|
| BLAKE2b-256 |
a6c2debc2dcfb3a4a07113ed66c63a5254fbf03157ee3b4939b993aa09db4205
|