Brasilapi.Isbn.API (BrasilAPI v0.1.5)

View Source

Client for BrasilAPI ISBN endpoints.

Provides functions to fetch book information by ISBN from multiple providers including CBL, Mercado Editorial, Open Library, and Google Books.

Summary

Functions

Fetches book information by ISBN.

Functions

get_book(isbn, opts \\ [])

@spec get_book(
  String.t(),
  keyword()
) :: {:ok, Brasilapi.Isbn.Book.t()} | {:error, map()}

Fetches book information by ISBN.

Supports both ISBN-10 and ISBN-13 formats, with or without dashes. Returns detailed book information including title, authors, publisher, synopsis, dimensions, and other metadata.

Parameters

  • isbn - The ISBN number (string, with or without dashes)
  • opts - Keyword list of options:
    • :providers - List of provider strings (default: all providers)

Provider Options

Available providers:

  • "cbl" - Câmara Brasileira do Livro
  • "mercado-editorial" - Mercado Editorial
  • "open-library" - Open Library
  • "google-books" - Google Books

If no providers are specified, the API will try all providers and return the response from the fastest one.

Examples

iex> Brasilapi.Isbn.API.get_book("9788545702870")
{:ok, %Brasilapi.Isbn.Book{isbn: "9788545702870", title: "Akira", ...}}

iex> Brasilapi.Isbn.API.get_book("978-85-457-0287-0")
{:ok, %Brasilapi.Isbn.Book{isbn: "9788545702870", title: "Akira", ...}}

iex> Brasilapi.Isbn.API.get_book("9788545702870", providers: ["cbl"])
{:ok, %Brasilapi.Isbn.Book{isbn: "9788545702870", title: "Akira", provider: "cbl", ...}}

iex> Brasilapi.Isbn.API.get_book("1234567890123")
{:error, %{status: 404, message: "ISBN não encontrado"}}

iex> Brasilapi.Isbn.API.get_book("invalid")
{:error, %{message: "Invalid ISBN format. Must be 10 or 13 digits."}}