pub struct Client { /* private fields */ }
Expand description
A client for the Bitvavo API.
Implementations§
Source§impl Client
impl Client
Sourcepub async fn time(&self) -> Result<u64>
pub async fn time(&self) -> Result<u64>
Get the current time.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let t = c.time().await.unwrap();
println!("{t}");
Sourcepub async fn assets(&self) -> Result<Vec<Asset>>
pub async fn assets(&self) -> Result<Vec<Asset>>
Get all the assets.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let assets = c.assets().await.unwrap();
println!("Number of assets: {}", assets.len());
Sourcepub async fn asset(&self, symbol: &str) -> Result<Asset>
pub async fn asset(&self, symbol: &str) -> Result<Asset>
Get the info of a particular asset.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let asset = c.asset("BTC").await.unwrap();
println!("Number of decimals used for BTC: {}", asset.decimals);
Sourcepub async fn markets(&self) -> Result<Vec<Market>>
pub async fn markets(&self) -> Result<Vec<Market>>
Get all the markets.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let markets = c.markets().await.unwrap();
println!("Number of markets: {}", markets.len());
Sourcepub async fn market(&self, pair: &str) -> Result<Market>
pub async fn market(&self, pair: &str) -> Result<Market>
Get market information for a specific market.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let market = c.market("BTC-EUR").await.unwrap();
println!("Price precision of BTC-EUR: {}", market.price_precision);
Sourcepub async fn order_book(
&self,
market: &str,
depth: Option<u64>,
) -> Result<OrderBook>
pub async fn order_book( &self, market: &str, depth: Option<u64>, ) -> Result<OrderBook>
Get the order book for a particular market.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let ob = c.order_book("BTC-EUR", Some(2)).await.unwrap();
println!("Number of bids: {}", ob.bids.len());
Sourcepub async fn trades(
&self,
market: &str,
limit: Option<u64>,
start: Option<u64>,
end: Option<u64>,
trade_id_from: Option<String>,
trade_id_to: Option<String>,
) -> Result<Vec<Trade>>
pub async fn trades( &self, market: &str, limit: Option<u64>, start: Option<u64>, end: Option<u64>, trade_id_from: Option<String>, trade_id_to: Option<String>, ) -> Result<Vec<Trade>>
Get the trades for a particular market.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let trades = c.trades("BTC-EUR", None, None, None, None, None).await.unwrap();
println!("Number of trades: {}", trades.len());
Sourcepub async fn candles(
&self,
market: &str,
interval: CandleInterval,
limit: Option<u16>,
start: Option<u64>,
end: Option<u64>,
) -> Result<Vec<OHLCV>>
pub async fn candles( &self, market: &str, interval: CandleInterval, limit: Option<u16>, start: Option<u64>, end: Option<u64>, ) -> Result<Vec<OHLCV>>
Get candles for a particular market.
use bitvavo_api as bitvavo;
use bitvavo::types::CandleInterval;
let c = bitvavo::Client::new();
let cs = c.candles("BTC-EUR", CandleInterval::OneDay, Some(1), None, None).await.unwrap();
println!("High for BTC-EUR at {} was {}", cs[0].time, cs[0].high);
Sourcepub async fn ticker_prices(&self) -> Result<Vec<TickerPrice>>
pub async fn ticker_prices(&self) -> Result<Vec<TickerPrice>>
Get all the tickers.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let ms = c.ticker_prices().await.unwrap();
println!("Number of markets: {}", ms.len());
Sourcepub async fn ticker_price(&self, pair: &str) -> Result<TickerPrice>
pub async fn ticker_price(&self, pair: &str) -> Result<TickerPrice>
Get the ticker for a particular market.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let m = c.ticker_price("BTC-EUR").await.unwrap();
println!("Price for BTC-EUR: {}", m.price.unwrap_or_default());
Sourcepub async fn ticker_books(&self) -> Result<Vec<TickerBook>>
pub async fn ticker_books(&self) -> Result<Vec<TickerBook>>
Retrieve the highest buy and lowest sell prices currently available for all markets.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let tb = c.ticker_books().await.unwrap();
println!("Number of tickers: {}", tb.len());
Sourcepub async fn ticker_book(&self, market: &str) -> Result<TickerBook>
pub async fn ticker_book(&self, market: &str) -> Result<TickerBook>
Retrieve the highest buy and lowest sell prices currently available for a given market.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let tb = c.ticker_book("BTC-EUR").await.unwrap();
println!("Highest buy price for BTC-EUR: {}", tb.ask.unwrap());
Sourcepub async fn tickers_24h(&self) -> Result<Vec<Ticker24h>>
pub async fn tickers_24h(&self) -> Result<Vec<Ticker24h>>
Retrieve high, low, open, last, and volume information for trades for all markets over the previous 24h.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let t24h = c.tickers_24h().await.unwrap();
println!("Number of tickers: {}", t24h.len());
Sourcepub async fn ticker_24h(&self, market: &str) -> Result<Ticker24h>
pub async fn ticker_24h(&self, market: &str) -> Result<Ticker24h>
Retrieve high, low, open, last, and volume information for trades for a given market over the previous 24h.
use bitvavo_api as bitvavo;
let c = bitvavo::Client::new();
let t24h = c.ticker_24h("BTC-EUR").await.unwrap();
println!("24h ask for BTC-EUR: {}", t24h.ask.unwrap());
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more