Blockfrost (Blockfrost v0.2.0) View Source
Blockfrost is an Elixir client for the Blockfrost API.
Each client is a supervision tree, and you can start more than one supervision tree if you want to query more than a network or use more than one project.
For example, if you want to start a Cardano main net and an IPFS client:
defmodule MyApp.Application do
def start(_type, _args) do
children = [
{Blockfrost, [
network: :cardano_mainnet,
name: CardanoMainNet,
api_key: System.get_env("CARDANO_API_KEY"),
retry_enabled?: true,
retry_max_attempts: 3
]},
{Blockfrost, [
network: :ipfs,
name: IPFS,
api_key: System.get_env("IPFS_API_KEY"),
retry_enabled?: false
]}
]
Supervisor.start_link(children, strategy: :one_for_one, name: MyApp.Supervisor)
end
endThen you're ready to use your clients:
{:ok, pools} = Blockfrost.Cardano.Pools.list_of_stake_pools(CardanoMainNet)Shared Options
Pagination Options
Unless specified otherwise, all Blockfrost functions that support pagination support the following options:
:page- The page to be fetched. If set to:all, will try to fetch all pages, with retries. If some of the pages fail, the first error is returned. Defaults to1.:count- The number of entries to be returned per page. Must be between 1 and 100. Defaults to100.:order- The ordering of items from the point of view of the blockchain, not the page listing itself. By default, Blockfrost return oldest first, newest last.:max_concurrency- If page was set to:all, sets how many concurrent requests will be made to the Blockfrost API. Defaults to10.
HTTP Options
All Blockfrost API call functions support the following options:
:retry_enabled?- whether it should retry failing requests.:retry_max_attempts- max retry attempts:retry_interval- interval between attempts
If some of these options is not given, they default to the configured values.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Get config from a running Blockfrost client
Starts a Blockfrost supervision tree.
Link to this section Types
Specs
t() :: atom()
The name of a Blockfrost instance
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Get config from a running Blockfrost client
Specs
start_link(Keyword.t()) :: Supervisor.on_start()
Starts a Blockfrost supervision tree.
Required options:
:name- the name of the Blockfrost client. Defaults toBlockfrost:network- the network for this client. Either:cardano_mainnet,cardano_testnetor:ipfs:api_key- Your Blockfrost API key
Other options:
:retry_enabled?- whether it should retry failing requests. Defaults totrue:retry_max_attempts- max retry attempts. Defaults to5.:retry_interval- interval between attempts, in milliseconds. Defaults to500.