pub struct OKXHttpInnerClient { /* private fields */ }
Expand description
Provides a HTTP client for connecting to the OKX REST API.
This client wraps the underlying HttpClient
to handle functionality
specific to OKX, such as request signing (for authenticated endpoints),
forming request URLs, and deserializing responses into specific data models.
Implementations§
Source§impl OKXHttpInnerClient
impl OKXHttpInnerClient
Sourcepub fn new(base_url: Option<String>, timeout_secs: Option<u64>) -> Self
pub fn new(base_url: Option<String>, timeout_secs: Option<u64>) -> Self
Creates a new OKXHttpClient
using the default OKX HTTP URL,
optionally overridden with a custom base URL.
This version of the client has no credentials, so it can only call publicly accessible endpoints.
Sourcepub fn with_credentials(
api_key: String,
api_secret: String,
api_passphrase: String,
base_url: String,
timeout_secs: Option<u64>,
) -> Self
pub fn with_credentials( api_key: String, api_secret: String, api_passphrase: String, base_url: String, timeout_secs: Option<u64>, ) -> Self
Creates a new OKXHttpClient
configured with credentials
for authenticated requests, optionally using a custom base URL.
Sourcepub async fn http_set_position_mode(
&self,
params: SetPositionModeParams,
) -> Result<Vec<Value>, OKXHttpError>
pub async fn http_set_position_mode( &self, params: SetPositionModeParams, ) -> Result<Vec<Value>, OKXHttpError>
Sets the position mode for an account.
§Errors
Returns an error if JSON serialization of params
fails, if the HTTP
request fails, or if the response body cannot be deserialized.
§References
https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-position-mode
Sourcepub async fn http_get_position_tiers(
&self,
params: GetPositionTiersParams,
) -> Result<Vec<OKXPositionTier>, OKXHttpError>
pub async fn http_get_position_tiers( &self, params: GetPositionTiersParams, ) -> Result<Vec<OKXPositionTier>, OKXHttpError>
Requests position tiers information, maximum leverage depends on your borrowings and margin ratio.
§Errors
Returns an error if the HTTP request fails, authentication is rejected or the response cannot be deserialized.
§References
https://www.okx.com/docs-v5/en/#public-data-rest-api-get-position-tiers
Sourcepub async fn http_get_instruments(
&self,
params: GetInstrumentsParams,
) -> Result<Vec<OKXInstrument>, OKXHttpError>
pub async fn http_get_instruments( &self, params: GetInstrumentsParams, ) -> Result<Vec<OKXInstrument>, OKXHttpError>
Requests a list of instruments with open contracts.
§Errors
Returns an error if JSON serialization of params
fails, if the HTTP
request fails, or if the response body cannot be deserialized.
§References
https://www.okx.com/docs-v5/en/#public-data-rest-api-get-instruments
Sourcepub async fn http_get_mark_price(
&self,
params: GetMarkPriceParams,
) -> Result<Vec<OKXMarkPrice>, OKXHttpError>
pub async fn http_get_mark_price( &self, params: GetMarkPriceParams, ) -> Result<Vec<OKXMarkPrice>, OKXHttpError>
Requests a mark price.
We set the mark price based on the SPOT index and at a reasonable basis to prevent individual users from manipulating the market and causing the contract price to fluctuate.
§Errors
Returns an error if the HTTP request fails or if the response body
cannot be parsed into OKXMarkPrice
.
§References
https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price
Sourcepub async fn http_get_index_ticker(
&self,
params: GetIndexTickerParams,
) -> Result<Vec<OKXIndexTicker>, OKXHttpError>
pub async fn http_get_index_ticker( &self, params: GetIndexTickerParams, ) -> Result<Vec<OKXIndexTicker>, OKXHttpError>
Requests the latest index price.
§References
https://www.okx.com/docs-v5/en/#public-data-rest-api-get-index-tickers
Sourcepub async fn http_get_trades(
&self,
params: GetTradesParams,
) -> Result<Vec<OKXTrade>, OKXHttpError>
pub async fn http_get_trades( &self, params: GetTradesParams, ) -> Result<Vec<OKXTrade>, OKXHttpError>
Requests trades history.
§References
https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-trades-history
Sourcepub async fn http_get_candlesticks(
&self,
params: GetCandlesticksParams,
) -> Result<Vec<OKXCandlestick>, OKXHttpError>
pub async fn http_get_candlesticks( &self, params: GetCandlesticksParams, ) -> Result<Vec<OKXCandlestick>, OKXHttpError>
Requests recent candlestick data.
§References
https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-candlesticks
Sourcepub async fn http_get_candlesticks_history(
&self,
params: GetCandlesticksParams,
) -> Result<Vec<OKXCandlestick>, OKXHttpError>
pub async fn http_get_candlesticks_history( &self, params: GetCandlesticksParams, ) -> Result<Vec<OKXCandlestick>, OKXHttpError>
Requests historical candlestick data.
§References
https://www.okx.com/docs-v5/en/#order-book-trading-market-data-get-candlesticks-history
Sourcepub async fn http_get_pending_orders(
&self,
params: GetPendingOrdersParams,
) -> Result<Vec<OKXOrderHistory>, OKXHttpError>
pub async fn http_get_pending_orders( &self, params: GetPendingOrdersParams, ) -> Result<Vec<OKXOrderHistory>, OKXHttpError>
Lists current open orders.
§References
https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-orders-pending
Sourcepub async fn http_get_order(
&self,
params: GetOrderParams,
) -> Result<Vec<OKXOrderHistory>, OKXHttpError>
pub async fn http_get_order( &self, params: GetOrderParams, ) -> Result<Vec<OKXOrderHistory>, OKXHttpError>
Retrieves a single order’s details.
§References
https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order
Sourcepub async fn http_get_balance(&self) -> Result<Vec<OKXAccount>, OKXHttpError>
pub async fn http_get_balance(&self) -> Result<Vec<OKXAccount>, OKXHttpError>
Requests a list of assets (with non-zero balance), remaining balance, and available amount in the trading account.
§References
https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-balance
Sourcepub async fn http_get_order_history(
&self,
params: GetOrderHistoryParams,
) -> Result<Vec<OKXOrderHistory>, OKXHttpError>
pub async fn http_get_order_history( &self, params: GetOrderHistoryParams, ) -> Result<Vec<OKXOrderHistory>, OKXHttpError>
Requests historical order records.
§References
https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-orders-history
Sourcepub async fn http_get_order_list(
&self,
params: GetOrderListParams,
) -> Result<Vec<OKXOrderHistory>, OKXHttpError>
pub async fn http_get_order_list( &self, params: GetOrderListParams, ) -> Result<Vec<OKXOrderHistory>, OKXHttpError>
Requests order list (pending orders).
§References
https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-list
Sourcepub async fn http_get_positions(
&self,
params: GetPositionsParams,
) -> Result<Vec<OKXPosition>, OKXHttpError>
pub async fn http_get_positions( &self, params: GetPositionsParams, ) -> Result<Vec<OKXPosition>, OKXHttpError>
Requests information on your positions. When the account is in net mode, net positions will be displayed, and when the account is in long/short mode, long or short positions will be displayed. Returns in reverse chronological order using ctime.
§References
https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions
Sourcepub async fn http_get_position_history(
&self,
params: GetPositionsHistoryParams,
) -> Result<Vec<OKXPositionHistory>, OKXHttpError>
pub async fn http_get_position_history( &self, params: GetPositionsHistoryParams, ) -> Result<Vec<OKXPositionHistory>, OKXHttpError>
Requests closed or historical position data.
§References
https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history
Sourcepub async fn http_get_transaction_details(
&self,
params: GetTransactionDetailsParams,
) -> Result<Vec<OKXTransactionDetail>, OKXHttpError>
pub async fn http_get_transaction_details( &self, params: GetTransactionDetailsParams, ) -> Result<Vec<OKXTransactionDetail>, OKXHttpError>
Requests transaction details (fills) for the given parameters.
§References
https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-transaction-details-last-3-days
Trait Implementations§
Source§impl Debug for OKXHttpInnerClient
impl Debug for OKXHttpInnerClient
Auto Trait Implementations§
impl Freeze for OKXHttpInnerClient
impl !RefUnwindSafe for OKXHttpInnerClient
impl Send for OKXHttpInnerClient
impl Sync for OKXHttpInnerClient
impl Unpin for OKXHttpInnerClient
impl !UnwindSafe for OKXHttpInnerClient
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