Brasilapi.Ddd.API (BrasilAPI v0.1.5)

View Source

Client for BrasilAPI DDD endpoints.

Provides functions to fetch information about Brazilian area codes (DDD) including the state and cities that use the specified area code.

Summary

Functions

Fetches information about a DDD (area code).

Functions

get_by_ddd(ddd)

@spec get_by_ddd(String.t() | integer()) ::
  {:ok, Brasilapi.Ddd.Info.t()} | {:error, map()}

Fetches information about a DDD (area code).

DDD means "Discagem Direta à Distância" (Direct Distance Dialing). It's an automatic telephone connection system between different national urban areas. The DDD is a 2-digit code that identifies the main cities in the country.

Parameters

  • ddd - The DDD (area code) as string or integer. Must be 2 digits.

Examples

iex> Brasilapi.Ddd.API.get_by_ddd(11)
{:ok, %Brasilapi.Ddd.Info{
  state: "SP",
  cities: ["EMBU", "VÁRZEA PAULISTA", "SÃO PAULO"]
}}

iex> Brasilapi.Ddd.API.get_by_ddd(99)
{:error, %{status: 404, message: "DDD não encontrado"}}