ExIbge.Locality.Microregion (ex_ibge v0.4.0)

Copy Markdown View Source

Module for handling Microregion (Microrregião) queries from IBGE.

Microregions are subdivisions of mesoregions, grouping municipalities with similar geographic and economic characteristics.

Note: Microregions were replaced by Immediate Geographic Regions in 2017, but this API endpoint is still available for historical data.

Summary

Functions

Get all microregions.

Same as all/1, but raises an error on failure.

Get microregion(s) by identifier(s).

Same as find/2, but raises an error on failure.

Get microregions by mesoregion identifier(s).

Same as get_by_mesoregion/2, but raises an error on failure.

Get microregions by region identifier(s).

Same as get_by_region/2, but raises an error on failure.

Get microregions by state identifier(s).

Same as get_by_state/2, but raises an error on failure.

Functions

all(query \\ [])

@spec all(Keyword.t()) :: {:ok, [ExIbge.Geography.Microregion.t()]} | {:error, any()}

Get all microregions.

Parameters

  • query - Optional parameters supported by the API (e.g., order_by: :name).

Examples

iex> ExIbge.Locality.Microregion.all()
{:ok, [%ExIbge.Geography.Microregion{id: 11001, name: "Ji-Paraná", ...}, ...]}

See Also

IBGE API: Microrregiões

all!(query \\ [])

Same as all/1, but raises an error on failure.

find(ids, query \\ [])

@spec find(integer() | String.t() | [integer() | String.t()], Keyword.t()) ::
  {:ok, [ExIbge.Geography.Microregion.t()]} | {:error, any()}

Get microregion(s) by identifier(s).

Parameters

  • ids - A single integer ID or a list of integer IDs.
  • query - Optional parameters supported by the API.

Examples

iex> ExIbge.Locality.Microregion.find(33007)
{:ok, [%ExIbge.Geography.Microregion{id: 33007, name: "Nova Friburgo", ...}]}

See Also

IBGE API: Microrregião por ID

find!(ids, query \\ [])

@spec find!(integer() | String.t() | [integer() | String.t()], Keyword.t()) :: [
  ExIbge.Geography.Microregion.t()
]

Same as find/2, but raises an error on failure.

get_by_mesoregion(mesoregion_ids, query \\ [])

@spec get_by_mesoregion(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) ::
  {:ok, [ExIbge.Geography.Microregion.t()]} | {:error, any()}

Get microregions by mesoregion identifier(s).

Parameters

  • mesoregion_ids - A single integer ID or a list of integer IDs.
  • query - Optional parameters supported by the API.

Examples

iex> ExIbge.Locality.Microregion.get_by_mesoregion(3303)
{:ok, [%ExIbge.Geography.Microregion{...}, ...]}

See Also

IBGE API: Microrregiões por Mesorregião

get_by_mesoregion!(mesoregion_ids, query \\ [])

@spec get_by_mesoregion!(
  integer() | String.t() | [integer() | String.t()],
  Keyword.t()
) :: [
  ExIbge.Geography.Microregion.t()
]

Same as get_by_mesoregion/2, but raises an error on failure.

get_by_region(region_ids, query \\ [])

@spec get_by_region(integer() | String.t() | [integer() | String.t()], Keyword.t()) ::
  {:ok, [ExIbge.Geography.Microregion.t()]} | {:error, any()}

Get microregions by region identifier(s).

Parameters

  • region_ids - A single integer ID or a list of integer IDs (1-5).
  • query - Optional parameters supported by the API.

Examples

iex> ExIbge.Locality.Microregion.get_by_region(3)
{:ok, [%ExIbge.Geography.Microregion{...}, ...]}

See Also

IBGE API: Microrregiões por Região

get_by_region!(region_ids, query \\ [])

@spec get_by_region!(integer() | String.t() | [integer() | String.t()], Keyword.t()) ::
  [
    ExIbge.Geography.Microregion.t()
  ]

Same as get_by_region/2, but raises an error on failure.

get_by_state(uf_ids, query \\ [])

@spec get_by_state(
  integer() | atom() | String.t() | [integer() | atom() | String.t()],
  Keyword.t()
) :: {:ok, [ExIbge.Geography.Microregion.t()]} | {:error, any()}

Get microregions by state identifier(s).

Parameters

  • uf_ids - A single identifier or list of identifiers (Integer ID or Atom UFs).
  • query - Optional parameters supported by the API.

Examples

iex> ExIbge.Locality.Microregion.get_by_state(33)
{:ok, [%ExIbge.Geography.Microregion{...}, ...]}

iex> ExIbge.Locality.Microregion.get_by_state(:rj)
{:ok, [%ExIbge.Geography.Microregion{...}, ...]}

See Also

IBGE API: Microrregiões por UF

get_by_state!(uf_ids, query \\ [])

@spec get_by_state!(
  integer() | atom() | String.t() | [integer() | atom() | String.t()],
  Keyword.t()
) :: [ExIbge.Geography.Microregion.t()]

Same as get_by_state/2, but raises an error on failure.