Ceramic (Ceramic v0.1.2)

Copy Markdown View Source

Client for the Ceramic REST API (POST /search).

client = Ceramic.new(api_key: System.fetch_env!("CERAMIC_API_KEY"))
{:ok, %Ceramic.SearchResponse{} = response} = Ceramic.search(client, "California rental laws")

new/1 reads CERAMIC_API_KEY and CERAMIC_BASE_URL when the options are absent.

Summary

Functions

Builds a client. Extra options are passed to Req.new/1, so :plug, :retry_delay and friends can be overridden.

Searches the web. query must contain 1 to 50 whitespace-separated words.

Types

client()

@type client() :: Req.Request.t()

Functions

new(opts \\ [])

@spec new(keyword()) :: client()

Builds a client. Extra options are passed to Req.new/1, so :plug, :retry_delay and friends can be overridden.

Options: :api_key, :base_url, :timeout (receive timeout in ms, default 60_000), :max_retries (default 2).

search(client, query, opts \\ [])

@spec search(client(), String.t(), keyword()) ::
  {:ok, Ceramic.SearchResponse.t()} | {:error, Ceramic.Error.t()}

Searches the web. query must contain 1 to 50 whitespace-separated words.

Options: :max_results (1..50), :max_description_length.

Per-request overrides, applied to this call only: :timeout (receive timeout in ms), :extra_headers (map or keyword list), :extra_query (map or keyword list of query params), and :extra_body (map merged over the JSON body, extra values win).

search!(client, query, opts \\ [])

@spec search!(client(), String.t(), keyword()) :: Ceramic.SearchResponse.t()

Same as search/3 but raises Ceramic.Error.