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.
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.
License
MIT.
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 alepe-0.1.0.tar.gz.
File metadata
- Download URL: alepe-0.1.0.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58acb73ea30f14f4886a8cfaa19092867ee8cbdcd25501ce765b0b231b230109
|
|
| MD5 |
733615050cd2bd07fe008febef8cf826
|
|
| BLAKE2b-256 |
06c088b61ba1aaba32e1ed6c70208d83af1ef1bb3792f3a85b839a9ebaca44fe
|
Provenance
The following attestation bundles were made for alepe-0.1.0.tar.gz:
Publisher:
release.yml on StrategicProjects/alepe_py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alepe-0.1.0.tar.gz -
Subject digest:
58acb73ea30f14f4886a8cfaa19092867ee8cbdcd25501ce765b0b231b230109 - Sigstore transparency entry: 2457568941
- Sigstore integration time:
-
Permalink:
StrategicProjects/alepe_py@f82e7aa5988d7f29ad2695a0079ebb594828e26e -
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:
release.yml@f82e7aa5988d7f29ad2695a0079ebb594828e26e -
Trigger Event:
push
-
Statement type:
File details
Details for the file alepe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: alepe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a09edf9a7f6ed630bfd1d623931db84311944862858eb4180c730833581bec3
|
|
| MD5 |
9fe9000e7e0d49613e1398eaa2aae817
|
|
| BLAKE2b-256 |
73b0304516f0d8a98de27d026dcf14dd765affcbc2e941ee06d0fa5e376845de
|
Provenance
The following attestation bundles were made for alepe-0.1.0-py3-none-any.whl:
Publisher:
release.yml on StrategicProjects/alepe_py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
alepe-0.1.0-py3-none-any.whl -
Subject digest:
6a09edf9a7f6ed630bfd1d623931db84311944862858eb4180c730833581bec3 - Sigstore transparency entry: 2457569058
- Sigstore integration time:
-
Permalink:
StrategicProjects/alepe_py@f82e7aa5988d7f29ad2695a0079ebb594828e26e -
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:
release.yml@f82e7aa5988d7f29ad2695a0079ebb594828e26e -
Trigger Event:
push
-
Statement type: