Skip to main content

DeribitHttpClient

Struct DeribitHttpClient 

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

HTTP client for Deribit REST API

Implementations§

Source§

impl DeribitHttpClient

Source

pub fn new() -> Self

Create a new HTTP client

Source

pub fn with_config(config: HttpConfig) -> Self

Create a new HTTP client with custom configuration

Source

pub fn config(&self) -> &HttpConfig

Get the configuration

Source

pub fn base_url(&self) -> &str

Get the base URL

Source

pub fn http_client(&self) -> &Client

Get the HTTP client

Source

pub async fn make_request(&self, url: &str) -> Result<Response, HttpError>

Make a rate-limited HTTP request

Source

pub async fn make_authenticated_request( &self, url: &str, ) -> Result<Response, HttpError>

Make an authenticated HTTP GET request for private endpoints

Source

pub async fn make_authenticated_post_request<T: Serialize>( &self, url: &str, body: &T, ) -> Result<Response, HttpError>

Make an authenticated HTTP POST request for private endpoints

Source

pub fn rate_limiter(&self) -> &RateLimiter

Get rate limiter for advanced usage

Source

pub async fn public_get<T>( &self, endpoint: &str, query: &str, ) -> Result<T, HttpError>

Generic helper for public GET endpoints.

Performs a rate-limited GET request to a public endpoint, parses the API response, and extracts the result. Handles all standard error cases: network errors, HTTP errors, API errors, and missing results.

§Arguments
  • endpoint - The API endpoint path (e.g., “/public/get_currencies”)
  • query - Query string including leading “?” if non-empty, or empty string
§Type Parameters
  • T - The expected result type, must implement DeserializeOwned
§Errors

Returns HttpError if the request fails at any stage.

Source

pub async fn private_get<T>( &self, endpoint: &str, query: &str, ) -> Result<T, HttpError>

Generic helper for private GET endpoints.

Performs a rate-limited, authenticated GET request to a private endpoint, parses the API response, and extracts the result. Handles all standard error cases: authentication errors, network errors, HTTP errors, API errors, and missing results.

§Arguments
  • endpoint - The API endpoint path (e.g., “/private/get_account_summary”)
  • query - Query string including leading “?” if non-empty, or empty string
§Type Parameters
  • T - The expected result type, must implement DeserializeOwned
§Errors

Returns HttpError if the request fails at any stage.

Source

pub async fn exchange_token( &self, refresh_token: &str, subject_id: u64, scope: Option<&str>, ) -> Result<AuthToken, HttpError>

Exchange refresh token for a new access token with different subject_id

Source

pub async fn fork_token( &self, refresh_token: &str, session_name: &str, scope: Option<&str>, ) -> Result<AuthToken, HttpError>

Fork a token to create a new session with the same permissions

Source§

impl DeribitHttpClient

Private endpoints implementation

Source

pub async fn get_subaccounts( &self, with_portfolio: Option<bool>, ) -> Result<Vec<Subaccount>, HttpError>

Get subaccounts

Retrieves the list of subaccounts associated with the main account.

§Arguments
  • with_portfolio - Include portfolio information (optional)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let subaccounts = client.get_subaccounts(Some(true)).await?;
// tracing::info!("Found {} subaccounts", subaccounts.len());
Source

pub async fn get_subaccounts_details( &self, currency: &str, with_open_orders: Option<bool>, ) -> Result<Vec<SubaccountDetails>, HttpError>

Get subaccounts details with positions

Retrieves position details for all subaccounts for a specific currency. Returns positions aggregated across all subaccounts, including size, average entry price, mark price, and P&L information.

§Arguments
  • currency - Currency symbol (BTC, ETH, USDC, etc.)
  • with_open_orders - Include open orders for each subaccount (optional)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let details = client.get_subaccounts_details("BTC", Some(true)).await?;
Source

pub async fn create_subaccount(&self) -> Result<Subaccount, HttpError>

Create a new subaccount

Creates a new subaccount under the main account.

§Returns

Returns the newly created Subaccount with its details.

§Errors

Returns HttpError if the request fails or if the user is not a main account.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let subaccount = client.create_subaccount().await?;
// tracing::info!("Created subaccount with ID: {}", subaccount.id);
Source

pub async fn remove_subaccount( &self, subaccount_id: u64, ) -> Result<String, HttpError>

Remove an empty subaccount

Removes a subaccount that has no open positions or pending orders.

§Arguments
  • subaccount_id - The ID of the subaccount to remove
§Returns

Returns "ok" on success.

§Errors

Returns HttpError if the request fails or if the subaccount is not empty.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let result = client.remove_subaccount(123).await?;
// assert_eq!(result, "ok");
Source

pub async fn change_subaccount_name( &self, sid: u64, name: &str, ) -> Result<String, HttpError>

Change the name of a subaccount

Updates the username for a subaccount.

§Arguments
  • sid - The subaccount ID
  • name - The new username for the subaccount
§Returns

Returns "ok" on success.

§Errors

Returns HttpError if the request fails.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let result = client.change_subaccount_name(123, "new_name").await?;
// assert_eq!(result, "ok");
Source

pub async fn toggle_subaccount_login( &self, sid: u64, state: &str, ) -> Result<String, HttpError>

Enable or disable login for a subaccount

Toggles whether a subaccount can log in. If login is disabled and a session for the subaccount exists, that session will be terminated.

§Arguments
  • sid - The subaccount ID
  • state - Either "enable" or "disable"
§Returns

Returns "ok" on success.

§Errors

Returns HttpError if the request fails.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let result = client.toggle_subaccount_login(123, "enable").await?;
// assert_eq!(result, "ok");
Source

pub async fn set_email_for_subaccount( &self, sid: u64, email: &str, ) -> Result<String, HttpError>

Set email address for a subaccount

Assigns an email address to a subaccount. The user will receive an email with a confirmation link.

§Arguments
  • sid - The subaccount ID
  • email - The email address to assign
§Returns

Returns "ok" on success.

§Errors

Returns HttpError if the request fails.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let result = client.set_email_for_subaccount(123, "user@example.com").await?;
// assert_eq!(result, "ok");
Source

pub async fn toggle_notifications_from_subaccount( &self, sid: u64, state: bool, ) -> Result<String, HttpError>

Enable or disable notifications for a subaccount

Toggles whether the main account receives notifications from a subaccount.

§Arguments
  • sid - The subaccount ID
  • state - true to enable notifications, false to disable
§Returns

Returns "ok" on success.

§Errors

Returns HttpError if the request fails.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let result = client.toggle_notifications_from_subaccount(123, true).await?;
// assert_eq!(result, "ok");
Source

pub async fn get_transaction_log( &self, request: TransactionLogRequest, ) -> Result<TransactionLogResponse, HttpError>

Get transaction log

Retrieves transaction log entries for the account.

§Arguments
  • request - A TransactionLogRequest struct containing:
    • currency - Currency symbol (BTC, ETH, etc.)
    • start_timestamp - Start timestamp in milliseconds (optional)
    • end_timestamp - End timestamp in milliseconds (optional)
    • count - Number of requested items (optional, default 10)
    • continuation - Continuation token for pagination (optional)
§Examples
use deribit_http::DeribitHttpClient;
use crate::model::TransactionLogRequest;

let client = DeribitHttpClient::new();
// let request = TransactionLogRequest { currency: "BTC".into(), ..Default::default() };
// let log = client.get_transaction_log(request).await?;
Source

pub async fn get_deposits( &self, currency: &str, count: Option<u32>, offset: Option<u32>, ) -> Result<DepositsResponse, HttpError>

Get deposits

Retrieves the latest user deposits.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • count - Number of requested items (optional, default 10)
  • offset - Offset for pagination (optional, default 0)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let deposits = client.get_deposits("BTC", Some(20), Some(0)).await?;
// tracing::info!("Found {} deposits", deposits.data.len());
Source

pub async fn get_withdrawals( &self, currency: &str, count: Option<u32>, offset: Option<u32>, ) -> Result<WithdrawalsResponse, HttpError>

Get withdrawals

Retrieves the latest user withdrawals.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • count - Number of requested items (optional, default 10)
  • offset - Offset for pagination (optional, default 0)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let withdrawals = client.get_withdrawals("BTC", Some(20), Some(0)).await?;
// tracing::info!("Found {} withdrawals", withdrawals.data.len());
Source

pub async fn submit_transfer_to_subaccount( &self, currency: &str, amount: f64, destination: u64, ) -> Result<TransferResultResponse, HttpError>

Submit transfer to subaccount

Transfers funds to a subaccount.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • amount - Amount of funds to be transferred
  • destination - ID of destination subaccount
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let transfer = client.submit_transfer_to_subaccount("BTC", 0.001, 123).await?;
// tracing::info!("Transfer ID: {}", transfer.id);
Source

pub async fn submit_transfer_to_user( &self, currency: &str, amount: f64, destination: &str, ) -> Result<TransferResultResponse, HttpError>

Submit transfer to user

Transfers funds to another user.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • amount - Amount of funds to be transferred
  • destination - Destination wallet address from address book
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let transfer = client.submit_transfer_to_user("ETH", 0.1, "0x1234...").await?;
// tracing::info!("Transfer ID: {}", transfer.id);
Source

pub async fn get_transfers( &self, currency: &str, count: Option<u32>, offset: Option<u32>, ) -> Result<TransfersResponse, HttpError>

Get transfers list

Retrieves the user’s internal transfers (between subaccounts or to other users).

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • count - Number of transfers to retrieve (1-1000, default 10)
  • offset - Offset for pagination (default 0)
§Returns

Returns a TransfersResponse containing the total count and list of transfers.

§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let transfers = client.get_transfers("BTC", Some(10), None).await?;
// tracing::info!("Found {} transfers", transfers.count);
Source

pub async fn cancel_transfer_by_id( &self, currency: &str, id: i64, ) -> Result<InternalTransfer, HttpError>

Cancel a transfer by ID

Cancels a pending internal transfer.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • id - Transfer ID to cancel
§Returns

Returns the cancelled InternalTransfer.

§Errors

Returns HttpError if the transfer cannot be cancelled or does not exist.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let transfer = client.cancel_transfer_by_id("BTC", 123).await?;
// tracing::info!("Cancelled transfer: {:?}", transfer.state);
Source

pub async fn submit_transfer_between_subaccounts( &self, currency: &str, amount: f64, destination: i64, source: Option<i64>, ) -> Result<InternalTransfer, HttpError>

Submit transfer between subaccounts

Transfers funds between two subaccounts or between a subaccount and the main account.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • amount - Amount of funds to transfer
  • destination - Destination subaccount ID
  • source - Source subaccount ID (optional, defaults to requesting account)
§Returns

Returns the created InternalTransfer.

§Errors

Returns HttpError if the transfer fails or validation fails.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let transfer = client.submit_transfer_between_subaccounts("ETH", 1.5, 20, Some(10)).await?;
// tracing::info!("Transfer ID: {}", transfer.id);
Source

pub async fn buy_order( &self, request: OrderRequest, ) -> Result<OrderResponse, HttpError>

Place a buy order

Places a buy order for the specified instrument.

§Arguments
  • request - The buy order request parameters
Source

pub async fn sell_order( &self, request: OrderRequest, ) -> Result<OrderResponse, HttpError>

Place a sell order

Places a sell order for the specified instrument.

§Arguments
  • request - The sell order request parameters
Source

pub async fn cancel_order( &self, order_id: &str, ) -> Result<OrderInfoResponse, HttpError>

Cancel an order

Cancels an order by its ID.

§Arguments
  • order_id - The order ID to cancel
Source

pub async fn cancel_all(&self) -> Result<u32, HttpError>

Cancel all orders

Cancels all orders for the account.

§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_all_by_currency( &self, currency: &str, ) -> Result<u32, HttpError>

Cancel all orders by currency

Cancels all orders for the specified currency.

§Arguments
  • currency - Currency to cancel orders for (BTC, ETH, USDC, etc.)
§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_all_by_currency_pair( &self, currency_pair: &str, ) -> Result<u32, HttpError>

Cancel all orders by currency pair

Cancels all orders for the specified currency pair.

§Arguments
  • currency_pair - Currency pair to cancel orders for (e.g., “BTC_USD”)
§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_all_by_instrument( &self, instrument_name: &str, ) -> Result<u32, HttpError>

Cancel all orders by instrument

Cancels all orders for the specified instrument.

§Arguments
  • instrument_name - Instrument name to cancel orders for (e.g., “BTC-PERPETUAL”)
§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_all_by_kind_or_type( &self, kind: Option<&str>, order_type: Option<&str>, ) -> Result<u32, HttpError>

Cancel all orders by kind or type

Cancels all orders for the specified kind or type.

§Arguments
  • kind - Kind of orders to cancel (future, option, spot, etc.) - optional
  • order_type - Type of orders to cancel (limit, market, etc.) - optional
§Returns

Returns the number of cancelled orders.

Source

pub async fn cancel_by_label(&self, label: &str) -> Result<u32, HttpError>

Cancel orders by label

Cancels all orders with the specified label.

§Arguments
  • label - Label of orders to cancel
§Returns

Returns the number of cancelled orders.

Source

pub async fn get_account_summary( &self, currency: &str, extended: Option<bool>, ) -> Result<AccountSummaryResponse, HttpError>

Get account summary

Retrieves account summary information including balance, margin, and other account details.

§Arguments
  • currency - Currency to get summary for (BTC, ETH, USDC, etc.)
  • extended - Whether to include extended information
Source

pub async fn get_account_summaries( &self, subaccount_id: Option<i64>, extended: Option<bool>, ) -> Result<AccountSummariesResponse, HttpError>

Get account summaries for all currencies

Retrieves a per-currency list of account summaries for the authenticated user. Each summary includes balance, equity, available funds, and margin information for each currency. Unlike get_account_summary, this returns data for all currencies at once.

§Arguments
  • subaccount_id - Retrieve summaries for a specific subaccount (optional)
  • extended - Include additional account details (id, username, email, type) (optional)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let summaries = client.get_account_summaries(None, Some(true)).await?;
Source

pub async fn get_positions( &self, currency: Option<&str>, kind: Option<&str>, subaccount_id: Option<i32>, ) -> Result<Vec<Position>, HttpError>

Get positions

Retrieves user positions for the specified currency and kind.

§Arguments
  • currency - Currency filter (BTC, ETH, USDC, etc.) - optional
  • kind - Kind filter (future, option, spot, etc.) - optional
  • subaccount_id - Subaccount ID - optional
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let positions = client.get_positions(Some("BTC"), Some("future"), None).await?;
// println!("Found {} positions", positions.len());
Source

pub async fn get_position( &self, instrument_name: &str, ) -> Result<Vec<Position>, HttpError>

Get position for a specific instrument

Retrieves the current position for the specified instrument.

§Arguments
  • instrument_name - The name of the instrument to get position for
§Returns

Returns a vector of positions for the specified instrument

Source

pub async fn edit_order( &self, request: OrderRequest, ) -> Result<OrderResponse, HttpError>

Edit an order

Edits an existing order.

§Arguments
  • request - The edit order request parameters
Source

pub async fn edit_order_by_label( &self, request: OrderRequest, ) -> Result<OrderResponse, HttpError>

Edit an order by label

Modifies an order identified by its label. This method works only when there is exactly one open order with the specified label.

§Arguments
  • request - The edit order request parameters (must include label and instrument_name)
§Examples
use deribit_http::DeribitHttpClient;
use deribit_http::model::request::order::OrderRequest;

let client = DeribitHttpClient::new();
// let request = OrderRequest {
//     label: Some("my_order_label".to_string()),
//     instrument_name: "BTC-PERPETUAL".to_string(),
//     amount: Some(150.0),
//     price: Some(50111.0),
//     ..Default::default()
// };
// let result = client.edit_order_by_label(request).await?;
Source

pub async fn close_position( &self, instrument_name: &str, order_type: &str, price: Option<f64>, ) -> Result<OrderResponse, HttpError>

Close an existing position

Places a reduce-only order to close an existing position. The order will automatically be set to reduce-only to ensure it only closes the position.

§Arguments
  • instrument_name - Instrument identifier (e.g., “BTC-PERPETUAL”)
  • order_type - Order type: “market” or “limit”
  • price - Optional price for limit orders (required if order_type is “limit”)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// Close position with market order
// let result = client.close_position("BTC-PERPETUAL", "market", None).await?;
// Close position with limit order
// let result = client.close_position("ETH-PERPETUAL", "limit", Some(2500.0)).await?;
Source

pub async fn get_margins( &self, instrument_name: &str, amount: f64, price: f64, ) -> Result<MarginsResponse, HttpError>

Get margin requirements

Calculates margin requirements for a hypothetical order on a given instrument. Returns initial margin and maintenance margin for the specified instrument, quantity, and price.

§Arguments
  • instrument_name - Instrument identifier (e.g., “BTC-PERPETUAL”)
  • amount - Order size (USD for perpetual/inverse, base currency for options/linear)
  • price - Order price
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let margins = client.get_margins("BTC-PERPETUAL", 10000.0, 50000.0).await?;
// println!("Buy margin: {}, Sell margin: {}", margins.buy, margins.sell);
Source

pub async fn get_order_margin_by_ids( &self, ids: &[&str], ) -> Result<Vec<OrderMargin>, HttpError>

Get order margin by IDs

Retrieves the initial margin requirements for one or more orders identified by their order IDs. Initial margin is the amount of funds required to open a position with these orders.

§Arguments
  • ids - Array of order IDs (e.g., [“ETH-349280”, “ETH-349279”])
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let margins = client.get_order_margin_by_ids(&["ETH-349280", "ETH-349279"]).await?;
Source

pub async fn get_order_state_by_label( &self, currency: &str, label: &str, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get order state by label

Retrieves the state of recent orders that have a specific label. Results are filtered by currency and label. The response includes order details such as status, filled amount, remaining amount, and other order properties for all orders with the specified label.

§Arguments
  • currency - Currency symbol (e.g., “BTC”, “ETH”, “USDC”)
  • label - User-defined label (max 64 characters)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let orders = client.get_order_state_by_label("ETH", "myLabel").await?;
Source

pub async fn get_settlement_history_by_currency( &self, currency: &str, settlement_type: Option<&str>, count: Option<u32>, continuation: Option<&str>, search_start_timestamp: Option<u64>, ) -> Result<SettlementsResponse, HttpError>

Get settlement history by currency

Retrieves settlement, delivery, and bankruptcy events that have affected your account for a specific currency. Settlements occur when futures or options contracts expire and are settled at the delivery price.

§Arguments
  • currency - Currency symbol (e.g., “BTC”, “ETH”, “USDC”)
  • settlement_type - Settlement type: “settlement”, “delivery”, or “bankruptcy” (optional)
  • count - Number of items (default 20, max 1000) (optional)
  • continuation - Pagination token (optional)
  • search_start_timestamp - Latest timestamp to return results from in ms (optional)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let history = client.get_settlement_history_by_currency("BTC", None, None, None, None).await?;
Source

pub async fn get_settlement_history_by_instrument( &self, instrument_name: &str, settlement_type: Option<&str>, count: Option<u32>, continuation: Option<&str>, search_start_timestamp: Option<u64>, ) -> Result<SettlementsResponse, HttpError>

Get settlement history by instrument

Retrieves settlement, delivery, and bankruptcy events for a specific instrument that have affected your account. Settlements occur when futures or options contracts expire and are settled at the delivery price.

§Arguments
  • instrument_name - Instrument identifier (e.g., “BTC-PERPETUAL”)
  • settlement_type - Settlement type: “settlement”, “delivery”, or “bankruptcy” (optional)
  • count - Number of items (default 20, max 1000) (optional)
  • continuation - Pagination token (optional)
  • search_start_timestamp - Latest timestamp to return results from in ms (optional)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let history = client.get_settlement_history_by_instrument("BTC-PERPETUAL", None, None, None, None).await?;
Source

pub async fn get_trigger_order_history( &self, currency: &str, instrument_name: Option<&str>, count: Option<u32>, continuation: Option<&str>, ) -> Result<TriggerOrderHistoryResponse, HttpError>

Get trigger order history

Retrieves a detailed log of all trigger orders (stop orders, take-profit orders, etc.) for the authenticated account. The log includes trigger order creation, activation, execution, and cancellation events.

§Arguments
  • currency - Currency symbol (e.g., “BTC”, “ETH”, “USDC”)
  • instrument_name - Filter by specific instrument (optional)
  • count - Number of items (default 20, max 1000) (optional)
  • continuation - Pagination token (optional)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let history = client.get_trigger_order_history("BTC", None, None, None).await?;
Source

pub async fn move_positions( &self, currency: &str, source_uid: i64, target_uid: i64, trades: &[MovePositionTrade], ) -> Result<Vec<MovePositionResult>, HttpError>

Move positions between subaccounts

Moves positions from a source subaccount to a target subaccount. This operation transfers open positions between subaccounts, which is useful for rebalancing or reorganizing trading activities.

Rate Limits: 6 requests/minute, 100 move_position uses per week (168 hours)

Important: In rare cases, the request may return an internal_server_error. This does not necessarily mean the operation failed entirely. Part or all of the position transfer might have still been processed successfully.

§Arguments
  • currency - Currency symbol (e.g., “BTC”, “ETH”, “USDC”)
  • source_uid - Source subaccount ID
  • target_uid - Target subaccount ID
  • trades - List of position trades to move
§Examples
use deribit_http::DeribitHttpClient;
use deribit_http::model::request::position::MovePositionTrade;

let client = DeribitHttpClient::new();
let trades = vec![
    MovePositionTrade::with_price("BTC-PERPETUAL", 110.0, 35800.0),
];
// let results = client.move_positions("BTC", 3, 23, &trades).await?;
Source

pub async fn get_mmp_config( &self, index_name: Option<&str>, mmp_group: Option<&str>, block_rfq: Option<bool>, ) -> Result<Vec<MmpConfig>, HttpError>

Get MMP configuration

Retrieves Market Maker Protection (MMP) configuration for an index. If index_name is not provided, returns all MMP configurations.

§Arguments
  • index_name - Index identifier (e.g., “btc_usd”, “eth_usd”), optional
  • mmp_group - MMP group name for Mass Quotes, optional
  • block_rfq - If true, retrieve MMP config for Block RFQ, optional
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let configs = client.get_mmp_config(Some("btc_usd"), None, None).await?;
Source

pub async fn get_mmp_status( &self, index_name: Option<&str>, mmp_group: Option<&str>, block_rfq: Option<bool>, ) -> Result<Vec<MmpStatus>, HttpError>

Get MMP status

Retrieves Market Maker Protection (MMP) status for a triggered index or MMP group. If index_name is not provided, returns all triggered MMP statuses.

§Arguments
  • index_name - Index identifier (e.g., “btc_usd”, “eth_usd”), optional
  • mmp_group - MMP group name for Mass Quotes, optional
  • block_rfq - If true, retrieve MMP status for Block RFQ, optional
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let statuses = client.get_mmp_status(Some("btc_usd"), None, None).await?;
Source

pub async fn set_mmp_config( &self, request: SetMmpConfigRequest, ) -> Result<MmpConfig, HttpError>

Set MMP configuration

Configures Market Maker Protection (MMP) for a specific index. Set interval to 0 to remove MMP configuration.

§Arguments
  • request - The MMP configuration request
§Examples
use deribit_http::DeribitHttpClient;
use deribit_http::model::response::mmp::SetMmpConfigRequest;

let client = DeribitHttpClient::new();
// let request = SetMmpConfigRequest {
//     index_name: "btc_usd".to_string(),
//     interval: 60,
//     frozen_time: 0,
//     quantity_limit: Some(3.0),
//     max_quote_quantity: Some(2.5),
//     ..Default::default()
// };
// let config = client.set_mmp_config(request).await?;
Source

pub async fn reset_mmp( &self, index_name: &str, mmp_group: Option<&str>, block_rfq: Option<bool>, ) -> Result<String, HttpError>

Reset MMP limits

Resets Market Maker Protection (MMP) limits for the specified currency pair or MMP group. If MMP protection has been triggered and quoting is frozen, this allows manual resume.

§Arguments
  • index_name - Currency pair (e.g., “btc_usd”, “eth_usd”)
  • mmp_group - MMP group name for Mass Quotes, optional
  • block_rfq - If true, reset MMP for Block RFQ, optional
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let result = client.reset_mmp("btc_usd", None, None).await?;
Source

pub async fn mass_quote( &self, _quotes: MassQuoteRequest, ) -> Result<MassQuoteResponse, HttpError>

Mass quote

Places multiple quotes at once.

§Arguments
  • quotes - Vector of mass quote requests
Source

pub async fn get_user_trades_by_instrument( &self, instrument_name: &str, start_seq: Option<u64>, end_seq: Option<u64>, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<UserTradeWithPaginationResponse, HttpError>

Get user trades by instrument

Retrieves user trades for a specific instrument.

§Arguments
  • instrument_name - Instrument name
  • start_seq - Start sequence number (optional)
  • end_seq - End sequence number (optional)
  • count - Number of requested items (optional)
  • include_old - Include old trades (optional)
  • sorting - Direction of results sorting (optional)
Source

pub async fn cancel_quotes( &self, cancel_type: Option<&str>, ) -> Result<u32, HttpError>

Cancel quotes

Cancels all mass quotes.

§Arguments
  • cancel_type - Type of cancellation (“all”, “by_currency”, “by_instrument”, etc.)
Source

pub async fn get_open_orders( &self, kind: Option<&str>, order_type: Option<&str>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get open orders

Retrieves list of user’s open orders across many currencies.

§Arguments
  • kind - Instrument kind filter (optional)
  • order_type - Order type filter (optional)
Source

pub async fn get_open_orders_by_label( &self, label: &str, currency: &str, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get open orders by label

Retrieves open orders filtered by a specific label.

§Arguments
  • label - The label to filter orders by
  • currency - The currency symbol (BTC, ETH, etc.)
Source

pub async fn get_order_state( &self, order_id: &str, ) -> Result<OrderInfoResponse, HttpError>

Get order state

Retrieves the state of a specific order.

§Arguments
  • order_id - The order ID
Source

pub async fn get_open_orders_by_currency( &self, currency: &str, kind: Option<&str>, order_type: Option<&str>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get open orders by currency

Retrieves open orders for a specific currency.

§Arguments
  • currency - The currency symbol (BTC, ETH, etc.)
  • kind - Instrument kind filter (optional)
  • order_type - Order type filter (optional)
Source

pub async fn get_open_orders_by_instrument( &self, instrument_name: &str, order_type: Option<&str>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get open orders by instrument

Retrieves open orders for a specific instrument.

§Arguments
  • instrument_name - The instrument name
  • order_type - Order type filter (optional)
Source

pub async fn get_order_history( &self, currency: &str, kind: Option<&str>, count: Option<u32>, offset: Option<u32>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get order history

Retrieves history of orders that have been partially or fully filled.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • kind - Instrument kind filter (optional)
  • count - Number of requested items (optional, default 20)
  • offset - Offset for pagination (optional)
Source

pub async fn get_order_history_by_currency( &self, currency: &str, kind: Option<&str>, count: Option<u32>, offset: Option<u32>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get order history by currency

Retrieves order history for a specific currency.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
  • kind - Instrument kind filter (optional)
  • count - Number of requested items (optional)
  • offset - Offset for pagination (optional)
Source

pub async fn get_order_history_by_instrument( &self, instrument_name: &str, count: Option<u32>, offset: Option<u32>, ) -> Result<Vec<OrderInfoResponse>, HttpError>

Get order history by instrument

Retrieves order history for a specific instrument.

§Arguments
  • instrument_name - The instrument name
  • count - Number of requested items (optional)
  • offset - Offset for pagination (optional)
Source

pub async fn get_user_trades_by_currency( &self, request: TradesRequest, ) -> Result<UserTradeWithPaginationResponse, HttpError>

Get user trades by currency

Retrieves user trades filtered by currency.

§Arguments
  • request - A TradesRequest struct containing:
    • currency - Currency symbol (BTC, ETH, etc.)
    • kind - Instrument kind filter (optional)
    • start_id - The ID of the first trade to be returned (optional)
    • end_id - The ID of the last trade to be returned (optional)
    • count - Number of requested items (optional, default 10, max 1000)
    • start_timestamp - The earliest timestamp to return results from (optional)
    • end_timestamp - The most recent timestamp to return results from (optional)
    • sorting - Direction of results sorting (optional)
    • historical - If true, retrieves historical records that persist indefinitely. If false (default), retrieves recent records available for 24 hours.
    • subaccount_id - The user id for the subaccount (optional)
Source

pub async fn get_user_trades_by_currency_and_time( &self, request: TradesRequest, ) -> Result<UserTradeWithPaginationResponse, HttpError>

Get user trades by currency and time

Retrieves user trades filtered by currency within a time range.

§Arguments
  • request - A TradesRequest struct containing:
    • currency - Currency symbol (BTC, ETH, etc.)
    • kind - Instrument kind filter (optional)
    • start_id - The ID of the first trade to be returned (optional)
    • end_id - The ID of the last trade to be returned (optional)
    • count - Number of requested items (optional, default 10, max 1000)
    • start_timestamp - The earliest timestamp to return results from (optional)
    • end_timestamp - The most recent timestamp to return results from (optional)
    • sorting - Direction of results sorting (optional)
    • historical - If true, retrieves historical records that persist indefinitely. If false (default), retrieves recent records available for 24 hours.
    • subaccount_id - The user id for the subaccount (optional)
Source

pub async fn get_user_trades_by_instrument_and_time( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<UserTradeWithPaginationResponse, HttpError>

Get user trades by instrument and time

Retrieves user trades for a specific instrument within a time range.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - Start timestamp in milliseconds
  • end_timestamp - End timestamp in milliseconds
  • count - Number of requested items (optional, default 10)
  • include_old - Include trades older than 7 days (optional)
  • sorting - Direction of results sorting (optional)
Source

pub async fn get_user_trades_by_order( &self, order_id: &str, sorting: Option<&str>, historical: bool, ) -> Result<Vec<UserTradeResponseByOrder>, HttpError>

Get user trades by order

Retrieves user trades for a specific order.

§Arguments
  • order_id - Order ID
  • sorting - Direction of results sorting (optional)
Source

pub async fn create_api_key( &self, request: CreateApiKeyRequest, ) -> Result<ApiKeyInfo, HttpError>

Create a new API key

Creates a new API key with the specified scope and optional settings.

§Arguments
  • request - The create API key request parameters
§Returns

Returns the newly created API key information including client_id and client_secret.

§Errors

Returns HttpError if the request fails or authentication is invalid.

§Example
use deribit_http::{DeribitHttpClient, model::CreateApiKeyRequest};

let client = DeribitHttpClient::new();
let request = CreateApiKeyRequest {
    max_scope: "account:read trade:read_write".to_string(),
    name: Some("my_trading_key".to_string()),
    ..Default::default()
};
let api_key = client.create_api_key(request).await?;
println!("Created API key: {}", api_key.client_id);
Source

pub async fn edit_api_key( &self, request: EditApiKeyRequest, ) -> Result<ApiKeyInfo, HttpError>

Edit an existing API key

Modifies an existing API key’s scope, name, or other settings.

§Arguments
  • request - The edit API key request parameters
§Returns

Returns the updated API key information.

§Errors

Returns HttpError if the request fails or the API key is not found.

Source

pub async fn disable_api_key(&self, id: u64) -> Result<ApiKeyInfo, HttpError>

Disable an API key

Disables the API key with the specified ID. The key cannot be used for authentication until it is re-enabled.

§Arguments
  • id - The ID of the API key to disable
§Returns

Returns the updated API key information with enabled set to false.

§Errors

Returns HttpError if the request fails or the API key is not found.

Source

pub async fn enable_api_key(&self, id: u64) -> Result<ApiKeyInfo, HttpError>

Enable an API key

Enables a previously disabled API key with the specified ID.

§Arguments
  • id - The ID of the API key to enable
§Returns

Returns the updated API key information with enabled set to true.

§Errors

Returns HttpError if the request fails or the API key is not found.

Source

pub async fn list_api_keys(&self) -> Result<Vec<ApiKeyInfo>, HttpError>

List all API keys

Retrieves a list of all API keys associated with the account.

§Returns

Returns a vector of API key information.

§Errors

Returns HttpError if the request fails or authentication is invalid.

§Example
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
let api_keys = client.list_api_keys().await?;
for key in api_keys {
    println!("Key ID: {}, Name: {}, Enabled: {}", key.id, key.name, key.enabled);
}
Source

pub async fn remove_api_key(&self, id: u64) -> Result<String, HttpError>

Remove an API key

Permanently removes the API key with the specified ID.

§Arguments
  • id - The ID of the API key to remove
§Returns

Returns "ok" on success.

§Errors

Returns HttpError if the request fails or the API key is not found.

Source

pub async fn reset_api_key(&self, id: u64) -> Result<ApiKeyInfo, HttpError>

Reset an API key secret

Generates a new client_secret for the API key with the specified ID. The old secret will no longer be valid.

§Arguments
  • id - The ID of the API key to reset
§Returns

Returns the updated API key information with the new client_secret.

§Errors

Returns HttpError if the request fails or the API key is not found.

Source

pub async fn change_api_key_name( &self, id: u64, name: &str, ) -> Result<ApiKeyInfo, HttpError>

Change API key name

Changes the name of the API key with the specified ID.

§Arguments
  • id - The ID of the API key
  • name - The new name (only letters, numbers and underscores; max 16 characters)
§Returns

Returns the updated API key information.

§Errors

Returns HttpError if the request fails or the API key is not found.

Source

pub async fn change_scope_in_api_key( &self, id: u64, max_scope: &str, ) -> Result<ApiKeyInfo, HttpError>

Change API key scope

Changes the maximum scope of the API key with the specified ID.

§Arguments
  • id - The ID of the API key
  • max_scope - The new maximum scope (e.g., “account:read trade:read_write”)
§Returns

Returns the updated API key information.

§Errors

Returns HttpError if the request fails or the API key is not found.

Source

pub async fn save_address_beneficiary( &self, request: &SaveAddressBeneficiaryRequest, ) -> Result<AddressBeneficiary, HttpError>

Save address beneficiary information.

Saves beneficiary information for a cryptocurrency address, required for travel rule compliance.

§Arguments
  • request - The beneficiary information to save
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;
use deribit_http::model::SaveAddressBeneficiaryRequest;

let client = DeribitHttpClient::new();
let request = SaveAddressBeneficiaryRequest {
    currency: "BTC".to_string(),
    address: "bc1qtest".to_string(),
    agreed: true,
    personal: false,
    unhosted: false,
    beneficiary_vasp_name: "Test VASP".to_string(),
    beneficiary_vasp_did: "did:test:123".to_string(),
    beneficiary_address: "Test Address".to_string(),
    ..Default::default()
};
// let beneficiary = client.save_address_beneficiary(&request).await?;
Source

pub async fn delete_address_beneficiary( &self, currency: &str, address: &str, tag: Option<&str>, ) -> Result<String, HttpError>

Delete address beneficiary information.

Removes beneficiary information for the specified address.

§Arguments
  • currency - Currency symbol (e.g., “BTC”, “ETH”)
  • address - The cryptocurrency address
  • tag - Optional tag for XRP addresses
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let result = client.delete_address_beneficiary("BTC", "bc1qtest", None).await?;
Source

pub async fn get_address_beneficiary( &self, currency: &str, address: &str, tag: Option<&str>, ) -> Result<AddressBeneficiary, HttpError>

Get address beneficiary information.

Retrieves beneficiary information for the specified address.

§Arguments
  • currency - Currency symbol (e.g., “BTC”, “ETH”)
  • address - The cryptocurrency address
  • tag - Optional tag for XRP addresses
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let beneficiary = client.get_address_beneficiary("BTC", "bc1qtest", None).await?;
Source

pub async fn list_address_beneficiaries( &self, request: Option<&ListAddressBeneficiariesRequest>, ) -> Result<ListAddressBeneficiariesResponse, HttpError>

List address beneficiaries with filtering and pagination.

Returns a paginated list of address beneficiaries with optional filters.

§Arguments
  • request - Optional filtering and pagination parameters
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;
use deribit_http::model::ListAddressBeneficiariesRequest;

let client = DeribitHttpClient::new();
let request = ListAddressBeneficiariesRequest {
    currency: Some("BTC".to_string()),
    limit: Some(10),
    ..Default::default()
};
// let response = client.list_address_beneficiaries(Some(&request)).await?;
Source

pub async fn set_clearance_originator( &self, deposit_id: &DepositId, originator: &Originator, ) -> Result<ClearanceDepositResult, HttpError>

Set clearance originator for a deposit.

Sets the originator information for a deposit transaction, required for travel rule compliance.

§Arguments
  • deposit_id - Identifier of the deposit
  • originator - Information about the originator
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;
use deribit_http::model::{DepositId, Originator};

let client = DeribitHttpClient::new();
let deposit_id = DepositId {
    currency: "BTC".to_string(),
    user_id: 123,
    address: "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz".to_string(),
    tx_hash: "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda".to_string(),
};
let originator = Originator {
    is_personal: false,
    company_name: Some("Company Name".to_string()),
    first_name: Some("First".to_string()),
    last_name: Some("Last".to_string()),
    address: "NL, Amsterdam, Street, 1".to_string(),
};
// let result = client.set_clearance_originator(&deposit_id, &originator).await?;
Source

pub async fn get_access_log( &self, count: Option<u32>, offset: Option<u32>, ) -> Result<AccessLogResponse, HttpError>

Get account access log

Retrieves the account access history showing login attempts and API access.

§Arguments
  • count - Number of entries to retrieve (optional, default 10)
  • offset - Offset for pagination (optional, default 0)
Source

pub async fn get_user_locks(&self) -> Result<Vec<UserLock>, HttpError>

Get user account locks

Retrieves information about any locks on the user’s account.

Source

pub async fn list_custody_accounts( &self, currency: &str, ) -> Result<Vec<CustodyAccount>, HttpError>

List custody accounts

Retrieves the list of custody accounts for the specified currency.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
Source

pub async fn simulate_portfolio( &self, request: SimulatePortfolioRequest, ) -> Result<SimulatePortfolioResponse, HttpError>

Simulate portfolio margin

Simulates portfolio margin for hypothetical positions.

§Arguments
  • request - Simulation request parameters
Source

pub async fn pme_simulate( &self, currency: &str, ) -> Result<PmeSimulateResponse, HttpError>

PME margin simulation

Simulates Portfolio Margin Engine (PME) margin for the specified currency.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
Source

pub async fn change_margin_model( &self, margin_model: MarginModel, user_id: Option<u64>, dry_run: Option<bool>, ) -> Result<ChangeMarginModelResponse, HttpError>

Change margin model

Changes the margin model for the account or a specific user.

§Arguments
  • margin_model - The new margin model to set
  • user_id - Optional user ID (for main account operating on subaccounts)
  • dry_run - Optional flag to simulate the change without applying it
Source

pub async fn set_self_trading_config( &self, mode: SelfTradingMode, extended_to_subaccounts: bool, block_rfq_self_match_prevention: Option<bool>, ) -> Result<bool, HttpError>

Set self-trading configuration

Configures self-trading prevention settings for the account.

§Arguments
  • mode - Self-trading prevention mode
  • extended_to_subaccounts - Whether to extend the config to subaccounts
  • block_rfq_self_match_prevention - Optional RFQ self-match prevention setting
Source

pub async fn set_disabled_trading_products( &self, trading_products: &[TradingProduct], user_id: u64, ) -> Result<bool, HttpError>

Set disabled trading products

Disables specific trading products for a user.

§Arguments
  • trading_products - List of trading products to disable
  • user_id - User ID to apply the setting to
Source

pub async fn get_new_announcements( &self, ) -> Result<Vec<Announcement>, HttpError>

Get new (unread) announcements

Retrieves announcements that have not been marked as read.

Source

pub async fn set_announcement_as_read( &self, announcement_id: u64, ) -> Result<bool, HttpError>

Mark announcement as read

Marks a specific announcement as read so it won’t appear in new announcements.

§Arguments
  • announcement_id - ID of the announcement to mark as read
Source

pub async fn enable_affiliate_program(&self) -> Result<bool, HttpError>

Enable affiliate program

Enables the affiliate program for the user’s account.

Source

pub async fn get_affiliate_program_info( &self, ) -> Result<AffiliateProgramInfo, HttpError>

Get affiliate program information

Retrieves information about the user’s affiliate program status.

Source

pub async fn set_email_language( &self, language: EmailLanguage, ) -> Result<bool, HttpError>

Set email language preference

Sets the preferred language for email communications.

§Arguments
  • language - The language to set for emails
Source

pub async fn get_email_language(&self) -> Result<String, HttpError>

Get email language preference

Retrieves the current email language preference.

Source

pub async fn withdraw( &self, currency: &str, address: &str, amount: f64, priority: Option<WithdrawalPriorityLevel>, ) -> Result<Withdrawal, HttpError>

Create a withdrawal request

Creates a new withdrawal request for the specified currency and amount. The destination address must be in the address book.

§Arguments
  • currency - Currency symbol (BTC, ETH, USDC, etc.)
  • address - Withdrawal address (must be in address book)
  • amount - Amount to withdraw
  • priority - Optional withdrawal priority level
§Returns

Returns the withdrawal details including ID, state, and fee.

§Errors

Returns HttpError if the request fails or the address is not in the address book.

Source

pub async fn cancel_withdrawal( &self, currency: &str, id: u64, ) -> Result<Withdrawal, HttpError>

Cancel a pending withdrawal

Cancels a withdrawal request that has not yet been processed.

§Arguments
  • currency - Currency symbol (BTC, ETH, USDC, etc.)
  • id - Withdrawal ID to cancel
§Returns

Returns the cancelled withdrawal details.

§Errors

Returns HttpError if the withdrawal cannot be cancelled or does not exist.

Source

pub async fn create_deposit_address( &self, currency: &str, ) -> Result<DepositAddress, HttpError>

Create a new deposit address

Generates a new deposit address for the specified currency.

§Arguments
  • currency - Currency symbol (BTC, ETH, USDC, etc.)
§Returns

Returns the newly created deposit address.

§Errors

Returns HttpError if address creation fails.

Source

pub async fn get_current_deposit_address( &self, currency: &str, ) -> Result<DepositAddress, HttpError>

Get the current deposit address

Retrieves the current deposit address for the specified currency.

§Arguments
  • currency - Currency symbol (BTC, ETH, USDC, etc.)
§Returns

Returns the current deposit address.

§Errors

Returns HttpError if no address exists or the request fails.

Source

pub async fn add_to_address_book( &self, currency: &str, address_type: AddressBookType, address: &str, label: Option<&str>, tag: Option<&str>, ) -> Result<AddressBookEntry, HttpError>

Add an address to the address book

Adds a new address entry to the address book.

§Arguments
  • currency - Currency symbol (BTC, ETH, USDC, etc.)
  • address_type - Type of address book entry
  • address - The cryptocurrency address
  • label - Optional label for the address
  • tag - Optional tag for XRP addresses
§Returns

Returns the created address book entry.

§Errors

Returns HttpError if the address is invalid or already exists.

Source

pub async fn remove_from_address_book( &self, currency: &str, address_type: AddressBookType, address: &str, ) -> Result<bool, HttpError>

Remove an address from the address book

Removes an address entry from the address book.

§Arguments
  • currency - Currency symbol (BTC, ETH, USDC, etc.)
  • address_type - Type of address book entry
  • address - The cryptocurrency address to remove
§Returns

Returns true if the address was successfully removed.

§Errors

Returns HttpError if the address does not exist or cannot be removed.

Source

pub async fn update_in_address_book( &self, request: &UpdateInAddressBookRequest, ) -> Result<bool, HttpError>

Update an address in the address book

Updates beneficiary information for an existing address book entry. This is used for travel rule compliance.

§Arguments
  • request - The update request containing all required fields
§Returns

Returns true if the address was successfully updated.

§Errors

Returns HttpError if the address does not exist or validation fails.

Source

pub async fn get_address_book( &self, currency: &str, address_type: AddressBookType, ) -> Result<Vec<AddressBookEntry>, HttpError>

Get addresses from the address book

Retrieves address book entries for a specific currency and type.

§Arguments
  • currency - Currency symbol (BTC, ETH, USDC, etc.)
  • address_type - Type of address book entries to retrieve
§Returns

Returns a list of address book entries.

§Errors

Returns HttpError if the request fails.

Source

pub async fn approve_block_trade( &self, timestamp: u64, nonce: &str, role: BlockTradeRole, ) -> Result<bool, HttpError>

Approve a pending block trade

Used to approve a pending block trade. The nonce and timestamp identify the block trade while role should be opposite to the trading counterparty.

To use block trade approval, the API key must have enabled_features: block_trade_approval.

§Arguments
  • timestamp - Timestamp shared with other party, in milliseconds since UNIX epoch
  • nonce - Nonce shared with other party
  • role - Role in the trade (maker or taker)
§Returns

Returns true if the block trade was successfully approved.

§Errors

Returns HttpError if the request fails or the block trade cannot be approved.

Source

pub async fn execute_block_trade( &self, request: &ExecuteBlockTradeRequest, ) -> Result<BlockTradeResult, HttpError>

Execute a block trade

Creates and executes a block trade with the counterparty signature. Both parties must agree on the same timestamp, nonce, and trades fields. The server ensures that roles are different between the two parties.

§Arguments
  • request - The execute block trade request containing all required parameters
§Returns

Returns the block trade result with trade details.

§Errors

Returns HttpError if the request fails or the block trade cannot be executed.

Source

pub async fn get_block_trade(&self, id: &str) -> Result<BlockTrade, HttpError>

Get a specific block trade by ID

Returns information about a user’s block trade.

§Arguments
  • id - Block trade ID
§Returns

Returns the block trade details.

§Errors

Returns HttpError if the request fails or the block trade is not found.

Source

pub async fn get_block_trade_requests( &self, broker_code: Option<&str>, ) -> Result<Vec<BlockTradeRequest>, HttpError>

Get pending block trade requests

Provides a list of pending block trade approvals. The timestamp and nonce received in response can be used to approve or reject the pending block trade.

§Arguments
  • broker_code - Optional broker code to filter by
§Returns

Returns a list of pending block trade requests.

§Errors

Returns HttpError if the request fails.

Source

pub async fn get_block_trades( &self, request: &GetBlockTradesRequest, ) -> Result<Vec<BlockTrade>, HttpError>

Get block trades with optional filters

Returns a list of block trades for the user.

§Arguments
  • request - Request parameters with optional filters
§Returns

Returns a list of block trades.

§Errors

Returns HttpError if the request fails.

Source

pub async fn get_broker_trade_requests( &self, ) -> Result<Vec<BlockTradeRequest>, HttpError>

Get broker trade requests

Provides a list of pending broker trade requests.

§Returns

Returns a list of broker trade requests.

§Errors

Returns HttpError if the request fails.

Source

pub async fn get_broker_trades( &self, request: &GetBlockTradesRequest, ) -> Result<Vec<BlockTrade>, HttpError>

Get broker trades with optional filters

Returns a list of broker trades.

§Arguments
  • request - Request parameters with optional filters
§Returns

Returns a list of broker trades.

§Errors

Returns HttpError if the request fails.

Source

pub async fn invalidate_block_trade_signature( &self, signature: &str, ) -> Result<bool, HttpError>

Invalidate a block trade signature

Invalidates a previously generated block trade signature.

§Arguments
  • signature - The signature to invalidate
§Returns

Returns true if the signature was successfully invalidated.

§Errors

Returns HttpError if the request fails.

Source

pub async fn reject_block_trade( &self, timestamp: u64, nonce: &str, role: BlockTradeRole, ) -> Result<bool, HttpError>

Reject a pending block trade

Used to reject a pending block trade.

§Arguments
  • timestamp - Timestamp shared with other party, in milliseconds since UNIX epoch
  • nonce - Nonce shared with other party
  • role - Role in the trade (maker or taker)
§Returns

Returns true if the block trade was successfully rejected.

§Errors

Returns HttpError if the request fails.

Source

pub async fn simulate_block_trade( &self, request: &SimulateBlockTradeRequest, ) -> Result<bool, HttpError>

Simulate a block trade

Checks if a block trade can be executed.

§Arguments
  • request - The simulation request containing trades and optional role
§Returns

Returns true if the block trade can be executed, false otherwise.

§Errors

Returns HttpError if the request fails.

Source

pub async fn verify_block_trade( &self, request: &VerifyBlockTradeRequest, ) -> Result<BlockTradeSignature, HttpError>

Verify and create a block trade signature

Verifies the block trade parameters and creates a signature. The signature is valid for 5 minutes around the given timestamp.

§Arguments
  • request - The verify block trade request containing all required parameters
§Returns

Returns the block trade signature.

§Errors

Returns HttpError if the request fails or verification fails.

Source

pub async fn create_combo( &self, trades: &[ComboTrade], ) -> Result<Combo, HttpError>

Create a combo book

Verifies and creates a combo book or returns an existing combo matching the given trades.

§Arguments
  • trades - List of trades used to create a combo
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;
use deribit_http::model::ComboTrade;

let client = DeribitHttpClient::new();
let trades = vec![
    ComboTrade::buy("BTC-29APR22-37500-C", Some(1.0)),
    ComboTrade::sell("BTC-29APR22-37500-P", Some(1.0)),
];
// let combo = client.create_combo(&trades).await?;
Source

pub async fn get_leg_prices( &self, legs: &[LegInput], price: f64, ) -> Result<LegPricesResponse, HttpError>

Get leg prices for a combo structure

Returns individual leg prices for a given combo structure based on an aggregated price of the strategy and the mark prices of the individual legs.

§Arguments
  • legs - List of legs for which the prices will be calculated
  • price - Price for the whole leg structure
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;
use deribit_http::model::LegInput;

let client = DeribitHttpClient::new();
let legs = vec![
    LegInput::buy("BTC-1NOV24-67000-C", 2.0),
    LegInput::sell("BTC-1NOV24-66000-C", 2.0),
];
// let prices = client.get_leg_prices(&legs, 0.6).await?;
Source

pub async fn create_block_rfq( &self, legs: &[BlockRfqLeg], hedge: Option<&BlockRfqHedge>, label: Option<&str>, makers: Option<&[&str]>, non_anonymous: Option<bool>, trade_allocations: Option<&[BlockRfqTradeAllocation]>, ) -> Result<BlockRfq, HttpError>

Creates a new Block RFQ (taker method).

§Arguments
  • legs - List of legs for the Block RFQ
  • hedge - Optional hedge leg
  • label - Optional user-defined label (max 64 chars)
  • makers - Optional list of targeted makers
  • non_anonymous - Whether the RFQ is non-anonymous (default true)
  • trade_allocations - Optional pre-allocation for splitting amounts
§Errors

Returns HttpError if the request fails.

Source

pub async fn cancel_block_rfq( &self, block_rfq_id: i64, ) -> Result<BlockRfq, HttpError>

Cancels a Block RFQ (taker method).

§Arguments
  • block_rfq_id - ID of the Block RFQ to cancel
§Errors

Returns HttpError if the request fails.

Source

pub async fn accept_block_rfq( &self, block_rfq_id: i64, legs: &[BlockRfqLeg], price: f64, direction: Direction, amount: f64, time_in_force: Option<BlockRfqTimeInForce>, hedge: Option<&BlockRfqHedge>, ) -> Result<AcceptBlockRfqResponse, HttpError>

Accepts a Block RFQ quote (taker method).

§Arguments
  • block_rfq_id - ID of the Block RFQ
  • legs - Legs to trade
  • price - Maximum acceptable price
  • direction - Direction from taker perspective
  • amount - Order amount
  • time_in_force - Time in force (fill_or_kill or good_til_cancelled)
  • hedge - Optional hedge leg
§Errors

Returns HttpError if the request fails.

Source

pub async fn get_block_rfqs( &self, count: Option<u32>, state: Option<BlockRfqState>, role: Option<BlockRfqRole>, continuation: Option<&str>, block_rfq_id: Option<i64>, currency: Option<&str>, ) -> Result<BlockRfqsResponse, HttpError>

Retrieves Block RFQs.

§Arguments
  • count - Optional number of RFQs to return (max 1000)
  • state - Optional state filter
  • role - Optional role filter
  • continuation - Optional continuation token for pagination
  • block_rfq_id - Optional specific Block RFQ ID
  • currency - Optional currency filter
§Errors

Returns HttpError if the request fails.

Source

pub async fn get_block_rfq_quotes( &self, block_rfq_id: Option<i64>, label: Option<&str>, block_rfq_quote_id: Option<i64>, ) -> Result<Vec<BlockRfqQuote>, HttpError>

Retrieves open quotes for Block RFQs (maker method).

§Arguments
  • block_rfq_id - Optional Block RFQ ID filter
  • label - Optional label filter
  • block_rfq_quote_id - Optional specific quote ID
§Errors

Returns HttpError if the request fails.

Source

pub async fn add_block_rfq_quote( &self, block_rfq_id: i64, amount: f64, direction: Direction, legs: &[BlockRfqLeg], label: Option<&str>, hedge: Option<&BlockRfqHedge>, execution_instruction: Option<ExecutionInstruction>, expires_at: Option<i64>, ) -> Result<BlockRfqQuote, HttpError>

Adds a quote to a Block RFQ (maker method).

§Arguments
  • block_rfq_id - ID of the Block RFQ
  • amount - Quote amount
  • direction - Direction from maker perspective
  • legs - Legs with prices
  • label - Optional user-defined label
  • hedge - Optional hedge leg
  • execution_instruction - Optional execution instruction
  • expires_at - Optional expiration timestamp in milliseconds
§Errors

Returns HttpError if the request fails.

Source

pub async fn edit_block_rfq_quote( &self, block_rfq_quote_id: Option<i64>, block_rfq_id: Option<i64>, label: Option<&str>, amount: Option<f64>, legs: Option<&[BlockRfqLeg]>, hedge: Option<&BlockRfqHedge>, execution_instruction: Option<ExecutionInstruction>, expires_at: Option<i64>, ) -> Result<BlockRfqQuote, HttpError>

Edits a Block RFQ quote (maker method).

§Arguments
  • block_rfq_quote_id - Optional quote ID to edit
  • block_rfq_id - Optional Block RFQ ID (used with label)
  • label - Optional label (used with block_rfq_id)
  • amount - Optional new amount
  • legs - Optional new legs
  • hedge - Optional new hedge
  • execution_instruction - Optional new execution instruction
  • expires_at - Optional new expiration timestamp
§Errors

Returns HttpError if the request fails.

Source

pub async fn cancel_block_rfq_quote( &self, block_rfq_quote_id: Option<i64>, block_rfq_id: Option<i64>, label: Option<&str>, ) -> Result<BlockRfqQuote, HttpError>

Cancels a single Block RFQ quote (maker method).

§Arguments
  • block_rfq_quote_id - Optional quote ID to cancel
  • block_rfq_id - Optional Block RFQ ID (used with label)
  • label - Optional label (used with block_rfq_id)
§Errors

Returns HttpError if the request fails.

Source

pub async fn cancel_all_block_rfq_quotes( &self, ) -> Result<Vec<BlockRfqQuote>, HttpError>

Cancels all Block RFQ quotes (maker method).

§Errors

Returns HttpError if the request fails.

Source§

impl DeribitHttpClient

Market data endpoints

Source

pub async fn get_currencies(&self) -> Result<Vec<CurrencyStruct>, HttpError>

Get all supported currencies

Retrieves all cryptocurrencies supported by the API. This is a public endpoint that doesn’t require authentication.

§Examples
let client = DeribitHttpClient::new(); // testnet
let currencies = client.get_currencies().await?;
for currency in currencies {
    println!("Currency: {} ({})", currency.currency, currency.currency_long);
}
Source

pub async fn get_index(&self, currency: &str) -> Result<IndexData, HttpError>

Get current index price for a currency

Retrieves the current index price for the instruments, for the selected currency. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
Source

pub async fn get_index_price( &self, index_name: &str, ) -> Result<IndexPriceData, HttpError>

Get index price by name

Retrieves the current index price value for given index name. This is a public endpoint that doesn’t require authentication.

§Arguments
  • index_name - The index identifier (e.g., “btc_usd”, “eth_usd”)
§Examples
let client = DeribitHttpClient::new(); // testnet
let index_price = client.get_index_price("btc_usd").await?;
println!("Index price: {}", index_price.index_price);
Source

pub async fn get_index_price_names(&self) -> Result<Vec<String>, HttpError>

Get all supported index price names

Retrieves the identifiers of all supported Price Indexes. This is a public endpoint that doesn’t require authentication.

§Examples
let client = DeribitHttpClient::new(); // testnet
let index_names = client.get_index_price_names().await?;
for name in index_names {
    println!("Index: {}", name);
}
Source

pub async fn get_index_chart_data( &self, index_name: &str, range: &str, ) -> Result<Vec<IndexChartDataPoint>, HttpError>

Get index chart data

Returns historical price index chart data for the specified index name and time range. The data is formatted for use in charting applications and shows price index values over time. This is a public endpoint that doesn’t require authentication.

§Arguments
  • index_name - Index identifier (e.g., “btc_usd”, “eth_usd”, “sol_usdc”)
  • range - Time range for the data: “1h”, “1d”, “2d”, “1m”, “1y”, or “all”
§Examples
let client = DeribitHttpClient::new(); // testnet
let chart_data = client.get_index_chart_data("btc_usd", "1d").await?;
for point in chart_data {
    println!("Time: {}, Price: {}", point.timestamp, point.price);
}
Source

pub async fn get_book_summary_by_currency( &self, currency: &str, kind: Option<&str>, ) -> Result<Vec<BookSummary>, HttpError>

Get book summary by currency

Retrieves the summary information such as open interest, 24h volume, etc. for all instruments for the currency (optionally filtered by kind). This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
  • kind - Optional instrument kind filter (future, option, spot, future_combo, option_combo)
§Examples
let client = DeribitHttpClient::new(); // testnet
let summaries = client.get_book_summary_by_currency("BTC", Some("future")).await?;
for summary in summaries {
    println!("Instrument: {} - Volume: {}", summary.instrument_name, summary.volume);
}
Source

pub async fn get_instrument( &self, instrument_name: &str, ) -> Result<Instrument, HttpError>

Get single instrument information

Retrieves detailed information about a specific instrument. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - The instrument identifier (e.g., “BTC-PERPETUAL”)
§Examples
let client = DeribitHttpClient::new(); // testnet
let instrument = client.get_instrument("BTC-PERPETUAL").await?;
println!("Contract size: {:?}", instrument.contract_size);
Source

pub async fn get_book_summary_by_instrument( &self, instrument_name: &str, ) -> Result<BookSummary, HttpError>

Get book summary by instrument

Retrieves the summary information such as open interest, 24h volume, etc. for a specific instrument. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - The instrument identifier (e.g., “BTC-PERPETUAL”)
Source

pub async fn get_contract_size( &self, instrument_name: &str, ) -> Result<f64, HttpError>

Get contract size for an instrument

Retrieves contract size for specified instrument. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - The instrument identifier (e.g., “BTC-PERPETUAL”)
§Examples
let client = DeribitHttpClient::new(); // testnet
let contract_size = client.get_contract_size("BTC-PERPETUAL").await?;
println!("Contract size: {}", contract_size);
Source

pub async fn get_server_time(&self) -> Result<u64, HttpError>

Get server time

Returns the current server time in milliseconds since Unix epoch. This is a public endpoint that doesn’t require authentication.

§Examples
let client = DeribitHttpClient::new(); // testnet
let server_time = client.get_server_time().await?;
println!("Server time: {}", server_time);
Source

pub async fn test_connection(&self) -> Result<String, HttpError>

Test connectivity to the API

Returns the API version to test connectivity. This is a public endpoint that doesn’t require authentication.

Source

pub async fn get_status(&self) -> Result<StatusResponse, HttpError>

Get platform status and locked currency indices

Returns information about the platform status and any locked currency indices. This is a public endpoint that doesn’t require authentication.

Source

pub async fn get_apr_history( &self, currency: &str, limit: Option<u32>, before: Option<i32>, ) -> Result<AprHistoryResponse, HttpError>

Get APR history for yield tokens

Retrieves historical APR data for specified currency. Only applicable to yield-generating tokens (USDE, STETH). This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - Currency for which to retrieve APR history (usde or steth)
  • limit - Optional number of days to retrieve (default 365, maximum 365)
  • before - Optional parameter to receive APR history before given epoch day
Source

pub async fn get_ticker( &self, instrument_name: &str, ) -> Result<TickerData, HttpError>

Get ticker information for an instrument

Returns ticker data including last price, bid/ask, volume, etc.

§Arguments
  • instrument_name - The instrument identifier (e.g., “BTC-PERPETUAL”)
§Examples
let client = DeribitHttpClient::new();
let ticker = client.get_ticker("BTC-PERPETUAL").await?;
println!("Last price: {:?}", ticker.last_price);
Source

pub async fn get_order_book( &self, instrument_name: &str, depth: Option<u32>, ) -> Result<OrderBook, HttpError>

Get order book for an instrument

Returns the current order book with bids and asks.

§Arguments
  • instrument_name - The instrument identifier
  • depth - Optional depth of the order book (default: 5)
Source

pub async fn get_options( &self, currency: &str, expiry: &str, ) -> Result<Vec<OptionInstrument>, HttpError>

Retrieves a list of option instruments for a given currency and expiry date.

This asynchronous function fetches option instruments for the specified currency and expiry date and returns a filtered list of options along with their associated ticker information.

§Arguments
  • currency - A string slice that represents the name of the currency (e.g., “BTC”, “ETH”).
  • expiry - A string slice representing the expiry date for the options (e.g., “20231027”).
§Returns

Returns a Result containing a vector of OptionInstrument on success, or an HttpError on failure.

  • On success, it returns a Vec<OptionInstrument>, where each option contains the instrument details and ticker information.
  • On failure, it returns an HttpError, such as in cases where the instrument data could not be retrieved or tickers are inaccessible.
§Errors

This function may return an HttpError in the following scenarios:

  • If fetching the instrument data fails.
  • If retrieving ticker information for an instrument fails.
§Implementation Details
  1. Fetches instruments for the specified currency filtered by type option.
  2. Filters the instruments to ensure they match the currency-expiry base name.
  3. Constructs an OptionInstrument for each filtered instrument, including the instrument details and ticker information.
Source

pub async fn get_options_pair( &self, currency: &str, expiry: &str, ) -> Result<HashMap<u64, OptionInstrumentPair>, HttpError>

Fetches option instruments for a given currency and expiry date, grouped by strike price.

This method retrieves all option instruments for the specified currency and expiry, then groups them into pairs (call and put) by strike price. Each strike price maps to an OptionInstrumentPair containing the call and put options if available.

§Arguments
  • currency - The currency symbol (e.g., “BTC”, “ETH”)
  • expiry - The expiry date in format “DDMMMYY” (e.g., “10SEP25”)
§Returns

Returns a HashMap where:

  • Key: Strike price as u64
  • Value: OptionInstrumentPair containing call and put options for that strike
§Errors

Returns HttpError if:

  • The API request fails
  • An option instrument has no option type
  • Network or authentication errors occur
§Example
let client = DeribitHttpClient::new();
let pairs = client.get_options_pair("BTC", "10SEP25").await?;

for (strike, pair) in pairs {
    println!("Strike {}: Call={:?}, Put={:?}",
             strike, pair.call.is_some(), pair.put.is_some());
}
Source

pub async fn get_instruments( &self, currency: &str, kind: Option<&str>, expired: Option<bool>, ) -> Result<Vec<Instrument>, HttpError>

Get available instruments

Returns a list of available trading instruments.

§Arguments
  • currency - The currency (e.g., “BTC”, “ETH”)
  • kind - Optional instrument kind (“future”, “option”, “spot”)
  • expired - Whether to include expired instruments
Source

pub async fn get_last_trades( &self, instrument_name: &str, count: Option<u32>, include_old: Option<bool>, ) -> Result<Vec<Trade>, HttpError>

Get recent trades for an instrument

Returns recent trade history for the specified instrument.

§Arguments
  • instrument_name - The instrument identifier
  • count - Optional number of trades to return (default: 10, max: 1000)
  • include_old - Whether to include old trades
Source

pub async fn get_historical_volatility( &self, currency: &str, ) -> Result<Vec<[f64; 2]>, HttpError>

Get historical volatility

Provides information about historical volatility for given cryptocurrency.

§Arguments
  • currency - Currency symbol (BTC, ETH, etc.)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let volatility = client.get_historical_volatility("BTC").await?;
// tracing::info!("Found {} volatility data points", volatility.len());
Source

pub async fn get_mark_price_history( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, ) -> Result<Vec<MarkPriceHistoryPoint>, HttpError>

Get mark price history

Retrieves 5-minute historical mark price data for an instrument. Mark prices are used for margin calculations and position valuations.

Note: Currently, mark price history is available only for a subset of options that participate in volatility index calculations. All other instruments, including futures and perpetuals, will return an empty list.

§Arguments
  • instrument_name - Unique instrument identifier (e.g., “BTC-25JUN21-50000-C”)
  • start_timestamp - The earliest timestamp to return results from (milliseconds since Unix epoch)
  • end_timestamp - The most recent timestamp to return results from (milliseconds since Unix epoch)
§Returns

Returns a vector of MarkPriceHistoryPoint containing timestamp and mark price pairs.

§Errors

Returns HttpError if the request fails or the response cannot be parsed.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let history = client.get_mark_price_history(
//     "BTC-25JUN21-50000-C",
//     1609376800000,
//     1609376810000
// ).await?;
// for point in history {
//     println!("Time: {}, Mark Price: {}", point.timestamp, point.mark_price);
// }
Source

pub async fn get_supported_index_names( &self, index_type: Option<&str>, ) -> Result<Vec<String>, HttpError>

Get supported index names

Retrieves the identifiers (names) of all supported price indexes. Price indexes are reference prices used for mark price calculations, settlement, and other market operations.

§Arguments
  • index_type - Optional filter by index type: “all”, “spot”, or “derivative”
§Returns

Returns a vector of index name strings (e.g., “btc_eth”, “btc_usdc”).

§Errors

Returns HttpError if the request fails or the response cannot be parsed.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// Get all index names
// let names = client.get_supported_index_names(None).await?;
// for name in names {
//     println!("Index: {}", name);
// }
//
// Get only spot indexes
// let spot_names = client.get_supported_index_names(Some("spot")).await?;
Source

pub async fn get_supported_index_names_extended( &self, index_type: Option<&str>, ) -> Result<Vec<IndexNameInfo>, HttpError>

Get supported index names with extended information

Retrieves the identifiers (names) of all supported price indexes along with combo trading availability flags.

§Arguments
  • index_type - Optional filter by index type: “all”, “spot”, or “derivative”
§Returns

Returns a vector of IndexNameInfo containing index names and optional combo trading flags.

§Errors

Returns HttpError if the request fails or the response cannot be parsed.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let indexes = client.get_supported_index_names_extended(None).await?;
// for idx in indexes {
//     println!("Index: {}, Future combo: {:?}", idx.name, idx.future_combo_enabled);
// }
Source

pub async fn get_trade_volumes( &self, extended: bool, ) -> Result<Vec<TradeVolume>, HttpError>

Get trade volumes

Retrieves aggregated 24-hour trade volumes for different instrument types and currencies. Block trades and Block RFQ trades are included. Position moves are not included.

§Arguments
  • extended - If true, include 7-day and 30-day volumes
§Returns

Returns a vector of TradeVolume with volume data per currency.

§Errors

Returns HttpError if the request fails or the response cannot be parsed.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// Get basic 24h volumes
// let volumes = client.get_trade_volumes(false).await?;
// for vol in volumes {
//     println!("{}: futures={}, calls={}", vol.currency, vol.futures_volume, vol.calls_volume);
// }
//
// Get extended volumes (7d, 30d)
// let extended = client.get_trade_volumes(true).await?;
Source

pub async fn get_volatility_index_data( &self, currency: &str, start_timestamp: u64, end_timestamp: u64, resolution: &str, ) -> Result<VolatilityIndexData, HttpError>

Get volatility index data

Retrieves volatility index (VIX) chart data formatted as OHLC candles. Useful for risk assessment and trading strategies.

§Arguments
  • currency - Currency symbol (e.g., “BTC”, “ETH”)
  • start_timestamp - Start timestamp in milliseconds since UNIX epoch
  • end_timestamp - End timestamp in milliseconds since UNIX epoch
  • resolution - Candle interval (“1”, “60”, “3600”, “43200”, “1D”)
§Returns

Returns VolatilityIndexData with candles and optional continuation token.

§Errors

Returns HttpError if the request fails or the response cannot be parsed.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// Get 1-hour VIX candles for BTC
// let vix_data = client.get_volatility_index_data(
//     "BTC",
//     1599373800000,
//     1599376800000,
//     "60"
// ).await?;
// for candle in &vix_data.data {
//     println!("ts={}, close={}", candle.timestamp, candle.close);
// }
Source

pub async fn get_funding_chart_data( &self, instrument_name: &str, length: &str, ) -> Result<FundingChartData, HttpError>

Get funding chart data

Retrieves the list of the latest PERPETUAL funding chart points within a given time period.

§Arguments
  • instrument_name - Instrument name
  • length - Time period (8h, 24h, 1m)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let funding_data = client.get_funding_chart_data("BTC-PERPETUAL", "8h").await?;
// tracing::info!("Current interest: {}", funding_data.current_interest);
Source

pub async fn get_tradingview_chart_data( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, resolution: &str, ) -> Result<TradingViewChartData, HttpError>

Get TradingView chart data

Publicly available market data used to generate a TradingView candle chart.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - Start timestamp in milliseconds
  • end_timestamp - End timestamp in milliseconds
  • resolution - Chart resolution (1, 3, 5, 10, 15, 30, 60, 120, 180, 360)
§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
// let chart_data = client.get_tradingview_chart_data("BTC-PERPETUAL", 1554373800000, 1554376800000, "30").await?;
// tracing::info!("Chart status: {}", chart_data.status);
Source

pub async fn get_delivery_prices( &self, index_name: &str, count: Option<u32>, offset: Option<u32>, ) -> Result<DeliveryPricesResponse, HttpError>

Get delivery prices

Retrieves delivery prices for the given index. This is a public endpoint that doesn’t require authentication.

§Arguments
  • index_name - Index identifier (e.g., “btc_usd”, “eth_usd”)
  • count - Number of requested items (optional, default 20)
  • offset - Offset for pagination (optional, default 0)
§Examples
let client = DeribitHttpClient::new(); // testnet
let delivery_prices = client.get_delivery_prices("btc_usd", Some(5), Some(0)).await?;
for price in delivery_prices.data {
    println!("Date: {} - Price: {}", price.date, price.delivery_price);
}
Source

pub async fn get_expirations( &self, currency: &str, kind: &str, currency_pair: Option<&str>, ) -> Result<ExpirationsResponse, HttpError>

Get expirations

Retrieves expirations for instruments. This method can be used to see instrument expirations. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, any, grouped)
  • kind - Instrument kind (future, option, any)
  • currency_pair - Currency pair identifier (optional)
Source

pub async fn get_funding_rate_history( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, ) -> Result<Vec<FundingRateData>, HttpError>

Get funding rate history

Retrieves hourly historical interest rate for requested PERPETUAL instrument. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - The earliest timestamp to return result from (milliseconds since UNIX epoch)
  • end_timestamp - The most recent timestamp to return result from (milliseconds since UNIX epoch)
Source

pub async fn get_funding_rate_value( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, ) -> Result<f64, HttpError>

Get funding rate value

Retrieves interest rate value for requested period. Applicable only for PERPETUAL instruments. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - The earliest timestamp to return result from (milliseconds since UNIX epoch)
  • end_timestamp - The most recent timestamp to return result from (milliseconds since UNIX epoch)
§Examples
let client = DeribitHttpClient::new(); // testnet
let funding_rate = client.get_funding_rate_value("BTC-PERPETUAL", 1569888000000, 1569974400000).await?;
println!("Funding rate for period: {}", funding_rate);
Source

pub async fn get_last_settlements_by_currency( &self, currency: &str, settlement_type: Option<&str>, count: Option<u32>, continuation: Option<&str>, search_start_timestamp: Option<u64>, ) -> Result<SettlementsResponse, HttpError>

Get last settlements by currency

Retrieves historical settlement, delivery and bankruptcy events coming from all instruments within a given currency. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
  • settlement_type - Settlement type (settlement, delivery, bankruptcy) - optional
  • count - Number of requested items (optional, default 20)
  • continuation - Continuation token for pagination (optional)
  • search_start_timestamp - The latest timestamp to return result from (optional)
Source

pub async fn get_last_settlements_by_instrument( &self, instrument_name: &str, settlement_type: Option<&str>, count: Option<u32>, continuation: Option<&str>, search_start_timestamp: Option<u64>, ) -> Result<SettlementsResponse, HttpError>

Get last settlements by instrument

Retrieves historical public settlement, delivery and bankruptcy events filtered by instrument name. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - Instrument name
  • settlement_type - Settlement type (settlement, delivery, bankruptcy) - optional
  • count - Number of requested items (optional, default 20)
  • continuation - Continuation token for pagination (optional)
  • search_start_timestamp - The latest timestamp to return result from (optional)
Source

pub async fn get_last_trades_by_currency( &self, currency: &str, kind: Option<&str>, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<LastTradesResponse, HttpError>

Get last trades by currency

Retrieves the latest trades that have occurred for instruments in a specific currency. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
  • kind - Instrument kind (future, option, spot, etc.) - optional
  • count - Number of requested items (optional, default 10)
  • include_old - Include trades older than 7 days (optional)
  • sorting - Direction of results sorting (optional)
§Examples
let client = DeribitHttpClient::new(); // testnet
let trades = client.get_last_trades_by_currency("BTC", Some("future"), Some(10), Some(false), Some("desc")).await?;
for trade in trades.trades {
    println!("Trade: {} {} at {}", trade.amount, trade.instrument_name, trade.price);
}
Source

pub async fn get_last_trades_by_currency_and_time( &self, currency: &str, start_timestamp: u64, end_timestamp: u64, kind: Option<&str>, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<LastTradesResponse, HttpError>

Get last trades by currency and time

Retrieves the latest trades that have occurred for instruments in a specific currency within a time range. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
  • start_timestamp - The earliest timestamp to return result from (milliseconds since UNIX epoch)
  • end_timestamp - The most recent timestamp to return result from (milliseconds since UNIX epoch)
  • kind - Instrument kind (future, option, spot, etc.) - optional
  • count - Number of requested items (optional, default 10)
  • include_old - Include trades older than 7 days (optional)
  • sorting - Direction of results sorting (optional)
§Examples
let client = DeribitHttpClient::new(); // testnet
let trades = client.get_last_trades_by_currency_and_time("BTC", 1569888000000, 1569974400000, Some("future"), Some(10), Some(false), Some("desc")).await?;
for trade in trades.trades {
    println!("Trade: {} {} at {}", trade.amount, trade.instrument_name, trade.price);
}
Source

pub async fn get_last_trades_by_instrument_and_time( &self, instrument_name: &str, start_timestamp: u64, end_timestamp: u64, count: Option<u32>, include_old: Option<bool>, sorting: Option<&str>, ) -> Result<LastTradesResponse, HttpError>

Get last trades by instrument and time

Retrieves the latest trades that have occurred for a specific instrument within a time range. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_name - Instrument name
  • start_timestamp - The earliest timestamp to return result from (milliseconds since UNIX epoch)
  • end_timestamp - The most recent timestamp to return result from (milliseconds since UNIX epoch)
  • count - Number of requested items (optional, default 10)
  • include_old - Include trades older than 7 days (optional)
  • sorting - Direction of results sorting (optional)
§Examples
let client = DeribitHttpClient::new(); // testnet
let trades = client.get_last_trades_by_instrument_and_time("BTC-PERPETUAL", 1569888000000, 1569974400000, Some(10), Some(false), Some("desc")).await?;
for trade in trades.trades {
    println!("Trade: {} at {} ({})", trade.amount, trade.price, trade.direction);
}
Source

pub async fn get_order_book_by_instrument_id( &self, instrument_id: u32, depth: Option<u32>, ) -> Result<OrderBook, HttpError>

Get order book by instrument ID

Retrieves the order book for the specified instrument by its ID. This is a public endpoint that doesn’t require authentication.

§Arguments
  • instrument_id - Instrument ID
  • depth - The number of entries to return for bid and ask order book entries (optional)
§Examples
let client = DeribitHttpClient::new(); // testnet
let order_book = client.get_order_book_by_instrument_id(42, Some(5)).await?;
println!("Order book for {}: {} bids, {} asks",
         order_book.instrument_name,
         order_book.bids.len(),
         order_book.asks.len());
Source

pub async fn get_announcements( &self, count: Option<u32>, start_timestamp: Option<u64>, ) -> Result<Vec<Announcement>, HttpError>

Get platform announcements

Retrieves announcements from the platform. Default start_timestamp is current time, count must be between 1 and 50 (default is 5).

§Arguments
  • count - Number of announcements to retrieve (1-50, default 5)
  • start_timestamp - Optional timestamp to start from in milliseconds
§Examples
let client = DeribitHttpClient::new();
let announcements = client.get_announcements(Some(10), None).await?;
for announcement in announcements {
    println!("Announcement: {}", announcement.title);
}
Source

pub async fn get_combo_details( &self, combo_id: &str, ) -> Result<Combo, HttpError>

Get combo details by ID

Retrieves information about a specific combo instrument. This is a public endpoint that doesn’t require authentication.

§Arguments
  • combo_id - The combo identifier (e.g., “BTC-FS-29APR22_PERP”)
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
let combo = client.get_combo_details("BTC-FS-29APR22_PERP").await?;
println!("Combo {} has {} legs", combo.id, combo.legs.len());
Source

pub async fn get_combo_ids( &self, currency: &str, state: Option<&str>, ) -> Result<Vec<String>, HttpError>

Get combo IDs by currency

Retrieves the list of available combo IDs for the specified currency. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR)
  • state - Optional combo state filter (rfq, active, inactive)
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
let combo_ids = client.get_combo_ids("BTC", Some("active")).await?;
println!("Found {} active combos", combo_ids.len());
Source

pub async fn get_combos(&self, currency: &str) -> Result<Vec<Combo>, HttpError>

Get all active combos by currency

Retrieves information about all active combo instruments for a currency. This is a public endpoint that doesn’t require authentication.

§Arguments
  • currency - The currency symbol (BTC, ETH, USDC, USDT, EURR, or “any” for all)
§Errors

Returns HttpError if the request fails or the response is invalid.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::new();
let combos = client.get_combos("BTC").await?;
for combo in combos {
    println!("Combo: {} ({:?})", combo.id, combo.state);
}
Source

pub async fn get_block_rfq_trades( &self, currency: Option<&str>, count: Option<u32>, continuation: Option<&str>, ) -> Result<BlockRfqTradesResponse, HttpError>

Retrieves a list of recent Block RFQ trades.

This is a public method that provides market data about completed Block RFQ trades. Can be optionally filtered by currency.

§Arguments
  • currency - Optional currency filter (e.g., “BTC”, “ETH”)
  • count - Optional number of trades to return (max 1000)
  • continuation - Optional continuation token for pagination
§Returns

Returns a BlockRfqTradesResponse containing the list of trades and pagination info.

§Errors

Returns HttpError if the request fails or the response cannot be parsed.

§Examples
use deribit_http::DeribitHttpClient;

let client = DeribitHttpClient::builder().testnet().build()?;
let trades = client.get_block_rfq_trades(Some("BTC"), Some(20), None).await?;
println!("Found {} Block RFQ trades", trades.len());

Trait Implementations§

Source§

impl Clone for DeribitHttpClient

Source§

fn clone(&self) -> DeribitHttpClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DeribitHttpClient

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for DeribitHttpClient

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> PolicyExt for T
where T: ?Sized,

Source§

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
Source§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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