Skip to main content

Brazilian CEP (postal code) lookup integrated with the Correios, ViaCEP, WideNet, and BrasilAPI services (sync and async). Python port of cep-promise.

Project description

cepx

Brazilian CEP (postal code) lookup integrated with the Correios, ViaCEP, WideNet, and BrasilAPI services. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cepx-0.1.1.tar.gz (53.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cepx-0.1.1-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file cepx-0.1.1.tar.gz.

File metadata

  • Download URL: cepx-0.1.1.tar.gz
  • Upload date:
  • Size: 53.2 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

Hashes for cepx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9feb1f9a7cd46f15b7e9fba10efaec02e24578bbf9dcb63678c81bce1fc09c7e
MD5 cdd7f09844f380932c2cff3283d409ef
BLAKE2b-256 7d6fd97f0f71371b6091cdca649d249f7c72835fb69fc9ff89b98716cc1e01e0

See more details on using hashes here.

File details

Details for the file cepx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cepx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.4 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

Hashes for cepx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c050d1fa8d0e86dd89c2c60e908efc554b34cdbbef8394c08c3b4fc92000a6e
MD5 6f219e75ebb35f95ea84416b47cc6978
BLAKE2b-256 2fa2d68b83afbfa4f92f8b5c7e4af981de5d2477f5b95ace427589d16686d12e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page