API Reference
Client
- class deribit_history_client.client.DeribitHistoryClient
Bases:
objectWrapper for requests to historical Deribit trading data.
This class encapsulates various HTTP GET requests to the public Deribit API in order to query information about instruments and trades.
- BASE_URL: str = 'https://history.deribit.com/api/v2/public/'
- HEADERS: Dict[str, str] = {'Accept': 'application/json'}
- get_instrument(instrument_name, raw=False)
Fetch details for a specific trading instrument.
- Parameters:
instrument_name (
str) – Name of the instrument (e.g. “BTC-30JUN23-20000-C”).raw (
bool) – If True, return the full HTTP response from the API; otherwise return only the “result” part.
- Return type:
Dict[str,Any]- Returns:
JSON response containing instrument metadata.
- get_instruments(currency, kind, expired, raw=False)
Fetch a list of instruments for a given currency and instrument type.
- Parameters:
currency (
str) – Currency code (e.g. “BTC”, “ETH”).kind (
str) – Instrument type (e.g. “future”, “option”).expired (
bool) – If True, include expired instruments.raw (
bool) – If True, return the full HTTP response from the API; otherwise return only the “result” part.
- Return type:
Dict[str,Any]- Returns:
JSON response containing a list of instruments.
- get_trades_by_sequence(instrument_name, start_seq, end_seq, count=10000, raw=False)
Fetch trades for a given instrument by sequence range.
- Parameters:
instrument_name (
str) – Name of the instrument.start_seq (
int) – Trade sequence number where the query should start.end_seq (
int) – Trade sequence number where the query should end.count (
int) – Maximum number of trades to request.raw (
bool) – If True, return the full HTTP response from the API; otherwise return only the “result” part.
- Return type:
Dict[str,Any]- Returns:
JSON response containing trade data.
- perform_api_check(currency='BTC', instrument_name='BTC-PERPETUAL', kind='future', expired=False, start_seq=99999999, end_seq=99999999)
Validate current API responses against stored JSON schemas.
This method calls several endpoints and checks their responses against local JSON schema files to detect API format changes.
- Parameters:
currency (
str) – Currency code of the instruments.instrument_name (
str) – Name of the instrument.kind (
str) – Instrument type (e.g. “future”, “option”).expired (
bool) – If True, include expired instruments.start_seq (
int) – Trade sequence number where the query should start.end_seq (
int) – Trade sequence number where the query should end.
- Return type:
None
Low-level HTTP helpers
- deribit_history_client.read.get_instrument(base_url, headers, instrument_name)
Fetch metadata for a specific trading instrument.
- Parameters:
base_url (
str) – Base URL of the Deribit API.headers (
Dict[str,str]) – HTTP headers including authentication information.instrument_name (
str) – Name of the instrument.
- Return type:
Dict[str,Any]- Returns:
JSON response containing instrument data.
- deribit_history_client.read.get_instruments(base_url, headers, currency, kind, expired)
Fetch a list of instruments for a given currency and instrument type.
- Parameters:
base_url (
str) – Base URL of the Deribit API.headers (
Dict[str,str]) – HTTP headers including authentication information.currency (
str) – Currency code (e.g. “BTC”, “ETH”).kind (
str) – Instrument type (e.g. “future”, “option”).expired (
bool) – If True, include expired instruments.
- Return type:
Dict[str,Any]- Returns:
JSON response containing a list of instruments.
- deribit_history_client.read.get_trades_by_sequence(base_url, headers, instrument_name, start_seq, end_seq, count)
Fetch trades for a specific trading instrument by sequence range.
- Parameters:
base_url (
str) – Base URL of the Deribit API.headers (
Dict[str,str]) – HTTP headers including authentication information.instrument_name (
str) – Name of the instrument.start_seq (
int) – Trade sequence number where the query should start.end_seq (
int) – Trade sequence number where the query should end.count (
int) – Maximum number of trades to request.
- Return type:
Dict[str,Any]- Returns:
JSON response containing trade data.