alepe 
Tidy access from Python to the open data API of the Legislative Assembly of the State of Pernambuco, Brazil (ALEPE): representatives, staff, positions, departments, remuneration, contracts, procurement and legislative propositions — as pandas frames with clean names and parsed types.
This is the Python sibling of the R package alepe; both wrap the same endpoints and produce the same column names.
Installation
pip install alepe
Quick start
import alepe
# Current representatives
alepe.representatives()
# Permanent staff, largest departments
alepe.staff(status="permanent").value_counts("nome_lotacao")
# Contracts active today
import datetime as dt
today = dt.date.today()
contracts = alepe.contracts()
contracts[(contracts.vigencia_inicio <= today) & (contracts.vigencia_fim >= today)]
# Bills of a given year
alepe.bills(year=2024)
Column names keep the official Portuguese field names, normalised to
snake_case, so a result stays traceable to its source. Filter values accept
both vocabularies — status="permanent" and status="efetivo" are the same
query.
Em português
Cada função tem um alias com o nome do próprio endpoint da API, para quem prefere manter o pipeline inteiro em português:
alepe.parlamentares()
alepe.servidores(status="efetivo")
alepe.contratos()
alepe.projetos(ano=2024)
cargos(), lotacoes(), remuneracao(), licitacoes(), indicacoes(),
requerimentos() e limpar_cache() completam o conjunto.
How it works
Every function is a thin wrapper over the same core: a cached, retrying request whose response is typed into a frame by a documented schema.
What the package handles for you
The API is generated from an internal system and shows it. Three quirks would otherwise produce quietly wrong numbers:
- Two naming conventions at once.
NOME_LOTACAOfrom/servidores,nomeParlamentarfrom/parlamentares. Both becomenome_lotacaoandnome_parlamentar. - Two number encodings at once.
"1.234,56"in some fields and float-formatted strings such as"119267.04"in others. Reading either with a fixed locale corrupts the other — a Brazilian locale turns119267.04into 11 926 704. The parser decides per value. - Dates in three shapes, including serialised
DateTimeobjects ({"date": "2026-05-05 00:00:00.000000", ...}).
The propositions endpoints answer XML embedded in CSV; the package parses it into ordinary columns and strips the HTML markup out of the free-text fields.
Caching, retries and failures
Responses are cached for six hours in the session's temporary directory. Set
ALEPE_CACHE_DIR, or call alepe.cache_dir(path), to keep them between
sessions; alepe.cache_clear() empties it, and any call takes refresh=True
to bypass it.
Requests are retried up to three times on 429 and 5xx with exponential backoff,
with a 60-second timeout. That default is measured, not habitual:
/licitacoes regularly takes 25–30 seconds to answer, and the service cuts its
own query off at 30 seconds, so a 30-second client timeout fails on margin
alone.
When the API cannot be reached, the call raises AlepeHTTPError, carrying the
status code and the URL. This is where the two siblings differ on purpose:
CRAN's policy on internet resources requires the R package to warn and return
an empty result instead of stopping, while a silent empty frame would be
surprising in Python.
try:
frame = alepe.procurements()
except alepe.AlepeHTTPError as err:
print(f"ALEPE is not answering ({err.status}); carrying on without it")
frame = alepe.empty("procurements")
alepe.empty(name) returns a correctly typed empty frame for any endpoint,
which is what you want when a pipeline downstream expects the columns to exist
either way.
Related packages
Part of a family of clients for Brazilian public data published under StrategicProjects, with siblings in R on CRAN: tceper (Pernambuco Court of Accounts), transferegovr and its Python twin transferegovpy, tesouror, comexr, datasusr, ibger and pixr.
Citation
Archived on Zenodo. The DOI above is the concept DOI: it always resolves to
the latest version. To cite the exact version you used, take its own DOI from
the Zenodo record, or read CITATION.cff.
License
MIT.
Metadata
Release files for alepe 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| alepe-0.1.1.tar.gz | 23.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| alepe-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.2 kB
Release files / alepe-0.1.1.tar.gz
| Download URL | alepe-0.1.1.tar.gz |
|---|---|
| Size | 23.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b86ab0723d319821499f5c13f604fb696777a85d6c640d92c7d1df85d84bee01
|
|
BLAKE2b-256 checksum How to use checksums |
7065729ded4d838a2b5b031266411c09accea5ba3db9f9ccbbf3739c91d40ad8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 29, 2026.
Transparency logRelease files / alepe-0.1.1-py3-none-any.whl
| Download URL | alepe-0.1.1-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a04ca916450ae12db1578d6d2429c3ae0ff4f1f558c234368a36e42ec8359df6
|
|
BLAKE2b-256 checksum How to use checksums |
fe800d1f0107cd5d34e1c6d649bf1b7cf3952962ea337f4b55c26cb902740496
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 29, 2026.
Transparency log