The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Package {sidrar}


Type: Package
Title: An Interface to IBGE's SIDRA API
Version: 0.3.0
Description: Provides a flexible interface to the aggregate data available from the Brazilian Institute of Geography and Statistics (IBGE) through its SIDRA application programming interfaces. SIDRA is IBGE's system for retrieving aggregate statistical data.
Depends: R (≥ 3.6.0)
License: GPL-3
Encoding: UTF-8
Language: en-US
URL: https://github.com/rpradosiqueira/sidrar/
BugReports: https://github.com/rpradosiqueira/sidrar/issues/
Imports: httr, jsonlite, utils
RoxygenNote: 8.0.0
Suggests: knitr, rmarkdown, testthat (≥ 3.2.0)
Config/testthat/edition: 3
VignetteBuilder: knitr
NeedsCompilation: no
Packaged: 2026-07-23 19:20:19 UTC; CodexSandboxOffline
Author: Renato Prado Siqueira [aut, cre]
Maintainer: Renato Prado Siqueira <rpradosiqueira@gmail.com>
Repository: CRAN
Date/Publication: 2026-07-23 20:50:02 UTC

Get a SIDRA table

Description

Retrieves aggregate data from the Brazilian Institute of Geography and Statistics (IBGE) SIDRA API.

Usage

get_sidra(
  x,
  variable = "allxp",
  period = "last",
  geo = "Brazil",
  geo.filter = NULL,
  classific = "all",
  category = "all",
  header = TRUE,
  format = 4,
  digits = "default",
  api = NULL,
  value_type = c("numeric", "character", "both")
)

Arguments

x

A numeric SIDRA table code. It may be omitted when api is used.

variable

A vector of variable codes. Defaults to "allxp", which selects all variables except automatically generated percentages.

period

A character vector of period codes, "all", or a single named value such as c(last = 12) or c(first = 5).

geo

A character vector containing supported geographic levels. Defaults to "Brazil".

geo.filter

A list of geographic filters. Each element corresponds positionally to an element of geo; names may identify a higher geographic level, such as list(State = 50) for cities in a state.

classific

A vector of classification codes. Defaults to "all".

category

"all" or a list containing categories for each classification.

header

Logical. Should the first API record be used as the returned column names?

format

An integer from 1 to 4 controlling the returned descriptor fields. See Details.

digits

"default", "max", or an integer from 0 to 9.

api

A relative SIDRA API path or a complete URL under ⁠https://apisidra.ibge.gov.br/values⁠. When supplied, the other query arguments are ignored.

value_type

How the value column is returned: "numeric" preserves the historical numeric interface, "character" preserves SIDRA symbols, and "both" keeps the numeric column and appends a ⁠_raw⁠ column.

Details

Supported values of geo are "Brazil", "Region", "State", "IntermediaryRegion", "ImmediateRegion", "MesoRegion", "MicroRegion", "MetroRegion", "MetroRegionDiv", "IRD", "UrbAglo", "PopArrang", "City", "District", "subdistrict", and "Neighborhood".

format = 1 returns codes, format = 2 returns names, format = 3 returns codes and names for geographic units plus names for other descriptors, and format = 4 returns codes and names for all descriptors.

Requests use HTTPS, UTF-8 decoding, a timeout, and limited retries for transient failures. Set options(sidrar.timeout = 120) or options(sidrar.retries = 4) to override their defaults.

The SIDRA API uses special value symbols. With the default value_type = "numeric", non-numeric symbols such as "-", "X", "..", and "..." become NA, as in earlier versions. Use value_type = "character" or "both" when those distinctions matter.

Value

A base data.frame.

Author(s)

Renato Prado Siqueira rpradosiqueira@gmail.com

See Also

info_sidra() and search_sidra()

Examples

## Not run: 
get_sidra(
  x = 7060,
  variable = 63,
  period = c(last = 12),
  geo = "City",
  geo.filter = list(State = 50),
  classific = "c315",
  category = list(7169)
)

get_sidra(
  api = "/t/7060/n1/all/v/63/p/last/c315/7169/h/n"
)

## End(Not run)

List the parameters of a SIDRA table

Description

Uses the official JSON table descriptor to return variables, periods, classifications, categories, and geographic levels available in a table.

Usage

info_sidra(x, wb = FALSE)

Arguments

x

A numeric SIDRA table code.

wb

Logical. When TRUE, open the official HTML descriptor in the default browser. When FALSE, return structured metadata.

Value

When wb = FALSE, a list with components table, period, variable, classific_category, and geo. When wb = TRUE, the descriptor URL is returned invisibly after the browser is opened.

Author(s)

Renato Prado Siqueira rpradosiqueira@gmail.com

See Also

get_sidra()

Examples

## Not run: 
info_sidra(7060)
info_sidra(7060, wb = TRUE)

## End(Not run)

Search SIDRA tables

Description

Searches table titles in the official IBGE aggregate catalog.

Usage

search_sidra(x)

Arguments

x

A non-empty character vector containing the search terms.

Value

A named character vector with matching SIDRA table titles. Names are the table codes.

Author(s)

Renato Prado Siqueira rpradosiqueira@gmail.com

See Also

get_sidra() and info_sidra()

Examples

## Not run: 
search_sidra("contas nacionais")
search_sidra("IPCA")

## End(Not run)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.