Skip to main content

transferegovpy

PyPI Python License: MIT DOI

Access the open data APIs of TransfereGov, the Brazilian federal government's platform for transfers to states, municipalities and civil society, from Python.

What this package covers

The package targets the public API host, api-publica.transferegov.gestao.gov.br, which publishes five modules and 86 tables in all:

Module Covers Tables
discricionarias Discretionary and legal transfers, the module that absorbed SICONV: proposals, proponents, programs, physical schedule, detailed application of funds, and the PAC selection process 12
especiais Special transfers, created by Constitutional Amendment 105/2019 for individual parliamentary amendments 23
fundoafundo Fund-to-fund transfers, from federal funds directly to state, district and municipal funds 20
parcerias Partnership management: programs, proposals, partnerships, their financial execution and bank statements 17
ted Decentralized credit between federal bodies (termo de execução descentralizada): programs, action plans, credit notes and financial programming 14

Every table in the published data models is reachable. Where the API folds a child table into its parent rather than giving it an endpoint of its own, it arrives as a column of lists — 2 of them in discricionarias, 5 in fundoafundo, 13 in parcerias, 4 in ted — and fields(nested=...) describes what is inside.

This is the Python sibling of transferegovr; the two cover the same ground with the same semantics.

What it does not cover

  • The older PostgREST endpoints at api.transferegov.gestao.gov.br, which version 0.1.x of this package used. The government announced their retirement for 2026-08-31.
  • The rest of the Discricionárias e Legais data. The discricionarias API published in October 2026 is the first of four stages the government has announced through October 2027; instruments, financial execution and the works module are still only CSV archives at https://api-publica.transferegov.gestao.gov.br/downloads.

Installation

pip install transferegovpy

A progress bar during long collections needs one extra:

pip install "transferegovpy[progress]"

Getting started

import transferegovpy as tg

tg.modules()
tg.tables("parcerias")
tg.fields("parcerias", "proposta")
tg.params("parcerias", "proposta")

get() retrieves rows. Each filter is named after one of the endpoint's own query parameters, and parameters combine with AND:

tg.get(
    "parcerias", "proposta",
    sg_uf_recebedor="PE",
    situacao_proposta="Aprovada",
    limit=20,
)

That is almost the whole filtering vocabulary. These services compare for equality — no greater-than, no pattern match — and publish no ordering or column-selection parameter. The one extension is on identifiers: 141 of them take several values and match any, which params() marks as multiple:

tg.get("ted", "planos_acao_metas", id_plano_acao=[3, 4])

params() lists what each table accepts, including the permitted values of the enumerated parameters.

A typo must not look like an answer

These services ignore a query parameter they do not recognise and answer 200 with the whole table. Misspell situacao_proposta and you get every proposal where the filter would have given the approved ones — a plausible number, quietly wrong.

So every parameter name is checked against the packaged schema before a request goes out:

tg.count("parcerias", "proposta", in_situacao_proposta="Aprovada")
#> FilterError: Unknown filter(s): 'in_situacao_proposta'. The API ignores a
#> parameter it does not recognise and returns every row, so this would look
#> like a query that matched nothing in particular. Did you mean
#> 'situacao_proposta'? ...

Enumerated values are checked the same way, before the round trip rather than after it.

Size first, download second

Each request returns one page — at most 200 rows in discricionarias, especiais and parcerias, 1000 in fundoafundo and ted — and these tables are not small. Ask before you fetch:

tg.count("especiais", "meta_especiais")
#> 156193

limit counts rows, not pages. Anything above one page is collected page by page, and the total collected is checked against what the API reported:

import math

metas = tg.get("especiais", "meta_especiais", limit=math.inf)

tg.metadata(metas)["total_rows"]
tg.metadata(metas)["pages"]

Types

Columns are typed from the API's own schema rather than guessed, so a column that happens to be entirely null on one page does not change dtype on the next:

proposals = tg.get("parcerias", "proposta", limit=5)

proposals.dtypes["dt_proposta"]
#> dtype('<M8[ns]')
proposals.dtypes["id_proposta"]
#> Int64Dtype()

Identifiers are a nullable 64-bit integer. This is the one deliberate divergence from the R sibling, which returns them as double: pandas' Int64 holds the full range and a missing value, so there is nothing to trade away. cd_parceria reaches 202500037062.

Freshness and caching

Each module reports when it was last loaded, which is the only freshness signal these APIs give — they send no ETag, Cache-Control or Last-Modified:

tg.updated_at("parcerias")
#> datetime.datetime(2026, 9, 28, 0, 0)

Responses are cached for an hour in a temporary directory, so nothing is written outside the session unless you ask for it:

tg.cache_dir("~/.cache/transferegovpy")

or set TRANSFEREGOVPY_CACHE_DIR in the environment. cache_clear() empties it.

Column names are in Portuguese

Table names, column names, parameter names and categorical values belong to the API and are left as the government publishes them. The package's own functions and documentation are in English.

Official documentation

Metadata

Release files for transferegovpy 0.4.0

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

Source distribution (sdist)

Source distribution for transferegovpy 0.4.0
File Size Uploaded Provenance Actions
transferegovpy-0.4.0.tar.gz 88.4 kB With provenance Details for transferegovpy-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 155.4 kB

Release files / transferegovpy-0.4.0.tar.gz

Download URL transferegovpy-0.4.0.tar.gz
Size 88.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6c742a3a08f01afa16ff391324bcb34f63ade3f0f74d88c5e422dbad0387a20f
BLAKE2b-256 checksum
How to use checksums
b21d2cc2cf65fbde83cc629a77dbaeae3453e6da7e370b113b4e94d9a6236914
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 29, 2026.

Transparency log

Release files / transferegovpy-0.4.0-py3-none-any.whl

Download URL transferegovpy-0.4.0-py3-none-any.whl
Size 67.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
340132a23928ad49746659de98283c07a34fc663c6ca024eb02597e4fbd7f6c6
BLAKE2b-256 checksum
How to use checksums
f53d4b9dd626139572b83415ff74a167c66a02c8d53c058b217d0eb489bd15f3
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 29, 2026.

Transparency log

Security for transferegovpy 0.4.0

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 transferegovpy-0.4.0.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 29, 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