pub struct PublicClient { /* private fields */ }Expand description
`PublicClient provides public market data
Implementations§
Source§impl PublicClient
impl PublicClient
Sourcepub fn new_sandbox() -> Self
pub fn new_sandbox() -> Self
Creates a PublicClient to be used with the coinbase pro sandbox API
let client = PublicClient::new();Sourcepub async fn get_products(&self) -> Result<Vec<Product>, Error>
pub async fn get_products(&self) -> Result<Vec<Product>, Error>
Get a list of available currency pairs for trading
api docs
let client = PublicClient::new();
let products = client.get_products().await.unwrap();Sourcepub async fn get_product(&self, id: &str) -> Result<Product, Error>
pub async fn get_product(&self, id: &str) -> Result<Product, Error>
Get market data for a specific currency pair.
api docs
let client = PublicClient::new();
let product = client.get_product("BTC-USD").await.unwrap();Sourcepub async fn get_product_order_book(
&self,
id: &str,
) -> Result<OrderBook<BookEntry>, Error>
pub async fn get_product_order_book( &self, id: &str, ) -> Result<OrderBook<BookEntry>, Error>
Get a list of open orders for a product
Gets only the best bid and ask
api docs
let client = PublicClient::new();
let order_book = client.get_product_order_book("BTC-USD").await.unwrap();Sourcepub async fn get_product_order_book_top50(
&self,
id: &str,
) -> Result<OrderBook<BookEntry>, Error>
pub async fn get_product_order_book_top50( &self, id: &str, ) -> Result<OrderBook<BookEntry>, Error>
Get a list of open orders for a product
Gets top 50 bids and asks
api docs
let client = PublicClient::new();
let order_book = client
.get_product_order_book_top50("BTC-USD")
.await
.unwrap();Sourcepub async fn get_product_order_book_all(
&self,
id: &str,
) -> Result<OrderBook<FullBookEntry>, Error>
pub async fn get_product_order_book_all( &self, id: &str, ) -> Result<OrderBook<FullBookEntry>, Error>
Get a list of open orders for a product
Get Full order book
api docs
let client = PublicClient::new();
let order_book = client.get_product_order_book_all("BTC-USD").await.unwrap();Sourcepub async fn get_product_ticker(
&self,
id: &str,
before: Option<&str>,
after: Option<&str>,
limit: Option<u16>,
) -> Result<Ticker, Error>
pub async fn get_product_ticker( &self, id: &str, before: Option<&str>, after: Option<&str>, limit: Option<u16>, ) -> Result<Ticker, Error>
Sourcepub async fn get_product_trades(
&self,
id: &str,
before: Option<&str>,
after: Option<&str>,
limit: Option<u16>,
) -> Result<Vec<Trade>, Error>
pub async fn get_product_trades( &self, id: &str, before: Option<&str>, after: Option<&str>, limit: Option<u16>, ) -> Result<Vec<Trade>, Error>
Get the latest trades for a product.
PARAMETERS
before: Request page before (newer) this pagination id.
after: Request page after (older) this pagination id.
limit: Number of results per request. Maximum 1000. (default 1000)
api docs
This request is paginated
let client = PublicClient::new();
let trades = client
.get_product_trades("BTC-USD", None, Some("30898635"), Some(100))
.await
.unwrap();Sourcepub async fn get_product_historic_rates(
&self,
id: &str,
start: Option<&str>,
end: Option<&str>,
granularity: Option<Granularity>,
) -> Result<Vec<HistoricRate>, Error>
pub async fn get_product_historic_rates( &self, id: &str, start: Option<&str>, end: Option<&str>, granularity: Option<Granularity>, ) -> Result<Vec<HistoricRate>, Error>
get historic rates for a product
PARAMETERS
start: Start time in ISO 8601
end: End time in ISO 8601
granularity: Desired timeslice in seconds
api docs
let client = PublicClient::new();
let historical_rates = client
.get_product_historic_rates("BTC-USD", None, None, Some(Granularity::OneMinute))
.await
.unwrap();Sourcepub async fn get_product_24hr_stats(
&self,
id: &str,
) -> Result<TwentyFourHourStats, Error>
pub async fn get_product_24hr_stats( &self, id: &str, ) -> Result<TwentyFourHourStats, Error>
Get 24 hr stats for the product
api docs
let client = PublicClient::new();
let twenty_four_hour_stats = client.get_product_24hr_stats("BTC-USD").await.unwrap();Sourcepub async fn get_currencies(&self) -> Result<Vec<Currency>, Error>
pub async fn get_currencies(&self) -> Result<Vec<Currency>, Error>
Get known currencies
api docs
let client = PublicClient::new();
let currencies = client.get_currencies().await.unwrap();