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
impl CoinbaseRawHttpClient
Sourcepub fn new(
environment: CoinbaseEnvironment,
timeout_secs: u64,
proxy_url: Option<String>,
retry_config: Option<RetryConfig>,
) -> Result<Self, HttpClientError>
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.
Sourcepub fn with_credentials(
credential: CoinbaseCredential,
environment: CoinbaseEnvironment,
timeout_secs: u64,
proxy_url: Option<String>,
retry_config: Option<RetryConfig>,
) -> Result<Self, HttpClientError>
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.
Sourcepub fn from_env(environment: CoinbaseEnvironment) -> Result<Self>
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.
Sourcepub fn from_credentials(
api_key: &str,
api_secret: &str,
environment: CoinbaseEnvironment,
timeout_secs: u64,
proxy_url: Option<String>,
retry_config: Option<RetryConfig>,
) -> Result<Self>
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.
Sourcepub fn cancellation_token(&self) -> &CancellationToken
pub fn cancellation_token(&self) -> &CancellationToken
Returns the cancellation token shared by in-flight requests.
Sourcepub fn set_base_url(&self, url: String)
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.
Sourcepub fn environment(&self) -> CoinbaseEnvironment
pub fn environment(&self) -> CoinbaseEnvironment
Returns the configured environment.
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Returns true if this client has credentials for authenticated requests.
Sourcepub async fn get_public(&self, path: &str) -> Result<Value>
pub async fn get_public(&self, path: &str) -> Result<Value>
Sends a GET request to a public endpoint (no auth required).
Sourcepub async fn get_public_with_query(
&self,
path: &str,
query: &str,
) -> Result<Value>
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.
Sourcepub async fn get_with_query(&self, path: &str, query: &str) -> Result<Value>
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.
Sourcepub async fn post(&self, path: &str, body: &Value) -> Result<Value>
pub async fn post(&self, path: &str, body: &Value) -> Result<Value>
Sends an authenticated POST request with a JSON body.
Sourcepub async fn get_products(&self) -> Result<Value>
pub async fn get_products(&self) -> Result<Value>
Gets all available products via the public /market/products endpoint.
Sourcepub async fn get_product(&self, product_id: &str) -> Result<Value>
pub async fn get_product(&self, product_id: &str) -> Result<Value>
Gets a specific product by ID via the public endpoint.
Sourcepub async fn get_candles(
&self,
product_id: &str,
start: &str,
end: &str,
granularity: &str,
) -> Result<Value>
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.
Sourcepub async fn get_market_trades(
&self,
product_id: &str,
limit: u32,
) -> Result<Value>
pub async fn get_market_trades( &self, product_id: &str, limit: u32, ) -> Result<Value>
Gets market trades for a product via the public endpoint.
Sourcepub async fn get_best_bid_ask(&self, product_ids: &[&str]) -> Result<Value>
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.
Sourcepub async fn get_product_book(
&self,
product_id: &str,
limit: Option<u32>,
) -> Result<Value>
pub async fn get_product_book( &self, product_id: &str, limit: Option<u32>, ) -> Result<Value>
Gets the product order book via the public endpoint.
Sourcepub async fn get_accounts(&self) -> Result<Value>
pub async fn get_accounts(&self) -> Result<Value>
Gets all accounts.
Sourcepub async fn get_accounts_with_query(&self, query: &str) -> Result<Value>
pub async fn get_accounts_with_query(&self, query: &str) -> Result<Value>
Gets accounts with a query string (for pagination via cursor / limit).
Sourcepub async fn get_account(&self, account_id: &str) -> Result<Value>
pub async fn get_account(&self, account_id: &str) -> Result<Value>
Gets a specific account by UUID.
Sourcepub async fn get_portfolios(&self) -> Result<Value>
pub async fn get_portfolios(&self) -> Result<Value>
Lists all portfolios visible to the authenticated key.
Sourcepub async fn get_orders(&self, query: &str) -> Result<Value>
pub async fn get_orders(&self, query: &str) -> Result<Value>
Gets historical orders.
Sourcepub async fn get_transaction_summary(&self) -> Result<Value>
pub async fn get_transaction_summary(&self) -> Result<Value>
Gets fee transaction summary.
Sourcepub async fn get_cfm_balance_summary(&self) -> Result<CfmBalanceSummaryResponse>
pub async fn get_cfm_balance_summary(&self) -> Result<CfmBalanceSummaryResponse>
Gets the CFM (Coinbase Financial Markets) futures balance summary.
§References
Sourcepub async fn get_cfm_positions(&self) -> Result<CfmPositionsResponse>
pub async fn get_cfm_positions(&self) -> Result<CfmPositionsResponse>
Gets all CFM futures positions for the account.
§References
Sourcepub async fn get_cfm_position(
&self,
product_id: &str,
) -> Result<CfmPositionResponse>
pub async fn get_cfm_position( &self, product_id: &str, ) -> Result<CfmPositionResponse>
Gets a single CFM futures position by product ID.
§References
Sourcepub async fn fetch_all_accounts(&self) -> Result<Vec<Account>>
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].
Sourcepub async fn fetch_all_orders(
&self,
query: &OrderListQuery,
) -> Result<Vec<Order>>
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.
Sourcepub async fn fetch_all_fills(&self, query: &FillListQuery) -> Result<Vec<Fill>>
pub async fn fetch_all_fills(&self, query: &FillListQuery) -> Result<Vec<Fill>>
Fetches every fill matching the query, following cursor pagination.
Sourcepub async fn create_order(
&self,
request: &CreateOrderRequest,
) -> Result<CreateOrderResponse>
pub async fn create_order( &self, request: &CreateOrderRequest, ) -> Result<CreateOrderResponse>
Creates a new order via POST /orders.
§References
Sourcepub async fn cancel_orders(
&self,
request: &CancelOrdersRequest,
) -> Result<CancelOrdersResponse>
pub async fn cancel_orders( &self, request: &CancelOrdersRequest, ) -> Result<CancelOrdersResponse>
Cancels one or more orders via POST /orders/batch_cancel.
§References
Sourcepub async fn edit_order(
&self,
request: &EditOrderRequest,
) -> Result<EditOrderResponse>
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§
Auto Trait Implementations§
impl !Freeze for CoinbaseRawHttpClient
impl !RefUnwindSafe for CoinbaseRawHttpClient
impl Send for CoinbaseRawHttpClient
impl Sync for CoinbaseRawHttpClient
impl Unpin for CoinbaseRawHttpClient
impl UnsafeUnpin for CoinbaseRawHttpClient
impl !UnwindSafe for CoinbaseRawHttpClient
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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