Brasilapi.Client (BrasilAPI v0.1.5)

View Source

HTTP client for BrasilAPI endpoints.

Provides a consistent interface for making HTTP requests to BrasilAPI with proper error handling, retries, and response parsing.

Summary

Functions

Makes a DELETE request to the specified path.

Makes a GET request to the specified path.

Makes a POST request to the specified path.

Makes a PUT request to the specified path.

Types

error_response()

@type error_response() :: {:error, map()}

response()

@type response() :: success_response() | error_response()

success_response()

@type success_response() :: {:ok, term()}

Functions

delete(path, opts \\ [])

@spec delete(
  String.t(),
  keyword()
) :: response()

Makes a DELETE request to the specified path.

Parameters

  • path - The API path (without base URL)
  • opts - Additional options (optional)

get(path, opts \\ [])

@spec get(
  String.t(),
  keyword()
) :: response()

Makes a GET request to the specified path.

Parameters

  • path - The API path (without base URL)
  • opts - Additional options (optional)

Examples

iex> Brasilapi.Client.get("/banks/v1")
{:ok, [%{"ispb" => "00000000", "name" => "BCO DO BRASIL S.A.", ...}]}

iex> Brasilapi.Client.get("/banks/v1/999999")
{:error, %{status: 404, message: "Not found"}}

post(path, body, opts \\ [])

@spec post(String.t(), term(), keyword()) :: response()

Makes a POST request to the specified path.

Parameters

  • path - The API path (without base URL)
  • body - The request body
  • opts - Additional options (optional)

put(path, body, opts \\ [])

@spec put(String.t(), term(), keyword()) :: response()

Makes a PUT request to the specified path.

Parameters

  • path - The API path (without base URL)
  • body - The request body
  • opts - Additional options (optional)