Skip to main content

CoinbaseRawHttpClient

Struct CoinbaseRawHttpClient 

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

Provides a raw HTTP client for low-level Coinbase Advanced Trade REST API operations.

Handles JWT authentication, request construction, and response parsing. Each request generates a fresh ES256 JWT for authentication.

Implementations§

Source§

impl CoinbaseRawHttpClient

Source

pub fn new( environment: CoinbaseEnvironment, timeout_secs: u64, proxy_url: Option<String>, retry_config: Option<RetryConfig>, ) -> Result<Self, HttpClientError>

Creates a new CoinbaseRawHttpClient for public endpoints only.

§Errors

Returns an error if the HTTP client cannot be created.

Source

pub fn with_credentials( credential: CoinbaseCredential, environment: CoinbaseEnvironment, timeout_secs: u64, proxy_url: Option<String>, retry_config: Option<RetryConfig>, ) -> Result<Self, HttpClientError>

Creates a new CoinbaseRawHttpClient with credentials for authenticated requests.

§Errors

Returns an error if the HTTP client cannot be created.

Source

pub fn from_env(environment: CoinbaseEnvironment) -> Result<Self>

Creates an authenticated client from environment variables.

§Errors

Returns Error::Auth if required environment variables are not set.

Source

pub fn from_credentials( api_key: &str, api_secret: &str, environment: CoinbaseEnvironment, timeout_secs: u64, proxy_url: Option<String>, retry_config: Option<RetryConfig>, ) -> Result<Self>

Creates a new CoinbaseRawHttpClient with explicit credentials.

§Errors

Returns Error::Auth if credentials are invalid.

Source

pub fn cancellation_token(&self) -> &CancellationToken

Returns the cancellation token shared by in-flight requests.

Source

pub fn set_base_url(&self, url: String)

Overrides the base REST URL (for testing with mock servers).

Lock-free; safe to call after the client has been cloned.

Source

pub fn environment(&self) -> CoinbaseEnvironment

Returns the configured environment.

Source

pub fn is_authenticated(&self) -> bool

Returns true if this client has credentials for authenticated requests.

Source

pub async fn get_public(&self, path: &str) -> Result<Value>

Sends a GET request to a public endpoint (no auth required).

Source

pub async fn get_public_with_query( &self, path: &str, query: &str, ) -> Result<Value>

Sends a GET request with query parameters to a public endpoint.

Source

pub async fn get(&self, path: &str) -> Result<Value>

Sends an authenticated GET request.

Source

pub async fn get_with_query(&self, path: &str, query: &str) -> Result<Value>

Sends an authenticated GET request with query parameters appended to the path.

The JWT URI claim covers only {METHOD} {host}{path} without the query string, matching the Coinbase SDK convention. Query parameters are appended to the URL but excluded from the signing input.

Source

pub async fn post(&self, path: &str, body: &Value) -> Result<Value>

Sends an authenticated POST request with a JSON body.

Source

pub async fn delete(&self, path: &str) -> Result<Value>

Sends an authenticated DELETE request.

Source

pub async fn get_products(&self) -> Result<Value>

Gets all available products via the public /market/products endpoint.

Source

pub async fn get_product(&self, product_id: &str) -> Result<Value>

Gets a specific product by ID via the public endpoint.

Source

pub async fn get_candles( &self, product_id: &str, start: &str, end: &str, granularity: &str, ) -> Result<Value>

Gets candles for a product via the public endpoint.

Source

pub async fn get_market_trades( &self, product_id: &str, limit: u32, ) -> Result<Value>

Gets market trades for a product via the public endpoint.

Source

pub async fn get_best_bid_ask(&self, product_ids: &[&str]) -> Result<Value>

Gets best bid/ask for one or more products.

No public /market/ equivalent exists for this endpoint; requires authentication.

Source

pub async fn get_product_book( &self, product_id: &str, limit: Option<u32>, ) -> Result<Value>

Gets the product order book via the public endpoint.

Source

pub async fn get_accounts(&self) -> Result<Value>

Gets all accounts.

Source

pub async fn get_accounts_with_query(&self, query: &str) -> Result<Value>

Gets accounts with a query string (for pagination via cursor / limit).

Source

pub async fn get_account(&self, account_id: &str) -> Result<Value>

Gets a specific account by UUID.

Source

pub async fn get_portfolios(&self) -> Result<Value>

Lists all portfolios visible to the authenticated key.

Source

pub async fn get_orders(&self, query: &str) -> Result<Value>

Gets historical orders.

Source

pub async fn get_order(&self, order_id: &str) -> Result<Value>

Gets a specific order by ID.

Source

pub async fn get_fills(&self, query: &str) -> Result<Value>

Gets fills (trade executions).

Source

pub async fn get_transaction_summary(&self) -> Result<Value>

Gets fee transaction summary.

Source

pub async fn get_cfm_balance_summary(&self) -> Result<CfmBalanceSummaryResponse>

Gets the CFM (Coinbase Financial Markets) futures balance summary.

§References
Source

pub async fn get_cfm_positions(&self) -> Result<CfmPositionsResponse>

Source

pub async fn get_cfm_position( &self, product_id: &str, ) -> Result<CfmPositionResponse>

Source

pub async fn fetch_all_accounts(&self) -> Result<Vec<Account>>

Fetches every account, following Coinbase’s cursor pagination.

Returns the deserialized Account vector. Domain callers compose this with parse_account_state to build a Nautilus [AccountState].

Source

pub async fn fetch_all_orders( &self, query: &OrderListQuery, ) -> Result<Vec<Order>>

Fetches every order matching the query, following cursor pagination.

Honors OrderListQuery::client_order_id_filter as a client-side filter applied to each page (the venue endpoint does not accept that parameter directly). Stops once the configured limit is reached.

Source

pub async fn fetch_all_fills(&self, query: &FillListQuery) -> Result<Vec<Fill>>

Fetches every fill matching the query, following cursor pagination.

Source

pub async fn create_order( &self, request: &CreateOrderRequest, ) -> Result<CreateOrderResponse>

Source

pub async fn cancel_orders( &self, request: &CancelOrdersRequest, ) -> Result<CancelOrdersResponse>

Cancels one or more orders via POST /orders/batch_cancel.

§References
Source

pub async fn edit_order( &self, request: &EditOrderRequest, ) -> Result<EditOrderResponse>

Edits an existing order via POST /orders/edit.

Coinbase restricts edits to GTC orders (LIMIT, STOP_LIMIT, Bracket); other order types require cancel-and-replace.

§References

Trait Implementations§

Source§

impl Debug for CoinbaseRawHttpClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> Ungil for T
where T: Send,