Skip to contents

Retrieves constitutional transfer data for municipalities within states.

Usage

get_tc_por_municipio(
  p_estado = NULL,
  p_municipio = NULL,
  p_ano = NULL,
  p_mes = NULL,
  p_transferencia = NULL,
  p_sn_detalhar = NULL,
  page_size = 1000L,
  max_rows = Inf,
  use_cache = TRUE,
  verbose = FALSE
)

get_tc_by_municipality(state_code = NULL, municipality = NULL,
  year = NULL, month = NULL, transfer_type = NULL, detailed = NULL,
  page_size = 1000L, max_rows = Inf, use_cache = TRUE, verbose = FALSE)

Arguments

p_estado

State code(s) from get_tc_estados(). Accepts a vector or colon-separated string. Optional.

p_municipio

Municipality code(s) from get_tc_municipios(). Accepts a vector or colon-separated string. Optional.

p_ano

Year(s). Accepts a vector or colon-separated string. Optional.

p_mes

Month(s). Accepts a vector or colon-separated string. Optional.

p_transferencia

Transfer type code(s) from get_tc_transferencias(). Accepts a vector or colon-separated string. Optional.

p_sn_detalhar

Character. Set to "sim" (the documented value; "S" also works) to break every transfer into its components (for example FUNDEB - FPM, FUNDEB - ICMS). Optional. get_tc_por_municipio_detalhe() returns the same breakdown with the three ten-day installments.

page_size

Integer. Rows requested per page (the server pages this endpoint; 10 rows by default on the server side, 1000 here).

max_rows

Integer. Stop after this many rows. Default Inf.

use_cache

Logical. If TRUE (default), uses an in-memory cache.

verbose

Logical. If TRUE, prints the full API URL being called. Useful for debugging or testing in a browser. Defaults to getOption("tesouror.verbose", FALSE).

state_code

State code(s) from get_tc_estados(). Accepts a vector or colon-separated string. Treasury codes, not IBGE. Optional. Maps to p_estado.

municipality

Municipality code(s) from get_tc_municipios(). Accepts a vector or colon-separated string. Treasury codes. Optional. Maps to p_municipio.

year

Year(s). Accepts a vector or colon-separated string. Optional. Maps to p_ano.

month

Month(s) (1-12). Accepts a vector or colon-separated string. Optional. Maps to p_mes.

transfer_type

Transfer type code(s) from get_tc_transferencias(). Accepts a vector or colon-separated string. Optional. Maps to p_transferencia.

detailed

Character. Set to any value to include detail. Optional. Maps to p_sn_detalhar.

Value

A tibble with transfer data by municipality (uf, ano, mes, transferencia, codigo_siafi, co_ibge, municipio, valor).

Details

All codes are internal Treasury codes (not IBGE). Use the dictionary functions to look them up: get_tc_estados() for state codes, get_tc_municipios() for municipality codes, and get_tc_transferencias() for transfer type codes.

Multi-value parameters accept either a colon-separated string ("1:2:3") or an R vector (c(1, 2, 3)).

get_tc_by_municipality() is an English alias.

The municipal endpoints are paginated: every page is fetched and the rows stacked. If a page after the first fails, the rows already fetched are returned with attr(x, "partial") = TRUE and attr(x, "last_page_error").

Examples

if (FALSE) { # \dontrun{
# Step 1: look up codes (Treasury codes, NOT IBGE)
estados <- get_tc_estados()
pe_code <- estados$codigo[estados$nome == "Pernambuco"]
municipios <- get_tc_municipios(p_uf = pe_code)
recife_code <- municipios$codigo[municipios$nome == "Recife"]

# Step 2: query (pass vector or string)
tc <- get_tc_por_municipio(
  p_estado = pe_code,
  p_municipio = recife_code,
  p_ano = 2023
)
} # }