Package {alepe}


Title: Access the Open Data API of the Legislative Assembly of Pernambuco
Version: 0.1.0
Description: A tidy interface to the open data API of the Legislative Assembly of the State of Pernambuco, Brazil ('ALEPE', https://dadosabertos.alepe.pe.gov.br). Retrieve data on representatives, staff, positions, departments, remuneration, contracts, procurement processes, and legislative propositions as tibbles with clean names and parsed column types. Requests are cached locally and retried with exponential backoff; network failures are handled gracefully.
License: MIT + file LICENSE
URL: https://github.com/StrategicProjects/alepe, https://strategicprojects.github.io/alepe/
BugReports: https://github.com/StrategicProjects/alepe/issues
Depends: R (≥ 4.1)
Imports: cli, httr2 (≥ 1.0.0), readr, rlang (≥ 1.1.0), tibble
Suggests: dplyr, ggplot2, httptest2, jsonlite, knitr, rmarkdown, testthat (≥ 3.0.0), tidyr, withr
VignetteBuilder: knitr
Config/Needs/website: tidyverse/tidytemplate, pkgdown
Config/testthat/edition: 3
Encoding: UTF-8
Language: en-US
Config/roxygen2/version: 8.0.0
NeedsCompilation: no
Packaged: 2026-08-19 12:53:57 UTC; leite
Author: Andre Leite ORCID iD [aut, cre], Marcos Wasiliew [aut], Hugo Vasconcelos ORCID iD [aut], Carlos Amorim ORCID iD [aut], Diogo Bezerra ORCID iD [aut], Júlia Nascimento Barreto [aut]
Maintainer: Andre Leite <leite@castlab.org>
Repository: CRAN
Date/Publication: 2026-08-20 14:22:29 UTC

alepe: Access the Open Data API of the Legislative Assembly of Pernambuco

Description

logo

A tidy interface to the open data API of the Legislative Assembly of the State of Pernambuco, Brazil ('ALEPE', https://dadosabertos.alepe.pe.gov.br). Retrieve data on representatives, staff, positions, departments, remuneration, contracts, procurement processes, and legislative propositions as tibbles with clean names and parsed column types. Requests are cached locally and retried with exponential backoff; network failures are handled gracefully.

Package options

Author(s)

Maintainer: Andre Leite leite@castlab.org (ORCID)

Authors:

See Also

Useful links:


Portuguese aliases

Description

Every endpoint function has an alias named after the API endpoint it wraps, for analysts who would rather keep their whole pipeline in Portuguese. The aliases are ordinary functions with the same arguments, the same defaults and the same return value as their English counterparts — only the name differs.

Usage

alepe_parlamentares(refresh = FALSE)

alepe_servidores(status = NULL, refresh = FALSE)

alepe_cargos(status = NULL, refresh = FALSE)

alepe_lotacoes(refresh = FALSE)

alepe_remuneracao(refresh = FALSE)

alepe_contratos(refresh = FALSE)

alepe_licitacoes(refresh = FALSE)

alepe_projetos(numero = NULL, ano = NULL, legislatura = NULL, refresh = FALSE)

alepe_indicacoes(
  numero = NULL,
  ano = NULL,
  legislatura = NULL,
  refresh = FALSE
)

alepe_requerimentos(
  numero = NULL,
  ano = NULL,
  legislatura = NULL,
  refresh = FALSE
)

alepe_limpar_cache()

Arguments

refresh

If TRUE, bypass the local cache.

status

Employment status filter. One of "permanent", "commissioned", or "seconded" (the original API terms "efetivo", "comissionado", and "a-disposicao" are also accepted), or NULL (default) for all.

numero

Portuguese spelling of number.

ano

Portuguese spelling of year.

legislatura

Portuguese spelling of legislature.

Details

Portuguese English
alepe_parlamentares() alepe_representatives()
alepe_servidores() alepe_staff()
alepe_cargos() alepe_positions()
alepe_lotacoes() alepe_departments()
alepe_remuneracao() alepe_remuneration()
alepe_contratos() alepe_contracts()
alepe_licitacoes() alepe_procurements()
alepe_projetos() alepe_bills()
alepe_indicacoes() alepe_indications()
alepe_requerimentos() alepe_requests()
alepe_limpar_cache() alepe_cache_clear()

Names are written without accents, since accented characters in R identifiers are awkward to type and travel badly between locales.

Argument values follow the same both-ways rule: status accepts the English vocabulary and the original API terms alike, so alepe_servidores(status = "efetivo") and alepe_staff(status = "permanent") are the same query.

Value

The same tibble the corresponding English function returns.

Examples


alepe_parlamentares()
alepe_servidores(status = "efetivo")
alepe_projetos(ano = 2024)


Query legislative propositions

Description

Retrieves legislative propositions from the Assembly: bills (alepe_bills()), indications (alepe_indications()), and requests (alepe_requests()). Two query modes are supported by the API:

Usage

alepe_bills(number = NULL, year = NULL, legislature = NULL, refresh = FALSE)

alepe_indications(
  number = NULL,
  year = NULL,
  legislature = NULL,
  refresh = FALSE
)

alepe_requests(number = NULL, year = NULL, legislature = NULL, refresh = FALSE)

Arguments

number

Proposition number, for the detail mode. Requires year.

year

Filter by year (listing mode) or select the proposition (detail mode).

legislature

Filter by legislature number (listing mode).

refresh

If TRUE, bypass the local cache.

Details

These endpoints serve structured data as XML embedded in CSV; the package parses the XML fields into regular columns, with names normalized to snake_case and HTML markup stripped from free-text fields.

Value

A tibble. In listing mode, one row per proposition with docid, numero, ano, legislatura, tipo, subtipo, ementa, data_publicacao (Date), and autores (author names, ⁠;⁠-separated). In detail mode, a single row with numero, ano, legislatura, tipo, autores, ementa, materia, justificativa, regime_tramitacao, impacto_orcamentario, resultado_final, data_publicacao (Date), numero_dpl, and lotacao_atual. On network failure, a zero-column tibble (with a warning).

Examples


# All bills of the current year
alepe_bills()

# One specific bill
alepe_bills(number = 100, year = 2024)


Cache directory used by alepe

Description

Responses from the ALEPE API are cached on disk to avoid repeated downloads. The location follows tools::R_user_dir(), as required by CRAN policy. Cached entries expire after getOption("alepe.cache_max_age", 6 * 3600) seconds.

Usage

alepe_cache_dir()

alepe_cache_clear()

Value

The cache directory path, invisibly for alepe_cache_clear().

Examples

alepe_cache_dir()

List administrative contracts

Description

Retrieves the Assembly's administrative contracts, including modality, contractor name and tax id (CPF/CNPJ), object, value, originating procurement process, and validity period.

Usage

alepe_contracts(refresh = FALSE)

Arguments

refresh

If TRUE, bypass the local cache.

Value

A tibble with one row per contract: modalidade, numero_contrato, ano, contratada, cpf_cnpj, objeto, valor (numeric, BRL), numero_licitacao, ano_licitacao, vigencia_inicio, and vigencia_fim (Date). Identifier fields are kept as published by the API. Zero rows (with a warning) on network failure.

Examples


alepe_contracts()


Count staff by department

Description

Retrieves the number of active staff members grouped by department (lotacao) and employment status. The reference period is fixed by the API and excludes retired staff.

Usage

alepe_departments(refresh = FALSE)

Arguments

refresh

If TRUE, bypass the local cache.

Value

A tibble with total, nome_lotacao, and vinculo. Zero rows (with a warning) on network failure.

Examples


alepe_departments()


Count staff by position

Description

Retrieves the number of staff members per position/level, optionally filtered by employment status.

Usage

alepe_positions(status = NULL, refresh = FALSE)

Arguments

status

Employment status filter. One of "permanent", "commissioned", or "seconded" (the original API terms "efetivo", "comissionado", and "a-disposicao" are also accepted), or NULL (default) for all.

refresh

If TRUE, bypass the local cache.

Value

A tibble with total and cargo_nivel. Zero rows (with a warning) on network failure.

Examples


alepe_positions(status = "commissioned")


List procurement processes

Description

Retrieves the Assembly's procurement (bidding) processes, including process number and year, modality, object, estimated and awarded values, winner, and status.

Usage

alepe_procurements(refresh = FALSE)

Arguments

refresh

If TRUE, bypass the local cache.

Value

A tibble with one row per procurement process: numero_processo, ano, numero_modalidade, modalidade, objeto, valor_estimado (numeric, BRL), status, vencedor, and valor_adjudicado (numeric, BRL). Value and winner fields are NA when the process has not been decided. Zero rows (with a warning) on network failure.

Examples


alepe_procurements()


List remuneration by position

Description

Retrieves position remuneration values published by the Assembly for the current reference month.

Usage

alepe_remuneration(refresh = FALSE)

Arguments

refresh

If TRUE, bypass the local cache.

Value

A tibble with cargo, remuneracao (numeric, BRL), tipo_cargo, mes_competencia, and ano_competencia. Zero rows (with a warning) on network failure.

Examples


alepe_remuneration()


List current state representatives

Description

Retrieves the members of the current legislature of the Legislative Assembly of Pernambuco, with name and party.

Usage

alepe_representatives(refresh = FALSE)

Arguments

refresh

If TRUE, bypass the local cache.

Value

A tibble with one row per representative: nome_parlamentar and partido. On network failure a warning is issued and a zero-row tibble with the same columns is returned.

Examples


alepe_representatives()


List ALEPE staff

Description

Retrieves the Assembly's staff roster, optionally filtered by employment status.

Usage

alepe_staff(status = NULL, refresh = FALSE)

Arguments

status

Employment status filter. One of "permanent", "commissioned", or "seconded" (the original API terms "efetivo", "comissionado", and "a-disposicao" are also accepted), or NULL (default) for all.

refresh

If TRUE, bypass the local cache.

Value

A tibble with one row per staff member: nome, codigo_lotacao, nome_lotacao, cargo_efetivo, cargo_nivel, vinculo, and data_admissao (Date). Zero rows (with a warning) on network failure.

Examples


alepe_staff(status = "permanent")