This library is no longer being maintained. Please see this repo for a more up to date and maintained library.
This project is meant to offer the user a helpful wrapper around various cryptocurrency APIs, so you don't have to worry about the low-level details. The initial focus is on centralised exchange APIs.
The following exchanges are covered:
- Binance
- BitcoinVN
- Bitflyer
- Bithumb
- Bitkub
- Bitstamp
- Blinktrade
- Coinbase
- Coinfloor
- CoinsPH
- CryptoMkt
- FTX
- IndependentReserve
- Indodax
- Kraken
- LocalBitcoins
- NairaEx
- Remitano
- Satang
- Upbit
- Zaif
Pair can be any one of the following formats (using "BTCUSD" as an example):
{:BTC, :USD}
{:BTC, "USD"}
{"BTC", :USD}
"BTCUSD"
:BTCUSD
history(opts \\ [])
prices(opts \\ [])
volume(currency, timeframe, opts \\ [])
bank_accounts(opts \\ [])
constraints(opts \\ [])
order_book(pair, opts \\ [])
ticker(pair, opts \\ [])
trades(pair, params \\ [], opts \\ [])
markets(opts \\ [])
order_book_status(opts \\ [])
exchange_status(opts \\ [])
chats(params \\ [], opts \\ [])
order_book(pair, opts \\ [])
ticker(pair, opts \\ [])
trades(pair, opts \\ [])
asset_status(crypto, opts \\ [])
btci(opts \\ [])
order_book(pair, limit \\ 100, opts \\ [])
bids(pair, limit \\ 100, opts \\ [])
asks(pair, limit \\ 100, opts \\ [])
ticker(pair \\ nil, opts \\ [])
trades(pair, limit \\ 100, opts \\ [])
depth(pair, limit \\ 100, opts \\ [])
status(opts \\ [])
server_time(opts \\ [])
symbols(opts \\ [])
order_book(pair, opts \\ [])
ticker(pair, opts \\ [])
hourly_ticker(pair, opts \\ [])
trades(pair, opts \\ [])
pairs(opts \\ [])
ohlc(pair, params \\ [], opts \\ [])
order_book(pair, level \\ nil, opts \\ [])
ticker(pair, opts \\ [])
trades(pair, opts \\ [])
pairs(opts \\ [])
pair(pair, opts \\ [])
historic_rates(pair, opts \\ [])
stats_24h(pair, opts \\ [])
currencies(opts \\ [])
currency(code, opts \\ [])
server_time(opts \\ [])
order_book(pair, opts \\ [])
ticker(pair, opts \\ [])
trades(pair, time \\ nil, opts \\ [])
rates(pair \\ nil, region \\ nil, opts \\ [])
order_book(pair, order_type, params \\ [], opts \\ [])
ticker(pair, opts \\ [])
trades(pair, params \\ [], opts \\ [])
markets(opts \\ [])
prices(pair, timeframe, params \\ [], opts \\ [])
order_book(pair, opts \\ [])
market_summary(pair, opts \\ [])
all_orders(pair, opts \\ [])
recent_trades(pair, num_trades, opts \\ [])
trade_history(pair, hours_in_past, opts \\ [])
cryptos(opts \\ [])
fiats(opts \\ [])
limit_order_types(opts \\ [])
market_order_types(opts \\ [])
order_types(opts \\ [])
transaction_types(opts \\ [])
fx_rates(opts \\ [])
minimum_volumes(opts \\ [])
withdrawal_fees(opts \\ [])
order_book(pair, opts \\ [])
ticker(pair, opts \\ [])
pairs(opts \\ [])
server_time(opts \\ [])
price_increments(opts \\ [])
summaries(opts \\ [])
ticker_all(opts \\ [])
trades(pair, opts \\ [])
asset_pairs(opts \\ [])
assets(opts \\ [])
ohlc(pair, opts \\ [])
order_book(pair, opts \\ [])
server_time(opts \\ [])
spread(pair, opts \\ [])
system_status(opts \\ [])
ticker(pair, opts \\ [])
trades(pair, opts \\ [])
rates(opts \\ [])
order_book(pair, params \\ [], opts \\ [])
trades(pair, params \\ [], opts \\ [])
volume(opts \\ [])
currencies(opts \\ [])
markets(opts \\ [])
exchange_info(opts \\ [])
order_book(pair, params \\ [], opts \\ [])
aggregate_trades(pair, params \\ [], opts \\ [])
ticker(pair \\ nil, params \\ [], opts \\ [])
order_book(pair, opts \\ [])
markets(opts \\ [])
ticker(pair, opts \\ [])
trades(pair, params \\ [], opts \\ [])
currency_info(crypto, opts \\ [])
pair_info(pair, opts \\ [])
last_price(pair, opts \\ [])
ticker(pair, opts \\ [])
trades(pair, opts \\ [])
order_book(pair, opts \\ [])
Under the hood, requests are made with HTTPoison. All requests accept an optional list of options
, which expects 3 keys, all optional. headers
and options
are passed straight through to HTTPoison
. params
is merged into options
.
For convenience, JSON responses are automatically decoded, and any response status code not in the OK range is regarded as an error.
Return values follow typical conventions. For example, Kraken.assets
should return an {:ok, response}
or an {:error, response}
tuple.
defmodule YourModule do
alias CryptoApis.Kraken
def get_recent_trades(pair) do
{:ok, response} = Kraken.trades(pair)
do_something(response.body)
end
end
If available in Hex, the package can be installed
by adding crypto_apis
to your list of dependencies in mix.exs
:
def deps do
[
{:crypto_apis, "~> 0.1.0"}
]
end