Skip to main content

tcepepy

PyPI version Python versions tests docs Downloads DOI License: MIT Code style: black

Python client for the TCE-PE (Tribunal de Contas do Estado de Pernambuco) Open Data API. It is the Python counterpart of the R package tceper.

tcepepy wraps 72 API endpoints into friendly functions that accept snake_case parameter names and return pandas DataFrames. A built-in catalog lets you discover endpoints and inspect their parameters and output fields — all offline, without leaving Python.

⚠️ Geo-restriction. The API host (sistemas.tcepe.tc.br) only accepts connections from Brazilian IP addresses. From outside Brazil, queries time out. The discovery helpers (catalog(), params(), fields()) work offline anywhere, as they read from the bundled catalog.

❗ Language note. Wrapper functions are named in English, but the underlying API is in Portuguese — so you pass parameters in Portuguese, e.g. state_revenues(AnoReferencia=2025). See the official endpoint list.

Installation

pip install tcepepy            # core (httpx + pandas)
pip install "tcepepy[rich]"    # prettier console output

Quick start

import tcepepy as tce

# 1. Discover endpoints (offline)
tce.catalog()
tce.catalog(search="contrat")

# 2. Inspect parameters and output fields (offline)
tce.params("Contratos")
tce.fields("Contratos")

# 3. Query (needs a Brazilian IP) — snake_case or the original API names both work
tce.contracts(codigo_efisco_ug="510101")
tce.contracts(CodigoEfiscoUG="510101", ano_contrato="2025")

Explore the API

tce.catalog()
#       endpoint      group                title  url
# 0  ReceitasEstaduais  Receitas  Relação das Receitas Estaduais  ...

tce.params("Contratos")    # api_name, r_name, required, type, description
tce.fields("Contratos")    # name, r_name, type, description

Use snake_case (r_name) or the original API names — both are accepted.

Cache

Every wrapper caches results in memory, keyed by endpoint + parameters (default TTL: 1 hour).

tce.contracts(codigo_efisco_ug="510101")                 # hits the API
tce.contracts(codigo_efisco_ug="510101")                 # cache hit (instant)
tce.contracts(codigo_efisco_ug="510101", cache=False)    # force fresh

tce.cache_info()    # inspect cached entries
tce.cache_clear()   # clear all

Parameter validation

Parameters are validated against the catalog. Passing an unknown parameter raises an error listing the allowed ones:

tce.contracts(xyz="foo")
# tcepepy.catalog.UnknownParameterError: Unknown query parameter(s) for
# endpoint 'Contratos': xyz.
# Allowed parameters:
#   - unidade_gestora (UnidadeGestora)
#   - codigo_efisco_ug (CodigoEfiscoUG)
#   ...

Configuration

tce.config.verbose = True      # print the final API URL on every call
tce.config.progress = False    # silence status messages
tce.config.cache_ttl = 7200    # cache TTL in seconds

Or via environment variables: TCEPEPY_VERBOSE, TCEPEPY_PROGRESS, TCEPEPY_CACHE_TTL.

Direct access

To call any endpoint (including ones without a dedicated wrapper) using API parameter names directly:

tce.request("Contratos", CodigoEfiscoUG="510101", AnoContrato="2025")

API limits

The API returns at most 100,000 records per request; tcepepy warns when this limit is hit. Use filters to narrow your query.

License

MIT. This package is an unofficial client; the data belongs to TCE-PE.

Metadata

Release files for tcepepy 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tcepepy 0.1.2
File Size Uploaded Provenance Actions
tcepepy-0.1.2.tar.gz 65.8 kB With provenance Details for tcepepy-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tcepepy 0.1.2
File Interpreter ABI Platform Actions
tcepepy-0.1.2-py3-none-any.whl Python 3 none any Details for tcepepy-0.1.2-py3-none-any.whl

Total release size: 106.9 kB

Release files / tcepepy-0.1.2.tar.gz

Download URL tcepepy-0.1.2.tar.gz
Size 65.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ecfa653dc72f71ae484c6baa50965d34ed475033c63640a1f3ca8c7f98039b1b
BLAKE2b-256 checksum
How to use checksums
bd66bbee134772ee462b99b969bbec52d8f2adfc2bec0eaeba18e9da8078d986
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / tcepepy-0.1.2-py3-none-any.whl

Download URL tcepepy-0.1.2-py3-none-any.whl
Size 41.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ca5e8bb605bf16930deb26b873cb21f09c30831927844ec2721a362610dbe796
BLAKE2b-256 checksum
How to use checksums
4908a89e0bf0625c056f4d5eee7655acfb25195621daf5de34f749181baa40ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for tcepepy 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tcepepy-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page