Python client for the Open Data API of the Pernambuco Court of Accounts (TCE-PE)
Project description
tcepepy
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 71 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.
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 tcepepy-0.1.0.tar.gz.
File metadata
- Download URL: tcepepy-0.1.0.tar.gz
- Upload date:
- Size: 63.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c2a84a813ba43223363603212f869d5968f2effbb2383e7112c61e3b0bdc24b
|
|
| MD5 |
c811ba304f236299f9e96675bdfba550
|
|
| BLAKE2b-256 |
ca870a4421768ca1be875054659d871eec455a1b3c0b3dca65b38869b4270d62
|
Provenance
The following attestation bundles were made for tcepepy-0.1.0.tar.gz:
Publisher:
publish.yml on StrategicProjects/tcepepy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tcepepy-0.1.0.tar.gz -
Subject digest:
3c2a84a813ba43223363603212f869d5968f2effbb2383e7112c61e3b0bdc24b - Sigstore transparency entry: 1819360942
- Sigstore integration time:
-
Permalink:
StrategicProjects/tcepepy@c78200e3ac3b7e4e2c5801bfcc199ad65a4c4cc2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/StrategicProjects
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c78200e3ac3b7e4e2c5801bfcc199ad65a4c4cc2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file tcepepy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: tcepepy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 40.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e463f2b68d3e2d2a33b8d21a4723c1e4d6ede4fc1b504becd1115507ac5db699
|
|
| MD5 |
b685a58d67fee6c4ed0127b195f47c94
|
|
| BLAKE2b-256 |
96d160d2e129dba387d5c35e1024a1405039cfc35a91061173588904e4296248
|
Provenance
The following attestation bundles were made for tcepepy-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on StrategicProjects/tcepepy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
tcepepy-0.1.0-py3-none-any.whl -
Subject digest:
e463f2b68d3e2d2a33b8d21a4723c1e4d6ede4fc1b504becd1115507ac5db699 - Sigstore transparency entry: 1819361178
- Sigstore integration time:
-
Permalink:
StrategicProjects/tcepepy@c78200e3ac3b7e4e2c5801bfcc199ad65a4c4cc2 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/StrategicProjects
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c78200e3ac3b7e4e2c5801bfcc199ad65a4c4cc2 -
Trigger Event:
release
-
Statement type: