PublicClient

Struct PublicClient 

Source
pub struct PublicClient { /* private fields */ }
Expand description

`PublicClient provides public market data

Implementations§

Source§

impl PublicClient

Source

pub fn new() -> Self

Creates a PublicClient

let client = PublicClient::new();
Source

pub fn new_sandbox() -> Self

Creates a PublicClient to be used with the coinbase pro sandbox API

let client = PublicClient::new();
Source

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();
Source

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();
Source

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();
Source

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();
Source

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();
Source

pub async fn get_product_ticker( &self, id: &str, before: Option<&str>, after: Option<&str>, limit: Option<u16>, ) -> Result<Ticker, Error>

Get snapshot information about the last trade (tick), best bid/ask and 24h volume.
api docs
This request is paginated

let client = PublicClient::new();
let ticker = client
    .get_product_ticker("BTC-USD", Some("30902419"), None, None)
    .await
    .unwrap();    
Source

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();
Source

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();
Source

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();
Source

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();
Source

pub async fn get_currency(&self, id: &str) -> Result<Currency, Error>

Get the currency for specified id
api docs

let client = PublicClient::new();
let currency = client.get_currency("LINK").await.unwrap();
Source

pub async fn get_time(&self) -> Result<Time, Error>

Get the API server time
api docs

let client = PublicClient::new();
let time = client.get_time().await.unwrap();

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,