Module for handling IBGE Aggregates API (v3).
Allows accessing aggregated data from surveys and censuses (SIDRA).
Summary
Functions
@spec all(Keyword.t()) :: {:ok, [ExIbge.Aggregate.Research.t()]} | {:error, any()}
Get all aggregates grouped by research.
Parameters
query- Optional parameters:period: Filter by period (e.g. "P5[202001]")subject: Filter by subject ID (e.g. 70)classification: Filter by classification ID (e.g. 12896)periodicity: Filter by periodicity (e.g. "P5")level: Filter by geographical level (e.g. "N6")
Examples
iex> ExIbge.Aggregate.all()
{:ok, [%ExIbge.Aggregate.Research{...}, ...]}See Also
@spec all!(Keyword.t()) :: [ExIbge.Aggregate.Research.t()]
Same as all/1, but raises an error on failure.
Get locations associated with an aggregate for specific geographical level(s).
Parameters
aggregate_id- ID of the aggregate (e.g. 1705)level- Geographical level ID(s), pipe-separated (e.g. "N6" or "N7|N6")
Examples
iex> ExIbge.Aggregate.get_locations(1705, "N6")
{:ok, [%{id: "3304557", nome: "Rio de Janeiro", ...}, ...]}
iex> ExIbge.Aggregate.get_locations(1705, "N7|N6")
{:ok, [%{id: "3301", ...}, ...]}See Also
@spec get_metadata(integer() | String.t()) :: {:ok, ExIbge.Aggregate.Metadata.t()} | {:error, any()}
Get metadata for a specific aggregate.
Parameters
aggregate_id- ID of the aggregate (e.g. 1705)
Examples
iex> ExIbge.Aggregate.get_metadata(1705)
{:ok, %ExIbge.Aggregate.Metadata{...}}See Also
@spec get_metadata!(integer() | String.t()) :: ExIbge.Aggregate.Metadata.t()
@spec get_periods(integer() | String.t()) :: {:ok, [ExIbge.Aggregate.Period.t()]} | {:error, any()}
Get periods for a specific aggregate.
Parameters
aggregate_id- ID of the aggregate (e.g. 1705)
Examples
iex> ExIbge.Aggregate.get_periods(1705)
{:ok, [%ExIbge.Aggregate.Period{...}, ...]}See Also
@spec get_periods!(integer() | String.t()) :: [ExIbge.Aggregate.Period.t()]
@spec get_variables( integer() | String.t(), String.t(), String.t() | nil, Keyword.t() ) :: {:ok, [ExIbge.Aggregate.Variable.t()]} | {:error, any()}
Get variables data for an aggregate.
This function allows querying the data for specific variables, periods, and locations/classifications.
Parameters
aggregate_id- ID of the aggregate (e.g. 1712)periods- Period identifier(s) (e.g. "-6", "201701", "201701-201706")variables- Variable identifier(s) (e.g. "214", "all", "allxp"). Defaults to "allxp" if nil.query- Additional query parameters:locations: Required. Location filter (e.g. "BR", "N6[3304557]")classifications: Optional. Classification filter (e.g. "226[4844]")view: Optional. "OLAP" or "flat".
Examples
iex> ExIbge.Aggregate.get_variables(1712, "-6", "214", locations: "BR")
{:ok, [%ExIbge.Aggregate.Variable{...}, ...]}