NAV Navbar Show example code
shell javascript python

Deribit API v2.0.1

Overview

Deribit provides three different interfaces to access the API:

Deribit features testing environment, test.deribit.com, which can be used to test the API. For this reason all examples in this documentation refer to that environment. To reach production environment it should be changed to www.deribit.com. Note that both environments are separate, which means that they require separate accounts and credentials (API keys) to authenticate using private methods - test credentials do not work in production enviromnent and vice versa.

To see the list of your API keys check Account > API tab, where you'll also find a link to API Console (>_ Api Console) which allows you to test JSON-RPC API, both via HTTP and Websocket.

Naming

Deribit tradeable assets or instruments use the following system of naming:

Kind Examples Template Comments
Future BTC-25MAR16, BTC-5AUG16 BTC-DMMMYY BTC is currency, DMMMYY is expiration date, D stands for day of month (1 or 2 digits), MMM - month (3 first letters in English), YY stands for year.
Perpetual BTC-PERPETUAL Perpetual contract for currency BTC.
Option BTC-25MAR16-420-C, BTC-5AUG16-580-P BTC-DMMMYY-STRIKE-K STRIKE is option strike price in USD. Template K is option kind: C for call options or P for put options.

Rate Limits

Rate limits are described on separate document.

JSON-RPC

JSON-RPC is a light-weight remote procedure call (RPC) protocol. The JSON-RPC specification defines the data structures that are used for the messages that are exchanged between client and server, as well as the rules around their processing. JSON-RPC uses JSON (RFC 4627) as data format.

JSON-RPC is transport agnostic: it does not specify which transport mechanism must be used. The Deribit API supports both Websocket (preferred) and HTTP (with limitations: subscriptions are not supported over HTTP).

Request messages

An example of a request message:

{
    "jsonrpc": "2.0",
    "id": 8066,
    "method": "public/ticker",
    "params": {
        "instrument": "BTC-24AUG18-6500-P"
    }
}

According to the JSON-RPC sepcification the requests must be JSON objects with the following fields.

Name Type Description
jsonrpc string The version of the JSON-RPC spec: "2.0"
id integer or string An identifier of the request. If it is included, then the response will contain the same identifier
method string The method to be invoked
params object The parameters values for the method. The field names must match with the expected parameter names. The parameters that are expected are described in the documentation for the methods, below.

Response messages

An example of a response message:

{
    "jsonrpc": "2.0",
    "id": 5239,
    "testnet": false,
    "result": [
        {
            "coin_type": "BITCOIN",
            "currency": "BTC",
            "currency_long": "Bitcoin",
            "fee_precision": 4,
            "min_confirmations": 1,
            "min_withdrawal_fee": 0.0001,
            "withdrawal_fee": 0.0001,
            "withdrawal_priorities": [
                {
                    "value": 0.15,
                    "name": "very_low"
                },
                {
                    "value": 1.5,
                    "name": "very_high"
                }
            ]
        }
    ],
    "usIn": 1535043730126248,
    "usOut": 1535043730126250,
    "usDiff": 2
}

The JSON-RPC API always responds with a JSON object with the following fields.

Name Type Description
id integer This is the same id that was sent in the request.
result any If successful, the result of the API call. The format for the result is described with each method.
error error object Only present if there was an error invoking the method. The error object is described below.
testnet boolean Indicates whether the API in use is actually the test API. false for production server, true for test server.
usIn integer The timestamp when the requests was received (microseconds since the Unix epoch)
usOut integer The timestamp when the response was sent (microseconds since the Unix epoch)
usDiff integer The number of microseconds that was spent handling the request

An example of a response with an error:

{
    "jsonrpc": "2.0",
    "id": 8163,
    "error": {
        "code": 11050,
        "message": "bad_request"
    },
    "testnet": false,
    "usIn": 1535037392434763,
    "usOut": 1535037392448119,
    "usDiff": 13356
}

In case of an error the response message will contain the error field, with as value an object with the following with the following fields:

Name Type Description
code integer A number that indicates the kind of error.
message string A short description that indicates the kind of error.
data any Additional data about the error. This field may be omitted.

Notifications

An example of a notification:

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
        "channel": "deribit_price_index.btc_usd",
        "data": {
            "timestamp": 1535098298227,
            "price": 6521.17,
            "index_name": "btc_usd"
        }
    }
}

API users can subscribe to certain types of notifications. This means that they will receive JSON-RPC notification-messages from the server when certain events occur, such as changes to the index price or changes to the order book for a certain instrument.

The API methods public/subscribe and private/subscribe are used to set up a subscription. Since HTTP does not support the sending of messages from server to client, these methods are only availble when using the Websocket transport mechanism.

At the moment of subscription a "channel" must be specified. The channel determines the type of events that will be received. See Subscriptions for more details about the channels.

In accordance with the JSON-RPC specification, the format of a notification is that of a request message without an id field. The value of the method field will always be "subscription". The params field will always be an object with 2 members: channel and data. The value of the channel member is the name of the channel (a string). The value of the data member is an object that contains data that is specific for the channel.

Authentication

An example of a JSON request with token:

{
    "id": 5647,
    "method": "private/get_subaccounts",
    "params": {
        "access_token": "1582628593469.1MbQ-J_4.CBP-OqOwm_FBdMYj4cRK2dMXyHPfBtXGpzLxhWg31nHu3H_Q60FpE5_vqUBEQGSiMrIGzw3nC37NMb9d1tpBNqBOM_Ql9pXOmgtV9Yj3Pq1c6BqC6dU6eTxHMFO67x8GpJxqw_QcKP5IepwGBD-gfKSHfAv9AEnLJkNu3JkMJBdLToY1lrBnuedF3dU_uARm"
    }
}

The API consists of public and private methods. The public methods do not require authentication. The private methods use OAuth 2.0 authentication. This means that a valid OAuth access token must be included in the request, which can be achived by calling method public/auth.

When the token was assigned to the user, it should be passed along, with other request parameters, back to the server:

Connection type Access token placement
Websocket Inside request JSON parameters, as an access_token field
HTTP (REST) Header Authorization: bearerToken value

Additional authorization method - basic user credentials

Every private method could be accessed by providing, inside HTTP Authorization: Basic XXX header, values with user ClientId and assigned ClientSecret (both values can be found on the API page on the Deribit website) encoded with Base64:

Authorization: Basic BASE64(ClientId + : + ClientSecret)

Additional authorization method - Deribit signature credentials

The Derbit service provides dedicated authorization method, which harness user generated signature to increase security level for passing request data. Generated value is passed inside Authorization header, coded as:

Authorization: deri-hmac-sha256 id=ClientId,ts=Timestamp,sig=Signature,nonce=Nonce

where:

Deribit credential Description
ClientId Can be found on the API page on the Deribit website (the user can configure up to 8 different IDs - with different privileges)
Timestamp Time when the request was generated - given as miliseconds. It's valid for 60 seconds since generation, after that time any request with an old timestamp will be rejected.
Signature Value for signature calculated as described below
Nonce Single usage, user generated initialization vector for the server token

The signature is generated by the following formula:

RequestData = UPPERCASE(HTTP_METHOD()) + "\n" + URI() + "\n" + RequestBody + "\n";
StringToSign = Timestamp + "\n" + Nonce + "\n" + RequestData;
Signature = HEX_STRING( HMAC-SHA256( ClientSecret, StringToSign ) );

Note the newline characters in RequestData and StringToSign variables. If RequestBody is ommitted in RequestData, it's treated as an empty string, so these three newline characters must always be present.

Example using shell with openssl tool:

    ClientId=AMANDA
    ClientSecret=AMANDASECRECT
    Timestamp=$( date +%s000 )
    Nonce=$( cat /dev/urandom | tr -dc 'a-z0-9' | head -c8 )
    URI="/api/v2/private/get_account_summary?currency=BTC"
    HttpMethod=GET
    Body=""

    Signature=$( echo -ne "${Timestamp}\n${Nonce}\n${HttpMethod}\n${URI}\n${Body}\n" | openssl sha256 -r -hmac "$ClientSecret" | cut -f1 -d' ' )

    echo $Signature

    shell output> 9bfbc51a2bc372d72cc396cf1a213dc78d42eb74cb7dc272351833ad0de276ab (WARNING: Exact value depends on current timestamp and client credentials)

    curl -s -X ${HttpMethod} -H "Authorization: deri-hmac-sha256 id=${ClientId},ts=${Timestamp},nonce=${Nonce},sig=${Signature}" "https://www.deribit.com${URI}"

Additional authorization method - signature credentials (WebSocket API)

Example of authorization using client_signature:

# see javascript or python example
// using CryptoJS library
var clientId = "AMANDA";
var clientSecret = "AMANDASECRECT";
var timestamp = Date.now();
var nonce = "abcd";
var data = "";
var signature = CryptoJS.HmacSHA256(`${timestamp}\n${nonce}\n${data}`, accessSecret).toString();

var msg = {
    "jsonrpc" : "2.0",
    "id" : 4316,
    "method" : "public/auth",
    "params" : {
        "grant_type": "client_signature",
        "client_id": clientId,
        "timestamp": timestamp,
        "signature": signature,
        "nonce": nonce,
        "data": data
    }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json
import hmac
import hashlib
from datetime import datetime

clientId = "AMANDA"
clientSecret = "AMANDASECRECT"
timestamp = round(datetime.now().timestamp() * 1000)
nonce = "abcd"
data = ""
signature = hmac.new(
    bytes(clientSecret, "latin-1"),
    msg=bytes('{}\n{}\n{}'.format(timestamp, nonce, data), "latin-1"),
    digestmod=hashlib.sha256
).hexdigest().lower()

msg = {
    "jsonrpc": "2.0",
    "id": 8748,
    "method": "public/auth",
    "params": {
        "grant_type": "client_signature",
        "client_id": clientId,
        "timestamp": timestamp,
        "signature": signature,
        "nonce": nonce,
        "data": data
    }
}

print(msg)

async def call_api(msg):
    async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
        await websocket.send(msg)
        while websocket.open:
            response = await websocket.recv()
            print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

When connecting through Websocket, user can request for authorization using client_signature method, which requires providing following parameters (as a part of JSON request):

JSON parameter Description
grant_type Must be client_signature
client_id Can be found on the API page on the Deribit website (the user can configure up to 8 different IDs - with different privileges)
timestamp Time when the request was generated - given as miliseconds. It's valid for 60 seconds since generation, after that time any request with an old timestamp will be rejected.
signature Value for signature calculated as described below
nonce Single usage, user generated initialization vector for the server token
data Optional field, which contains any user specific value

The signature is generated by the following formula:

StringToSign = Timestamp + "\n" + Nonce + "\n" + Data;
Signature = HEX_STRING( HMAC-SHA256( ClientSecret, StringToSign ) );

Note the newline characters separating parts of the StringToSign variable. If Data is ommitted, it's treated as an empty string, so these two newline characters must always be present.

Example using shell with openssl tool:

    ClientId=AMANDA
    ClientSecret=AMANDASECRECT
    Timestamp=$( date +%s000 ) # e.g. 1576074319000
    Nonce=$( cat /dev/urandom | tr -dc 'a-z0-9' | head -c8 ) # e.g. 1iqt2wls
    Data=""

    Signature=$( echo -ne "${Timestamp}\n${Nonce}\n${Data}" | openssl sha256 -r -hmac "$ClientSecret" | cut -f1 -d' ' )

    echo $Signature

    shell output> 56590594f97921b09b18f166befe0d1319b198bbcdad7ca73382de2f88fe9aa1 (WARNING: Exact value depends on current timestamp and client credentials)

You can also check the signature value using some online tools like, e.g: https://codebeautify.org/hmac-generator (remember that you should use it only with your test credentials).

Here's a sample JSON request created using the values from the example above:

{
  "jsonrpc" : "2.0",
  "id" : 9929,
  "method" : "public/auth",
  "params" :
  {
    "grant_type" : "client_signature",
    "client_id" : "AMANDA",
    "timestamp": "1576074319000",
    "nonce": "1iqt2wls",
    "data": "",
    "signature" : "56590594f97921b09b18f166befe0d1319b198bbcdad7ca73382de2f88fe9aa1"
  }
}

Access scope

When asking for access token user can provide the required access level (called scope) which defines what type of functionality he/she wants to use, and whether requests are only going to check for some data or also to update them. Scopes are required and checked for private methods, so if you plan to use only public information you can stay with values assigned by default.

Scope Description
mainaccount It is set automatically by the server when currently connecting user (his/her credentials) is the main user, otherwise it's not included in the final scope.
connection Access with requested parameters is granted when connection is open (or till expiration time). When the connection is closed user need to repeat the authentication request to get new tokens. It is set and used automatically by the server when neither connection nor session scope is provided within the request.
session:name The server creates a new session with name provided by the user, then generates tokens and binds them with the session. Access is granted during session lifetime. It allows to reconnect to the server and reuse assigned tokens (before their expiration time). Note that only 16 sessions are allowed per user - when limit is reached session with the shortest lifetime is removed.
When using WebSocket it also allows (due to the fact that tokens are bound to the created session) skipping providing access_token with every subsequent request.
account:read Access to account methods - read only data.
account:read_write Access to account methods - allows to manage account settings, add subaccounts, etc.
trade:read Access to trade methods - read only data.
trade:read_write Access to trade methods - required to create and modify orders.
wallet:read Access to wallet methods - read only data.
wallet:read_write Access to wallet methods - allows to withdraw, generate new deposit address, etc.
wallet:none, account:none, trade:none Blocked access to specified functionality.
expires:NUMBER Access token will expire after NUMBER of seconds.
ip:ADDR Token will work with connection from ADDR IPv4 address, when * is provided as ADDR token will work from all IP addresses.
block_trade:read Access to block_trade methods - reading info about block trades - read only data.
block_trade:read_write Access to block_trade methods - required to create block trades.

NOTICE: Depending on choosing an authentication method (grant type) some scopes could be narrowed by the server or limited by user API key configured scope, e.g. when grant_type = client_credentials and scope = wallet:read_write could be modified by the server as scope = wallet:read.

The user shouldn't assume that requested values are blindly accepted and should verify assigned scoped.

JSON-RPC over websocket

Websocket is the prefered transport mechanism for the JSON-RPC API, because it is faster and because it can support subscriptions and cancel on disconnect. The code examples that can be found next to each of the methods show how websockets can be used from Python or Javascript/node.js.

JSON-RPC over HTTP

Besides websockets it is also possible to use the API via HTTP. The code examples for 'shell' show how this can be done using curl. Note that subscriptions and cancel on disconnect are not supported via HTTP.

Methods

Authentication

/public/auth

curl -X GET "https://test.deribit.com/api/v2/public/auth?client_id=fo7WAPRm4P&client_secret=W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS&grant_type=client_credentials" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9929,
  "method" : "public/auth",
  "params" : {
    "grant_type" : "client_credentials",
    "client_id" : "fo7WAPRm4P",
    "client_secret" : "W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9929,
  "method" : "public/auth",
  "params" : {
    "grant_type" : "client_credentials",
    "client_id" : "fo7WAPRm4P",
    "client_secret" : "W0H6FJW4IRPZ1MOQ8FP6KMC5RZDUUKXS"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9929,
  "result": {
      "access_token": "1582628593469.1MbQ-J_4.CBP-OqOwm_FBdMYj4cRK2dMXyHPfBtXGpzLxhWg31nHu3H_Q60FpE5_vqUBEQGSiMrIGzw3nC37NMb9d1tpBNqBOM_Ql9pXOmgtV9Yj3Pq1c6BqC6dU6eTxHMFO67x8GpJxqw_QcKP5IepwGBD-gfKSHfAv9AEnLJkNu3JkMJBdLToY1lrBnuedF3dU_uARm",
      "expires_in": 31536000,
      "refresh_token": "1582628593469.1GP4rQd0.A9Wa78o5kFRIUP49mScaD1CqHgiK50HOl2VA6kCtWa8BQZU5Dr03BhcbXPNvEh3I_MVixKZXnyoBeKJwLl8LXnfo180ckAiPj3zOclcUu4zkXuF3NNP3sTPcDf1B3C1CwMKkJ1NOcf1yPmRbsrd7hbgQ-hLa40tfx6Oa-85ymm_3Z65LZcnCeLrqlj_A9jM",
      "scope": "connection mainaccount",
      "token_type": "bearer"
  }
}

Retrieve an Oauth access token, to be used for authentication of 'private' requests.

Three methods of authentication are supported:

The response will contain an access token, expiration period (number of seconds that the token is valid) and a refresh token that can be used to get a new set of tokens.

Try in API console

Parameters

Parameter Required Type Enum Description
grant_type true string client_credentials
client_signature
refresh_token
Method of authentication
client_id true string Required for grant type client_credentials and client_signature
client_secret true string Required for grant type client_credentials
refresh_token true string Required for grant type refresh_token
timestamp true integer Required for grant type client_signature, provides time when request has been generated
signature true string Required for grant type client_signature; it's a cryptographic signature calculated over provided fields using user secret key. The signature should be calculated as an HMAC (Hash-based Message Authentication Code) with SHA256 hash algorithm
nonce false string Optional for grant type client_signature; delivers user generated initialization vector for the server token
data false string Optional for grant type client_signature; contains any user specific value
state false string Will be passed back in the response
scope false string Describes type of the access for assigned token, possible values: connection, session:name, trade:[read, read_write, none], wallet:[read, read_write, none], account:[read, read_write, none], expires:NUMBER, ip:ADDR.

Details are elucidated in Access scope

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  acccess_token string
  ›  expires_in integer Token lifetime in seconds
  ›  refresh_token string Can be used to request a new token (with a new lifetime)
  ›  scope string Type of the access for assigned token
  ›  state string Copied from the input (if applicable)
  ›  token_type string Authorization type, allowed value - bearer

/public/exchange_token

curl -X GET "https://test.deribit.com/api/v2/public/exchange_token?refresh_token=1568800656974.1CWcuzUS.MGy49NK4hpTwvR1OYWfpqMEkH4T4oDg4tNIcrM7KdeyxXRcSFqiGzA_D4Cn7mqWocHmlS89FFmUYcmaN2H7lNKKTnhRg5EtrzsFCCiuyN0Wv9y-LbGLV3-Ojv_kbD50FoScQ8BDXS5b_w6Ir1MqEdQ3qFZ3MLcvlPiIgG2BqyJX3ybYnVpIlrVrrdYD1-lkjLcjxOBNJvvUKNUAzkQ&subject_id=10" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7619,
  "method" : "public/exchange_token",
  "params" : {
    "refresh_token" : "1568800656974.1CWcuzUS.MGy49NK4hpTwvR1OYWfpqMEkH4T4oDg4tNIcrM7KdeyxXRcSFqiGzA_D4Cn7mqWocHmlS89FFmUYcmaN2H7lNKKTnhRg5EtrzsFCCiuyN0Wv9y-LbGLV3-Ojv_kbD50FoScQ8BDXS5b_w6Ir1MqEdQ3qFZ3MLcvlPiIgG2BqyJX3ybYnVpIlrVrrdYD1-lkjLcjxOBNJvvUKNUAzkQ",
    "subject_id" : 10
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7619,
  "method" : "public/exchange_token",
  "params" : {
    "refresh_token" : "1568800656974.1CWcuzUS.MGy49NK4hpTwvR1OYWfpqMEkH4T4oDg4tNIcrM7KdeyxXRcSFqiGzA_D4Cn7mqWocHmlS89FFmUYcmaN2H7lNKKTnhRg5EtrzsFCCiuyN0Wv9y-LbGLV3-Ojv_kbD50FoScQ8BDXS5b_w6Ir1MqEdQ3qFZ3MLcvlPiIgG2BqyJX3ybYnVpIlrVrrdYD1-lkjLcjxOBNJvvUKNUAzkQ",
    "subject_id" : 10
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9929,
  "result": {
      "access_token": "1582628593469.1MbQ-J_4.CBP-OqOwm_FBdMYj4cRK2dMXyHPfBtXGpzLxhWg31nHu3H_Q60FpE5_vqUBEQGSiMrIGzw3nC37NMb9d1tpBNqBOM_Ql9pXOmgtV9Yj3Pq1c6BqC6dU6eTxHMFO67x8GpJxqw_QcKP5IepwGBD-gfKSHfAv9AEnLJkNu3JkMJBdLToY1lrBnuedF3dU_uARm",
      "expires_in": 31536000,
      "refresh_token": "1582628593469.1GP4rQd0.A9Wa78o5kFRIUP49mScaD1CqHgiK50HOl2VA6kCtWa8BQZU5Dr03BhcbXPNvEh3I_MVixKZXnyoBeKJwLl8LXnfo180ckAiPj3zOclcUu4zkXuF3NNP3sTPcDf1B3C1CwMKkJ1NOcf1yPmRbsrd7hbgQ-hLa40tfx6Oa-85ymm_3Z65LZcnCeLrqlj_A9jM",
      "scope": "session:named_session mainaccount",
      "token_type": "bearer"
  }
}

Generates token for new subject id. This method can be used to switch between subaccounts.

Try in API console

Parameters

Parameter Required Type Enum Description
refresh_token true string Refresh token
subject_id true integer New subject id

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  acccess_token string
  ›  expires_in integer Token lifetime in seconds
  ›  refresh_token string Can be used to request a new token (with a new lifetime)
  ›  scope string Type of the access for assigned token
  ›  token_type string Authorization type, allowed value - bearer

/public/fork_token

curl -X GET "https://test.deribit.com/api/v2/public/fork_token?refresh_token=1568800656974.1CWcuzUS.MGy49NK4hpTwvR1OYWfpqMEkH4T4oDg4tNIcrM7KdeyxXRcSFqiGzA_D4Cn7mqWocHmlS89FFmUYcmaN2H7lNKKTnhRg5EtrzsFCCiuyN0Wv9y-LbGLV3-Ojv_kbD50FoScQ8BDXS5b_w6Ir1MqEdQ3qFZ3MLcvlPiIgG2BqyJX3ybYnVpIlrVrrdYD1-lkjLcjxOBNJvvUKNUAzkQ&session_name=forked_session_name" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7620,
  "method" : "public/fork_token",
  "params" : {
    "refresh_token" : "1568800656974.1CWcuzUS.MGy49NK4hpTwvR1OYWfpqMEkH4T4oDg4tNIcrM7KdeyxXRcSFqiGzA_D4Cn7mqWocHmlS89FFmUYcmaN2H7lNKKTnhRg5EtrzsFCCiuyN0Wv9y-LbGLV3-Ojv_kbD50FoScQ8BDXS5b_w6Ir1MqEdQ3qFZ3MLcvlPiIgG2BqyJX3ybYnVpIlrVrrdYD1-lkjLcjxOBNJvvUKNUAzkQ",
    "session_name" : "forked_session_name"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7620,
  "method" : "public/fork_token",
  "params" : {
    "refresh_token" : "1568800656974.1CWcuzUS.MGy49NK4hpTwvR1OYWfpqMEkH4T4oDg4tNIcrM7KdeyxXRcSFqiGzA_D4Cn7mqWocHmlS89FFmUYcmaN2H7lNKKTnhRg5EtrzsFCCiuyN0Wv9y-LbGLV3-Ojv_kbD50FoScQ8BDXS5b_w6Ir1MqEdQ3qFZ3MLcvlPiIgG2BqyJX3ybYnVpIlrVrrdYD1-lkjLcjxOBNJvvUKNUAzkQ",
    "session_name" : "forked_session_name"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9929,
  "result": {
      "access_token": "1582628593469.1MbQ-J_4.CBP-OqOwm_FBdMYj4cRK2dMXyHPfBtXGpzLxhWg31nHu3H_Q60FpE5_vqUBEQGSiMrIGzw3nC37NMb9d1tpBNqBOM_Ql9pXOmgtV9Yj3Pq1c6BqC6dU6eTxHMFO67x8GpJxqw_QcKP5IepwGBD-gfKSHfAv9AEnLJkNu3JkMJBdLToY1lrBnuedF3dU_uARm",
      "expires_in": 31536000,
      "refresh_token": "1582628593469.1GP4rQd0.A9Wa78o5kFRIUP49mScaD1CqHgiK50HOl2VA6kCtWa8BQZU5Dr03BhcbXPNvEh3I_MVixKZXnyoBeKJwLl8LXnfo180ckAiPj3zOclcUu4zkXuF3NNP3sTPcDf1B3C1CwMKkJ1NOcf1yPmRbsrd7hbgQ-hLa40tfx6Oa-85ymm_3Z65LZcnCeLrqlj_A9jM",
      "scope": "session:named_session mainaccount",
      "token_type": "bearer"
  }
}

Generates token for new named session. This method can be used only with session scoped tokens.

Try in API console

Parameters

Parameter Required Type Enum Description
refresh_token true string Refresh token
session_name true string New session name

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  acccess_token string
  ›  expires_in integer Token lifetime in seconds
  ›  refresh_token string Can be used to request a new token (with a new lifetime)
  ›  scope string Type of the access for assigned token
  ›  token_type string Authorization type, allowed value - bearer

/private/logout

This method is only available via websockets.

var msg = 
    {"jsonrpc": "2.0",
     "method": "private/logout",
     "id": 42,
     "params": {
        "access_token": "1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP"}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
    {"jsonrpc": "2.0",
     "method": "private/logout",
     "id": 42,
     "params": {
        "access_token": "1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP"}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This method has no response body

Gracefully close websocket connection, when COD (Cancel On Disconnect) is enabled orders are not cancelled

Try in API console

Parameters

This method takes no parameters

Response

This method has no response body

Session management

/public/set_heartbeat

This method is only available via websockets.

var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9098,
  "method" : "public/set_heartbeat",
  "params" : {
    "interval" : 30
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9098,
  "method" : "public/set_heartbeat",
  "params" : {
    "interval" : 30
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9098,
  "result": "ok"
}

Signals the Websocket connection to send and request heartbeats. Heartbeats can be used to detect stale connections. When heartbeats have been set up, the API server will send heartbeat messages and test_request messages. Your software should respond to test_request messages by sending a /api/v2/public/test request. If your software fails to do so, the API server will immediately close the connection. If your account is configured to cancel on disconnect, any orders opened over the connection will be cancelled.

Try in API console

Parameters

Parameter Required Type Enum Description
interval true number The heartbeat interval in seconds, but not less than 10

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/public/disable_heartbeat

This method is only available via websockets.

var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3562,
  "method" : "public/disable_heartbeat",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3562,
  "method" : "public/disable_heartbeat",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 3562,
    "result": "ok"
}

Stop sending heartbeat messages.

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/enable_cancel_on_disconnect

curl -X GET "https://test.deribit.com/api/v2/private/enable_cancel_on_disconnect?scope=account" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7859,
  "method" : "private/enable_cancel_on_disconnect",
  "params" : {
    "scope" : "account"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7859,
  "method" : "private/enable_cancel_on_disconnect",
  "params" : {
    "scope" : "account"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7859,
  "result": "ok"
}

Enable Cancel On Disconnect for the connection. After enabling Cancel On Disconnect all orders created by the connection will be removed when connection is closed.

NOTICE It does not affect orders created by other connections - they will remain active !

When change is applied for the account, then every newly opened connection will start with active Cancel on Disconnect.

Try in API console

Parameters

Parameter Required Type Enum Description
scope false string connection
account
Specifies if Cancel On Disconnect change should be applied/checked for the current connection or the account (default - connection)

NOTICE: Scope connection can be used only when working via Websocket.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/disable_cancel_on_disconnect

curl -X GET "https://test.deribit.com/api/v2/private/disable_cancel_on_disconnect?scope=account" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 1569,
  "method" : "private/disable_cancel_on_disconnect",
  "params" : {
    "scope" : "account"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 1569,
  "method" : "private/disable_cancel_on_disconnect",
  "params" : {
    "scope" : "account"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 1569,
  "result": "ok"
}

Disable Cancel On Disconnect for the connection.

When change is applied for the account, then every newly opened connection will start with inactive Cancel on Disconnect.

Try in API console

Parameters

Parameter Required Type Enum Description
scope false string connection
account
Specifies if Cancel On Disconnect change should be applied/checked for the current connection or the account (default - connection)

NOTICE: Scope connection can be used only when working via Websocket.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/get_cancel_on_disconnect

curl -X GET "https://test.deribit.com/api/v2/private/get_cancel_on_disconnect?scope=account" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 220,
  "method" : "private/get_cancel_on_disconnect",
  "params" : {
    "scope" : "account"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 220,
  "method" : "private/get_cancel_on_disconnect",
  "params" : {
    "scope" : "account"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 220,
  "result": {
    "scope" : "account",
    "enabled": false
  }
}

Read current Cancel On Disconnect configuration for the account.

Try in API console

Parameters

Parameter Required Type Enum Description
scope false string connection
account
Specifies if Cancel On Disconnect change should be applied/checked for the current connection or the account (default - connection)

NOTICE: Scope connection can be used only when working via Websocket.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  enabled boolean Current configuration status
  ›  scope string Informs if Cancel on Disconnect was checked for the current connection or the account

Supporting

/public/get_time

curl -X GET "https://test.deribit.com/api/v2/public/get_time?" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7365,
  "method" : "public/get_time",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7365,
  "method" : "public/get_time",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7365,
  "result": 1550147385946
}

Retrieves the current time (in milliseconds). This API endpoint can be used to check the clock skew between your software and Deribit's systems.

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result integer Current timestamp (milliseconds)

/public/hello

This method is only available via websockets.

var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2841,
  "method" : "public/hello",
  "params" : {
    "client_name" : "My Trading Software",
    "client_version" : "1.0.2"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2841,
  "method" : "public/hello",
  "params" : {
    "client_name" : "My Trading Software",
    "client_version" : "1.0.2"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 2841,
    "result": {
        "version": "1.2.26"
    }
}

Method used to introduce the client software connected to Deribit platform over websocket. Provided data may have an impact on the maintained connection and will be collected for internal statistical purposes. In response, Deribit will also introduce itself.

Try in API console

Parameters

Parameter Required Type Enum Description
client_name true string Client software name
client_version true string Client software version

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  version string The API version

/public/test

curl -X GET "https://test.deribit.com/api/v2/public/test?" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8212,
  "method" : "public/test",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8212,
  "method" : "public/test",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 8212,
  "result": {
    "version": "1.2.26"
  }
}

Tests the connection to the API server, and returns its version. You can use this to make sure the API is reachable, and matches the expected version.

Try in API console

Parameters

Parameter Required Type Enum Description
expected_result false string exception The value "exception" will trigger an error response. This may be useful for testing wrapper libraries.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  version string The API version

Subscription management

Subscription works as notifications, so users will automatically (after subscribing) receive messages from the server. Overview for each channel response format is described in subscriptions section.

/public/subscribe

This method is only available via websockets.

var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3600,
  "method" : "public/subscribe",
  "params" : {
    "channels" : [
      "deribit_price_index.btc_usd"
    ]
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3600,
  "method" : "public/subscribe",
  "params" : {
    "channels" : [
      "deribit_price_index.btc_usd"
    ]
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 3600,
  "result": [
    "deribit_price_index.btc_usd"
  ]
}

Subscribe to one or more channels.

This is the same method as /private/subscribe, but it can only be used for 'public' channels.

Try in API console

Parameters

Parameter Required Type Enum Description
channels true array A list of channels to subscribe to.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of string A list of subscribed channels.

/public/unsubscribe

This method is only available via websockets.

var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8691,
  "method" : "public/unsubscribe",
  "params" : {
    "channels" : [
      "deribit_price_index.btc_usd"
    ]
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8691,
  "method" : "public/unsubscribe",
  "params" : {
    "channels" : [
      "deribit_price_index.btc_usd"
    ]
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 8691,
  "result": [
    "deribit_price_index.btc_usd"
  ]
}

Unsubscribe from one or more channels.

Try in API console

Parameters

Parameter Required Type Enum Description
channels true array A list of channels to unsubscribe from.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of string A list of subscribed channels.

/private/subscribe

This method is only available via websockets.

var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 4235,
  "method" : "private/subscribe",
  "params" : {
    "channels" : [
      "deribit_price_index.btc_usd"
    ]
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 4235,
  "method" : "private/subscribe",
  "params" : {
    "channels" : [
      "deribit_price_index.btc_usd"
    ]
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 4235,
  "result": [
    "deribit_price_index.btc_usd"
  ]
}

Subscribe to one or more channels.

The name of the channel determines what information will be provided, and in what form.

Try in API console

Parameters

Parameter Required Type Enum Description
channels true array A list of channels to subscribe to.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of string A list of subscribed channels.

/private/unsubscribe

This method is only available via websockets.

var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3370,
  "method" : "private/unsubscribe",
  "params" : {
    "channels" : [
      "deribit_price_index.btc_usd"
    ]
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3370,
  "method" : "private/unsubscribe",
  "params" : {
    "channels" : [
      "deribit_price_index.btc_usd"
    ]
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 3370,
  "result": [
    "deribit_price_index.btc_usd"
  ]
}

Unsubscribe from one or more channels.

Try in API console

Parameters

Parameter Required Type Enum Description
channels true array A list of channels to unsubscribe from.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of string A list of subscribed channels.

Account management

/public/get_announcements

curl -X GET "https://test.deribit.com/api/v2/public/get_announcements?" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7661,
  "method" : "public/get_announcements",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7661,
  "method" : "public/get_announcements",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7661,
  "result": [
    {
      "title": "Example announcement",
      "publication_timestamp": 1550058362418,
      "important": false,
      "id": 1550058362418,
      "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
    }
  ]
}

Retrieves announcements. Default "start_timestamp" parameter value is current timestamp, "count" parameter value must be between 1 and 50, default is 5.

Try in API console

Parameters

Parameter Required Type Enum Description
start_timestamp false integer Timestamp from which we want to retrieve announcements
count false integer Maximum count of returned announcements

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  body string The HTML body of the announcement
  ›  confirmation boolean Whether the user confirmation is required for this announcement
  ›  id number A unique identifier for the announcement
  ›  important boolean Whether the announcement is marked as important
  ›  publication_timestamp integer The timestamp in ms at which the announcement was published
  ›  title string The title of the announcement

/private/change_api_key_name

curl -X GET "https://test.deribit.com/api/v2/private/change_api_key_name?id=3&name=KeyName3" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2453,
  "method" : "private/change_scope_in_api_key",
  "params" : {
    "name" : "KeyName3",
    "id" : 3
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2453,
  "method" : "private/change_scope_in_api_key",
  "params" : {
    "name" : "KeyName3",
    "id" : 3
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2453,
  "result": {
    "timestamp": 1560242482758,
    "max_scope": "account:read_write block_trade:read trade:read_write wallet:read_write",
    "id": 3,
    "enabled": true,
    "default": false,
    "client_secret": "B6RsF9rrLY5ezEGBQkyLlV-UC7whyPJ34BMA-kKYpes",
    "client_id": "1sXMQBhM",
    "name": "KeyName3"
  }
}

Changes name for key with given id

Try in API console

Parameters

Parameter Required Type Enum Description
id true integer Id of key
name true string Name of key (only letters, numbers and underscores allowed; maximum length - 16 characters)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  client_id string Client identifier used for authentication
  ›  client_secret string Client secret used for authentication
  ›  default boolean Informs whether this api key is default (field is deprecated and will be removed in the future)
  ›  enabled boolean Informs whether api key is enabled and can be used for authentication
  ›  id integer key identifier
  ›  max_scope string Describes maximal access for tokens generated with given key, possible values: trade:[read, read_write, none], wallet:[read, read_write, none], account:[read, read_write, none], block_trade:[read, read_write, none]. If scope is not provided, it value is set as none.

Please check details described in Access scope
  ›  name string Api key name that can be displayed in transaction log
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/change_scope_in_api_key

curl -X GET "https://test.deribit.com/api/v2/private/change_scope_in_api_key?id=3&max_scope=account%3Aread_write+wallet%3Aread_write+block_trade%3Aread+trade%3Aread_write" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2453,
  "method" : "private/change_scope_in_api_key",
  "params" : {
    "max_scope" : "account:read_write wallet:read_write block_trade:read trade:read_write",
    "id" : 3
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2453,
  "method" : "private/change_scope_in_api_key",
  "params" : {
    "max_scope" : "account:read_write wallet:read_write block_trade:read trade:read_write",
    "id" : 3
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2453,
  "result": {
    "timestamp": 1560242482758,
    "max_scope": "account:read_write block_trade:read trade:read_write wallet:read_write",
    "id": 3,
    "enabled": true,
    "default": false,
    "client_secret": "B6RsF9rrLY5ezEGBQkyLlV-UC7whyPJ34BMA-kKYpes",
    "client_id": "1sXMQBhM",
    "name": ""
  }
}

Changes scope for key with given id

Try in API console

Parameters

Parameter Required Type Enum Description
max_scope true string
id true integer Id of key

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  client_id string Client identifier used for authentication
  ›  client_secret string Client secret used for authentication
  ›  default boolean Informs whether this api key is default (field is deprecated and will be removed in the future)
  ›  enabled boolean Informs whether api key is enabled and can be used for authentication
  ›  id integer key identifier
  ›  max_scope string Describes maximal access for tokens generated with given key, possible values: trade:[read, read_write, none], wallet:[read, read_write, none], account:[read, read_write, none], block_trade:[read, read_write, none]. If scope is not provided, it value is set as none.

Please check details described in Access scope
  ›  name string Api key name that can be displayed in transaction log
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/change_subaccount_name

curl -X GET "https://test.deribit.com/api/v2/private/change_subaccount_name?name=new_user_1_1&sid=7" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3964,
  "method" : "private/change_subaccount_name",
  "params" : {
    "sid" : 7,
    "name" : "new_user_1_1"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3964,
  "method" : "private/change_subaccount_name",
  "params" : {
    "sid" : 7,
    "name" : "new_user_1_1"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 3964,
    "result": "ok"
}

Change the user name for a subaccount

Try in API console

Parameters

Parameter Required Type Enum Description
sid true integer The user id for the subaccount
name true string The new user name

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/create_api_key

curl -X GET "https://test.deribit.com/api/v2/private/create_api_key?scope=account%3Aread+trade%3Aread+block_trade%3Aread_write+wallet%3Anone" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8974,
  "method" : "private/create_api_key",
  "params" : {
    "scope" : "account:read trade:read block_trade:read_write wallet:none"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8974,
  "method" : "private/create_api_key",
  "params" : {
    "scope" : "account:read trade:read block_trade:read_write wallet:none"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 8974,
  "result": {
    "timestamp": 1560238048714,
    "max_scope": "account:read block_trade:read_write trade:read wallet:none",
    "id": 5,
    "enabled": true,
    "default": false,
    "client_secret": "STu1eIkdOsLrDZFCRlddYLXUAx4Cubm4oUhEUoxWHKc",
    "client_id": "wcVoQGam",
    "name": ""
  }
}

Creates new api key with given scope

Try in API console

Parameters

Parameter Required Type Enum Description
max_scope true string
default false boolean If true, new key is marked as default
name false string Name of key (only letters, numbers and underscores allowed; maximum length - 16 characters)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  client_id string Client identifier used for authentication
  ›  client_secret string Client secret used for authentication
  ›  default boolean Informs whether this api key is default (field is deprecated and will be removed in the future)
  ›  enabled boolean Informs whether api key is enabled and can be used for authentication
  ›  id integer key identifier
  ›  max_scope string Describes maximal access for tokens generated with given key, possible values: trade:[read, read_write, none], wallet:[read, read_write, none], account:[read, read_write, none], block_trade:[read, read_write, none]. If scope is not provided, it value is set as none.

Please check details described in Access scope
  ›  name string Api key name that can be displayed in transaction log
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/create_subaccount

curl -X GET "https://test.deribit.com/api/v2/private/create_subaccount?" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 5414,
  "method" : "private/create_subaccount",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 5414,
  "method" : "private/create_subaccount",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 5414,
    "result": {
        "email": "user_AAA@email.com",
        "id": 13,
        "is_password": false,
        "login_enabled": false,
        "portfolio": {
            "eth": {
                "available_funds": 0,
                "available_withdrawal_funds": 0,
                "balance": 0,
                "currency": "eth",
                "equity": 0,
                "initial_margin": 0,
                "maintenance_margin": 0,
                "margin_balance": 0
            },
            "btc": {
                "available_funds": 0,
                "available_withdrawal_funds": 0,
                "balance": 0,
                "currency": "btc",
                "equity": 0,
                "initial_margin": 0,
                "maintenance_margin": 0,
                "margin_balance": 0
            }
        },
        "receive_notifications": false,
        "system_name": "user_1_4",
        "tfa_enabled": false,
        "type": "subaccount",
        "username": "user_1_4"
    }
}

Create a new subaccount

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  email string User email
  ›  id integer Subaccount identifier
  ›  is_password boolean true when password for the subaccount has been configured
  ›  login_enabled boolean Informs whether login to the subaccount is enabled
  ›  portfolio object
  ›    ›  btc object
  ›    ›    ›  available_funds number
  ›    ›    ›  available_withdrawal_funds number
  ›    ›    ›  balance number
  ›    ›    ›  currency string
  ›    ›    ›  equity number
  ›    ›    ›  initial_margin number
  ›    ›    ›  maintenance_margin number
  ›    ›    ›  margin_balance number
  ›    ›  eth object
  ›    ›    ›  available_funds number
  ›    ›    ›  available_withdrawal_funds number
  ›    ›    ›  balance number
  ›    ›    ›  currency string
  ›    ›    ›  equity number
  ›    ›    ›  initial_margin number
  ›    ›    ›  maintenance_margin number
  ›    ›    ›  margin_balance number
  ›  receive_notifications boolean When true - receive all notification emails on the main email
  ›  system_name string System generated user nickname
  ›  tfa_enabled boolean Whether the two factor authentication is enabled
  ›  type string Account type
  ›  username string Account name (given by user)

/private/disable_api_key

curl -X GET "https://test.deribit.com/api/v2/private/disable_api_key?id=3" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2861,
  "method" : "private/disable_api_key",
  "params" : {
    "id" : 3
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2861,
  "method" : "private/disable_api_key",
  "params" : {
    "id" : 3
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2861,
  "result": {
    "timestamp": 1560242676023,
    "max_scope": "account:read_write block_trade:read trade:read_write wallet:read_write",
    "id": 3,
    "enabled": false,
    "default": false,
    "client_secret": "B6RsF9rrLY5ezEGBQkyLlV-UC7whyPJ34BMA-kKYpes",
    "client_id": "1sXMQBhM",
    "name": ""
  }
}

Disables api key with given id

Try in API console

Parameters

Parameter Required Type Enum Description
id true integer Id of key

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  client_id string Client identifier used for authentication
  ›  client_secret string Client secret used for authentication
  ›  default boolean Informs whether this api key is default (field is deprecated and will be removed in the future)
  ›  enabled boolean Informs whether api key is enabled and can be used for authentication
  ›  id integer key identifier
  ›  max_scope string Describes maximal access for tokens generated with given key, possible values: trade:[read, read_write, none], wallet:[read, read_write, none], account:[read, read_write, none], block_trade:[read, read_write, none]. If scope is not provided, it value is set as none.

Please check details described in Access scope
  ›  name string Api key name that can be displayed in transaction log
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/disable_tfa_for_subaccount

curl -X GET "https://test.deribit.com/api/v2/private/disable_tfa_for_subaccount?sid=7" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7640,
  "method" : "private/disable_tfa_for_subaccount",
  "params" : {
    "sid" : 7
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7640,
  "method" : "private/disable_tfa_for_subaccount",
  "params" : {
    "sid" : 7
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 7640,
    "result": "ok"
}

Disable two factor authentication for a subaccount.

Try in API console

Parameters

Parameter Required Type Enum Description
sid true integer The user id for the subaccount

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/enable_affiliate_program

curl -X GET "https://test.deribit.com/api/v2/private/enable_affiliate_program?" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 24,
  "method" : "private/enable_affiliate_program",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 24,
  "method" : "private/enable_affiliate_program",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc":"2.0",
  "id":24,
  "result":"ok"
}

Enables affilate program for user

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/enable_api_key

curl -X GET "https://test.deribit.com/api/v2/private/enable_api_key?id=3" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8580,
  "method" : "private/enable_api_key",
  "params" : {
    "id" : 3
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8580,
  "method" : "private/enable_api_key",
  "params" : {
    "id" : 3
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 8580,
  "result": {
    "timestamp": 1560242634599,
    "max_scope": "account:read_write block_trade:read trade:read_write wallet:read_write",
    "id": 3,
    "enabled": true,
    "default": false,
    "client_secret": "B6RsF9rrLY5ezEGBQkyLlV-UC7whyPJ34BMA-kKYpes",
    "client_id": "1sXMQBhM",
    "name": ""
  }
}

Enables api key with given id

Try in API console

Parameters

Parameter Required Type Enum Description
id true integer Id of key

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  client_id string Client identifier used for authentication
  ›  client_secret string Client secret used for authentication
  ›  default boolean Informs whether this api key is default (field is deprecated and will be removed in the future)
  ›  enabled boolean Informs whether api key is enabled and can be used for authentication
  ›  id integer key identifier
  ›  max_scope string Describes maximal access for tokens generated with given key, possible values: trade:[read, read_write, none], wallet:[read, read_write, none], account:[read, read_write, none], block_trade:[read, read_write, none]. If scope is not provided, it value is set as none.

Please check details described in Access scope
  ›  name string Api key name that can be displayed in transaction log
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/get_account_summary

curl -X GET "https://test.deribit.com/api/v2/private/get_account_summary?currency=BTC&extended=true" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2515,
  "method" : "private/get_account_summary",
  "params" : {
    "currency" : "BTC",
    "extended" : true
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2515,
  "method" : "private/get_account_summary",
  "params" : {
    "currency" : "BTC",
    "extended" : True
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 2515,
    "result": {
        "balance": 118.72074005,
        "options_session_upl": 0,
        "deposit_address": "2NC9eNLq1z3MFuZGVp2JgSCATeDzLqwpcY7",
        "options_gamma": 0,
        "options_theta": 0,
        "username": "user",
        "equity": 118.77720303,
        "type": "main",
        "currency": "BTC",
        "delta_total": -11.1895,
        "futures_session_rpl": -0.00011454,
        "portfolio_margining_enabled": false,
        "total_pl": -3.46418369,
        "margin_balance": 118.77720303,
        "tfa_enabled": false,
        "options_session_rpl": 0,
        "options_delta": 0,
        "futures_pl": -3.46418369,
        "referrer_id": null,
        "id": 3,
        "session_upl": 0.05657752,
        "available_withdrawal_funds": 118.38439069,
        "creation_timestamp": 1594388820315,
        "options_pl": 0,
        "system_name": "user",
        "limits": {
            "non_matching_engine": {
                "rate": 30,
                "burst": 400
            },
            "matching_engine": {
                "rate": 5,
                "burst": 20
            }
        },
        "initial_margin": 0.33634936,
        "projected_initial_margin": 0.33634936,
        "maintenance_margin": 0.24683366,
        "projected_maintenance_margin": 0.24683366,
        "session_rpl": -0.00011454,
        "interuser_transfers_enabled": false,
        "options_vega": 0,
        "projected_delta_total": -11.1895,
        "email": "user@example.com",
        "futures_session_upl": 0.05657752,
        "available_funds": 118.44085367,
        "options_value": 0
    }
}

Retrieves user account summary.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
extended false boolean Include additional fields

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  options_gamma number Options summary gamma
  ›  projected_maintenance_margin number Projected maintenance margin
  ›  system_name string System generated user nickname (available when parameter extended = true)
  ›  margin_balance number The account's margin balance
  ›  tfa_enabled boolean Whether two factor authentication is enabled (available when parameter extended = true)
  ›  options_value number Options value
  ›  username string Account name (given by user) (available when parameter extended = true)
  ›  limits object
  ›    ›  futures object Field not included if limits for futures are not set.
  ›    ›    ›  burst integer Maximal number of futures related matching engine requests allowed for user in burst mode
  ›    ›    ›  rate integer Number of futures related matching engine requests per second allowed for user
  ›    ›  matching_engine object
  ›    ›    ›  burst integer Maximal number of matching engine requests allowed for user in burst mode
  ›    ›    ›  rate integer Number of matching engine requests per second allowed for user
  ›    ›  non_matching_engine object
  ›    ›    ›  burst integer Maximal number of non matching engine requests allowed for user in burst mode
  ›    ›    ›  rate integer Number of non matching engine requests per second allowed for user
  ›    ›  options object Field not included if limits for options are not set.
  ›    ›    ›  burst integer Maximal number of options related matching engine requests allowed for user in burst mode
  ›    ›    ›  rate integer Number of options related matching engine requests per second allowed for user
  ›    ›  perpetuals object Field not included if limits for perpetuals are not set.
  ›    ›    ›  burst integer Maximal number of perpetual related matching engine requests allowed for user in burst mode
  ›    ›    ›  rate integer Number of perpetual related matching engine requests per second allowed for user
  ›  equity number The account's current equity
  ›  futures_pl number Futures profit and Loss
  ›  fees array of object User fees in case of any discounts (available when parameter extended = true and user has any discounts)
  ›    ›  currency string The currency the fee applies to
  ›    ›  fee_type string Fee type - relative if fee is calculated as a fraction of base instrument fee, fixed if fee is calculated solely using user fee
  ›    ›  instrument_type string Type of the instruments the fee applies to - future for future instruments (excluding perpetual), perpetual for future perpetual instruments, option for options
  ›    ›  maker_fee number User fee as a maker
  ›    ›  taker_fee number User fee as a taker
  ›  options_session_upl number Options session unrealized profit and Loss
  ›  id integer Account id (available when parameter extended = true)
  ›  options_vega number Options summary vega
  ›  referrer_id string Optional identifier of the referrer (of the affiliation program, and available when parameter extended = true), which link was used by this account at registration. It coincides with suffix of the affiliation link path after /reg-
  ›  currency string The selected currency
  ›  login_enabled boolean Whether account is loginable using email and password (available when parameter extended = true and account is a subaccount)
  ›  type string Account type (available when parameter extended = true)
  ›  futures_session_rpl number Futures session realized profit and Loss
  ›  options_theta number Options summary theta
  ›  portfolio_margining_enabled boolean true when portfolio margining is enabled for user
  ›  projected_delta_total number The sum of position deltas without positions that will expire during closest expiration
  ›  session_rpl number Session realized profit and loss
  ›  delta_total number The sum of position deltas
  ›  options_pl number Options profit and Loss
  ›  available_withdrawal_funds number The account's available to withdrawal funds
  ›  maintenance_margin number The maintenance margin.
  ›  initial_margin number The account's initial margin
  ›  interuser_transfers_enabled boolean true when the inter-user transfers are enabled for user (available when parameter extended = true)
  ›  futures_session_upl number Futures session unrealized profit and Loss
  ›  options_session_rpl number Options session realized profit and Loss
  ›  available_funds number The account's available funds
  ›  email string User email (available when parameter extended = true)
  ›  creation_timestamp integer Time at which the account was created (milliseconds since the Unix epoch; available when parameter extended = true)
  ›  session_upl number Session unrealized profit and loss
  ›  total_pl number Profit and loss
  ›  options_delta number Options summary delta
  ›  balance number The account's balance
  ›  projected_initial_margin number Projected initial margin
  ›  deposit_address string The deposit address for the account (if available)

/private/get_affiliate_program_info

curl -X GET "https://test.deribit.com/api/v2/private/get_affiliate_program_info?" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "method" : "private/get_affiliate_program_info",
  "params" : {

  },
  "jsonrpc" : "2.0",
  "id" : 2
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "method" : "private/get_affiliate_program_info",
  "params" : {

  },
  "jsonrpc" : "2.0",
  "id" : 2
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "received": {
      "eth": 0.00004,
      "btc": 0.000001
    },
    "number_of_affiliates": 1,
    "link": "https://www.deribit.com/reg-xxx.zxyq",
    "is_enabled": true
  }
}

Retrieves user`s affiliates count, payouts and link.

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  is_enabled boolean Status of affiliate program
  ›  link string Affliate link
  ›  number_of_affiliates number Number of affiliates
  ›  received object
  ›    ›  btc number Total payout received in BTC
  ›    ›  eth number Total payout received in ETH

/private/get_email_language

curl -X GET "https://test.deribit.com/api/v2/private/get_email_language?" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9265,
  "method" : "private/get_email_language",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9265,
  "method" : "private/get_email_language",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9265,
  "result": "en"
}

Retrieves the language to be used for emails.

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string The abbreviation of the language

/private/get_new_announcements

curl -X GET "https://test.deribit.com/api/v2/private/get_new_announcements?" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3022,
  "method" : "private/get_new_announcements",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3022,
  "method" : "private/get_new_announcements",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 3022,
  "result": [
    {
      "title": "Example announcement",
      "publication_timestamp": 1550058362418,
      "important": false,
      "id": 1550058362418,
      "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
    }
  ]
}

Retrieves announcements that have not been marked read by the user.

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  body string The HTML body of the announcement
  ›  confirmation boolean Whether the user confirmation is required for this announcement
  ›  id number A unique identifier for the announcement
  ›  important boolean Whether the announcement is marked as important
  ›  publication_timestamp integer The timestamp in ms at which the announcement was published
  ›  title string The title of the announcement

/private/get_position

curl -X GET "https://test.deribit.com/api/v2/private/get_position?instrument_name=BTC-PERPETUAL" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 404,
  "method" : "private/get_position",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 404,
  "method" : "private/get_position",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 404,
  "result": {
      "average_price": 0,
      "delta": 0,
      "direction": "buy",
      "estimated_liquidation_price": 0,
      "floating_profit_loss": 0,
      "index_price": 3555.86,
      "initial_margin": 0,
      "instrument_name": "BTC-PERPETUAL",
      "leverage": 100,
      "kind": "future",
      "maintenance_margin": 0,
      "mark_price": 3556.62,
      "open_orders_margin": 0.000165889,
      "realized_profit_loss": 0,
      "settlement_price": 3555.44,
      "size": 0,
      "size_currency": 0,
      "total_profit_loss": 0
  }
}

Retrieve user position.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  average_price number Average price of trades that built this position
  ›  average_price_usd number Only for options, average price in USD
  ›  delta number Delta parameter
  ›  direction string Direction: buy, sell or zero
  ›  estimated_liquidation_price number Estimated liquidation price, added only for futures, for non portfolio margining users
  ›  floating_profit_loss number Floating profit or loss
  ›  floating_profit_loss_usd number Only for options, floating profit or loss in USD
  ›  gamma number Only for options, Gamma parameter
  ›  index_price number Current index price
  ›  initial_margin number Initial margin
  ›  instrument_name string Unique instrument identifier
  ›  kind string Instrument kind, "future" or "option"
  ›  leverage integer Current available leverage for future position
  ›  maintenance_margin number Maintenance margin
  ›  mark_price number Current mark price for position's instrument
  ›  open_orders_margin number Open orders margin
  ›  realized_funding number Realized Funding in current session included in session realized profit or loss, only for positions of perpetual instruments
  ›  realized_profit_loss number Realized profit or loss
  ›  settlement_price number Last settlement price for position's instrument 0 if instrument wasn't settled yet
  ›  size number Position size for futures size in quote currency (e.g. USD), for options size is in base currency (e.g. BTC)
  ›  size_currency number Only for futures, position size in base currency
  ›  theta number Only for options, Theta parameter
  ›  total_profit_loss number Profit or loss from position
  ›  vega number Only for options, Vega parameter

/private/get_positions

curl -X GET "https://test.deribit.com/api/v2/private/get_positions?currency=BTC&kind=future" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2236,
  "method" : "private/get_positions",
  "params" : {
    "currency" : "BTC",
    "kind" : "future"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2236,
  "method" : "private/get_positions",
  "params" : {
    "currency" : "BTC",
    "kind" : "future"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2236,
  "result": [
      {
          "average_price": 7440.18,
          "delta": 0.006687487,
          "direction": "buy",
          "estimated_liquidation_price": 1.74,
          "floating_profit_loss": 0,
          "index_price": 7466.79,
          "initial_margin": 0.000197283,
          "instrument_name": "BTC-PERPETUAL",
          "kind": "future",
          "leverage": 34,
          "maintenance_margin": 0.000143783,
          "mark_price": 7476.65,
          "open_orders_margin": 0.000197288,
          "realized_funding": -1e-8,
          "realized_profit_loss": -9e-9,
          "settlement_price": 7476.65,
          "size": 50,
          "size_currency": 0.006687487,
          "total_profit_loss": 0.000032781
      }
  ]
}

Retrieve user positions.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
kind false string future
option
Kind filter on positions

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  average_price number Average price of trades that built this position
  ›  average_price_usd number Only for options, average price in USD
  ›  delta number Delta parameter
  ›  direction string Direction: buy, sell or zero
  ›  estimated_liquidation_price number Estimated liquidation price, added only for futures, for non portfolio margining users
  ›  floating_profit_loss number Floating profit or loss
  ›  floating_profit_loss_usd number Only for options, floating profit or loss in USD
  ›  gamma number Only for options, Gamma parameter
  ›  index_price number Current index price
  ›  initial_margin number Initial margin
  ›  instrument_name string Unique instrument identifier
  ›  kind string Instrument kind, "future" or "option"
  ›  leverage integer Current available leverage for future position
  ›  maintenance_margin number Maintenance margin
  ›  mark_price number Current mark price for position's instrument
  ›  open_orders_margin number Open orders margin
  ›  realized_funding number Realized Funding in current session included in session realized profit or loss, only for positions of perpetual instruments
  ›  realized_profit_loss number Realized profit or loss
  ›  settlement_price number Last settlement price for position's instrument 0 if instrument wasn't settled yet
  ›  size number Position size for futures size in quote currency (e.g. USD), for options size is in base currency (e.g. BTC)
  ›  size_currency number Only for futures, position size in base currency
  ›  theta number Only for options, Theta parameter
  ›  total_profit_loss number Profit or loss from position
  ›  vega number Only for options, Vega parameter

/private/get_subaccounts

curl -X GET "https://test.deribit.com/api/v2/private/get_subaccounts?with_portfolio=true" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 4947,
  "method" : "private/get_subaccounts",
  "params" : {
    "with_portfolio" : true
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 4947,
  "method" : "private/get_subaccounts",
  "params" : {
    "with_portfolio" : True
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 4947,
    "result": [
        {
            "email": "user_AAA@email.com",
            "id": 2,
            "is_password": true,
            "login_enabled": true,
            "portfolio": {
                "eth": {
                    "available_funds": 5,
                    "available_withdrawal_funds": 5,
                    "balance": 5,
                    "currency": "eth",
                    "equity": 5,
                    "initial_margin": 0,
                    "maintenance_margin": 0,
                    "margin_balance": 5
                },
                "btc": {
                    "available_funds": 5.000413075,
                    "available_withdrawal_funds": 5.000413075,
                    "balance": 5.000593987,
                    "currency": "btc",
                    "equity": 5.000571846,
                    "initial_margin": 0.000158771,
                    "maintenance_margin": 0.000115715,
                    "margin_balance": 5.000571846
                }
            },
            "receive_notifications": false,
            "system_name": "user_1",
            "tfa_enabled": false,
            "type": "main",
            "username": "user_1"
        },
        {
            "email": "user_AAA@gmail.com",
            "id": 7,
            "is_password": true,
            "login_enabled": false,
            "portfolio": {
                "eth": {
                    "available_funds": 0,
                    "available_withdrawal_funds": 0,
                    "balance": 0,
                    "currency": "eth",
                    "equity": 0,
                    "initial_margin": 0,
                    "maintenance_margin": 0,
                    "margin_balance": 0
                },
                "btc": {
                    "available_funds": 0,
                    "available_withdrawal_funds": 0,
                    "balance": 0,
                    "currency": "btc",
                    "equity": 0,
                    "initial_margin": 0,
                    "maintenance_margin": 0,
                    "margin_balance": 0
                }
            },
            "receive_notifications": false,
            "system_name": "user_1_1",
            "tfa_enabled": false,
            "type": "subaccount",
            "username": "user_1_1"
        },
        {
            "email": "user_AAA@gmail.com",
            "id": 11,
            "is_password": false,
            "login_enabled": false,
            "portfolio": {
                "eth": {
                    "available_funds": 0,
                    "available_withdrawal_funds": 0,
                    "balance": 0,
                    "currency": "eth",
                    "equity": 0,
                    "initial_margin": 0,
                    "maintenance_margin": 0,
                    "margin_balance": 0
                },
                "btc": {
                    "available_funds": 0,
                    "available_withdrawal_funds": 0,
                    "balance": 0,
                    "currency": "btc",
                    "equity": 0,
                    "initial_margin": 0,
                    "maintenance_margin": 0,
                    "margin_balance": 0
                }
            },
            "receive_notifications": false,
            "system_name": "user_1_2",
            "tfa_enabled": false,
            "type": "subaccount",
            "username": "user_1_2"
        }
    ]
}


Get information about subaccounts

Try in API console

Parameters

Parameter Required Type Enum Description
with_portfolio false boolean

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  email string User email
  ›  id integer Account/Subaccount identifier
  ›  is_password boolean true when password for the subaccount has been configured
  ›  login_enabled boolean Informs whether login to the subaccount is enabled
  ›  not_confirmed_email string New email address that has not yet been confirmed. This field is only included if with_portfolio == true.
  ›  portfolio object
  ›    ›  btc object
  ›    ›    ›  available_funds number
  ›    ›    ›  available_withdrawal_funds number
  ›    ›    ›  balance number
  ›    ›    ›  currency string
  ›    ›    ›  equity number
  ›    ›    ›  initial_margin number
  ›    ›    ›  maintenance_margin number
  ›    ›    ›  margin_balance number
  ›    ›  eth object
  ›    ›    ›  available_funds number
  ›    ›    ›  available_withdrawal_funds number
  ›    ›    ›  balance number
  ›    ›    ›  currency string
  ›    ›    ›  equity number
  ›    ›    ›  initial_margin number
  ›    ›    ›  maintenance_margin number
  ›    ›    ›  margin_balance number
  ›  receive_notifications boolean When true - receive all notification emails on the main email
  ›  system_name string System generated user nickname
  ›  tfa_enabled boolean Whether the two factor authentication is enabled
  ›  type string
  ›  username string

/private/get_transaction_log

curl -X GET "https://test.deribit.com/api/v2/private/get_transaction_log?count=5&currency=BTC&end_timestamp=1613660407000&start_timestamp=1613657734000" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "method" : "private/get_transaction_log",
  "params" : {
    "currency" : "BTC",
    "start_timestamp" : "1613657734000",
    "end_timestamp" : "1613660407000",
    "count" : 5
  },
  "jsonrpc" : "2.0",
  "id" : 4
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "method" : "private/get_transaction_log",
  "params" : {
    "currency" : "BTC",
    "start_timestamp" : "1613657734000",
    "end_timestamp" : "1613660407000",
    "count" : 5
  },
  "jsonrpc" : "2.0",
  "id" : 4
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 4,
  "result": {
    "logs": [
      {
        "username": "TestUser",
        "user_seq": 6009,
        "user_id": 7,
        "type": "transfer",
        "trade_id": null,
        "timestamp": 1613659830333,
        "side": "-",
        "price": null,
        "position": null,
        "order_id": null,
        "interest_pl": null,
        "instrument_name": null,
        "info": {
          "transfer_type": "subaccount",
          "other_user_id": 27,
          "other_user": "Subaccount"
        },
        "id": 61312,
        "equity": 3000.9275869,
        "currency": "BTC",
        "commission": 0,
        "change": -2.5,
        "cashflow": -2.5,
        "balance": 3001.22270418
      },
      {
        "username": "TestUser",
        "user_seq": 6008,
        "user_id": 7,
        "type": "settlement",
        "trade_id": null,
        "total_interest_pl": 0.00001243,
        "timestamp": 1613659544153,
        "side": "long",
        "session_upl": 0.00220172,
        "session_rpl": -0.00004467,
        "price_currency": "USD",
        "price": 51807.07,
        "position": 1520,
        "order_id": null,
        "interest_pl": 0.00000993,
        "instrument_name": "BTC-PERPETUAL",
        "info": {
          "settlement_price": 51807,
          "floating_pl": 0.00220172
        },
        "id": 61311,
        "equity": 3003.42821428,
        "currency": "BTC",
        "commission": null,
        "change": 0.00215706,
        "cashflow": 0.00215706,
        "balance": 3003.72270418,
        "amount": 1520
      },
      {
        "username": "TestUser",
        "user_seq": 6007,
        "user_id": 7,
        "type": "deposit",
        "trade_id": null,
        "timestamp": 1613657828414,
        "side": "-",
        "price": null,
        "position": null,
        "order_id": null,
        "interest_pl": null,
        "instrument_name": null,
        "info": {
          "transaction": "de6eba075855f32c9510f338d3ca0900376cedcb9f7b142caccfbdc292d3237e",
          "deposit_type": "wallet",
          "addr": "2N8prMvpZHr8aYqodX3S4yhz5wMxjY8La3p"
        },
        "id": 61291,
        "equity": 3003.4876111,
        "currency": "BTC",
        "commission": 0,
        "change": 0.65,
        "cashflow": 0.65,
        "balance": 3003.72054712
      },
      {
        "username": "TestUser",
        "user_seq": 6006,
        "user_role": "maker",
        "user_id": 7,
        "type": "trade",
        "trade_id": "28349",
        "timestamp": 1613657734620,
        "side": "open buy",
        "profit_as_cashflow": false,
        "price_currency": "BTC",
        "price": 0.1537,
        "position": 0.7,
        "order_id": "67546",
        "mark_price": 0.04884653215049635,
        "interest_pl": 0,
        "instrument_name": "BTC-19FEB21-49200-C",
        "info": "Source: api",
        "id": 61289,
        "equity": 3002.83270455,
        "currency": "BTC",
        "commission": 0,
        "change": -0.10759,
        "cashflow": -0.10759,
        "balance": 3003.07054712,
        "amount": 0.7
      },
      {
        "username": "TestUser",
        "user_seq": 6005,
        "user_role": "maker",
        "user_id": 7,
        "type": "trade",
        "trade_id": "28349",
        "timestamp": 1613657734620,
        "side": "close buy",
        "profit_as_cashflow": false,
        "price_currency": "BTC",
        "price": 0.1537,
        "position": 0,
        "order_id": "67546",
        "mark_price": 0.04884653215049635,
        "interest_pl": 0,
        "instrument_name": "BTC-19FEB21-49200-C",
        "info": "Source: api",
        "id": 61288,
        "equity": 3002.83270455,
        "currency": "BTC",
        "commission": 0,
        "change": -0.04611,
        "cashflow": -0.04611,
        "balance": 3003.17813712,
        "amount": 0.3
      }
    ],
    "continuation": 61282
  }
}

Retrieve the latest user trades that have occurred for a specific instrument and within given time range.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for
query false string The following keywords can be used to filter the results: trade, maker, taker, open, close, liquidation, buy, sell, withdrawal, delivery, settlement, deposit, transfer, option, future, correction, block_trade, swap. Plus withdrawal or transfer addresses
count false integer Number of requested items, default - 100
continuation false integer Continuation token for pagination

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  continuation integer Continuation token for pagination. NULL when no continuation.
  ›  logs array of object
  ›    ›  amount number The amount of traded contracts
  ›    ›  balance number Cash balance after the transaction
  ›    ›  cashflow number For futures and perpetual contracts: Realized session PNL (since last settlement). For options: the amount paid or received for the options traded.
  ›    ›  change number Change in cash balance. For trades: fees and options premium paid/received. For settlement: Futures session PNL and perpetual session funding.
  ›    ›  commission number Commission paid so far (in base currency)
  ›    ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  equity number Updated equity value after the transaction
  ›    ›  id integer Unique identifier
  ›    ›  info object Additional information regarding transaction. Strongly dependent on the log entry type
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  interest_pl number Actual funding rate of trades and settlements on perpetual instruments
  ›    ›  mark_price number Market price during the trade
  ›    ›  order_id string Unique order identifier
  ›    ›  position number Updated position size after the transaction
  ›    ›  price number Settlement/delivery price or the price level of the traded contracts
  ›    ›  price_currency string Currency symbol associated with the price field value
  ›    ›  profit_as_cashflow boolean Indicator informing whether the cashflow is waiting for settlement or not
  ›    ›  session_rpl number Session realized profit and loss
  ›    ›  session_upl number Session unrealized profit and loss
  ›    ›  side string One of: short or long in case of settlements, close sell or close buy in case of deliveries, open sell, open buy, close sell, close buy in case of trades
  ›    ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  total_interest_pl number Total session funding rate
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  type string Transaction category/type. The most common are: trade, deposit, withdrawal, settlement, delivery, transfer, swap, correction. New types can be added any time in the future
  ›    ›  user_id integer Unique user identifier
  ›    ›  user_role string Trade role of the user: maker or taker
  ›    ›  user_seq integer Sequential identifier of user transaction
  ›    ›  username string System name or user defined subaccount alias

/private/list_api_keys

curl -X GET "https://test.deribit.com/api/v2/private/list_api_keys?" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2553,
  "method" : "private/list_api_keys"
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2553,
  "method" : "private/list_api_keys"
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2553,
  "result": [
    {
      "timestamp": 1560236001108,
      "max_scope": "account:read block_trade:read trade:read_write wallet:read",
      "id": 1,
      "enabled": false,
      "default": false,
      "client_secret": "SjM57m1T2CfXZ4vZ76X1APjqRlJdtzHI8IwVXoQnfoM",
      "client_id": "TiA4AyLPq3",
      "name": ""
    },
    {
      "timestamp": 1560236287708,
      "max_scope": "account:read_write block_trade:read_write trade:read_write wallet:read_write",
      "id": 2,
      "enabled": true,
      "default": true,
      "client_secret": "mwNOvbUVyQczytQ5IVM8CbzmgqNJ81WvLKfu6MXcJPs",
      "client_id": "aD-KFx-H",
      "name": ""
    }
  ]
}

Retrieves list of api keys

Try in API console

Parameters

Parameter Required Type Enum Description
tfa false string TFA code, required when TFA is enabled for current account

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  client_id string Client identifier used for authentication
  ›  client_secret string Client secret used for authentication
  ›  default boolean Informs whether this api key is default (field is deprecated and will be removed in the future)
  ›  enabled boolean Informs whether api key is enabled and can be used for authentication
  ›  id integer key identifier
  ›  max_scope string Describes maximal access for tokens generated with given key, possible values: trade:[read, read_write, none], wallet:[read, read_write, none], account:[read, read_write, none], block_trade:[read, read_write, none]. If scope is not provided, it value is set as none.

Please check details described in Access scope
  ›  name string Api key name that can be displayed in transaction log
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/remove_api_key

curl -X GET "https://test.deribit.com/api/v2/private/remove_api_key?id=2" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8190,
  "method" : "private/remove_api_key",
  "params" : {
    "id" : 2
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8190,
  "method" : "private/remove_api_key",
  "params" : {
    "id" : 2
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 8190,
  "result": "ok"
}

Removes api key

Try in API console

Parameters

Parameter Required Type Enum Description
id true integer Id of key

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/remove_subaccount

curl -X GET "https://test.deribit.com/api/v2/private/remove_subaccount?subaccount_id=120" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "method" : "private/remove_subaccount",
  "params" : {
    "subaccount_id" : 120
  },
  "jsonrpc" : "2.0",
  "id" : 6
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "method" : "private/remove_subaccount",
  "params" : {
    "subaccount_id" : 120
  },
  "jsonrpc" : "2.0",
  "id" : 6
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 6,
  "result": "ok"
}

Remove empty subaccount.

Try in API console

Parameters

Parameter Required Type Enum Description
subaccount_id true integer The user id for the subaccount

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/reset_api_key

curl -X GET "https://test.deribit.com/api/v2/private/reset_api_key?id=3" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 6524,
  "method" : "private/reset_api_key",
  "params" : {
    "id" : 3
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 6524,
  "method" : "private/reset_api_key",
  "params" : {
    "id" : 3
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 6524,
  "result": {
    "timestamp": 1560238942222,
    "max_scope": "account:read block_trade:read trade:read wallet:read",
    "id": 3,
    "enabled": true,
    "default": false,
    "client_secret": "P9Z_c73KaBPwpoTVfsXzehAhjhdJn5kM7Zlz_hhDhE8",
    "client_id": "IY2D68DS",
    "name": ""
  }
}

Resets secret in api key

Try in API console

Parameters

Parameter Required Type Enum Description
id true integer Id of key

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  client_id string Client identifier used for authentication
  ›  client_secret string Client secret used for authentication
  ›  default boolean Informs whether this api key is default (field is deprecated and will be removed in the future)
  ›  enabled boolean Informs whether api key is enabled and can be used for authentication
  ›  id integer key identifier
  ›  max_scope string Describes maximal access for tokens generated with given key, possible values: trade:[read, read_write, none], wallet:[read, read_write, none], account:[read, read_write, none], block_trade:[read, read_write, none]. If scope is not provided, it value is set as none.

Please check details described in Access scope
  ›  name string Api key name that can be displayed in transaction log
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/set_announcement_as_read

curl -X GET "https://test.deribit.com/api/v2/private/set_announcement_as_read?announcement_id=1550058362418" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 5147,
  "method" : "private/set_announcement_as_read",
  "params" : {
    "announcement_id" : 1550058362418
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 5147,
  "method" : "private/set_announcement_as_read",
  "params" : {
    "announcement_id" : 1550058362418
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 5147,
  "result": "ok"
}

Marks an announcement as read, so it will not be shown in get_new_announcements.

Try in API console

Parameters

Parameter Required Type Enum Description
announcement_id true number the ID of the announcement

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/set_api_key_as_default

curl -X GET "https://test.deribit.com/api/v2/private/set_api_key_as_default?id=3" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 402,
  "method" : "private/set_api_key_as_default",
  "params" : {
    "id" : 3
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 402,
  "method" : "private/set_api_key_as_default",
  "params" : {
    "id" : 3
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 402,
  "result": {
    "timestamp": 1560242795712,
    "max_scope": "account:read_write block_trade:read trade:read_write wallet:read_write",
    "id": 3,
    "enabled": false,
    "default": true,
    "client_secret": "B6RsF9rrLY5ezEGBQkyLlV-UC7whyPJ34BMA-kKYpes",
    "client_id": "1sXMQBhM",
    "name": ""
  }
}

Sets key with given id as default one for API Console

Try in API console

Parameters

Parameter Required Type Enum Description
id true integer Id of key

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  client_id string Client identifier used for authentication
  ›  client_secret string Client secret used for authentication
  ›  default boolean Informs whether this api key is default (field is deprecated and will be removed in the future)
  ›  enabled boolean Informs whether api key is enabled and can be used for authentication
  ›  id integer key identifier
  ›  max_scope string Describes maximal access for tokens generated with given key, possible values: trade:[read, read_write, none], wallet:[read, read_write, none], account:[read, read_write, none], block_trade:[read, read_write, none]. If scope is not provided, it value is set as none.

Please check details described in Access scope
  ›  name string Api key name that can be displayed in transaction log
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/set_email_for_subaccount

curl -X GET "https://test.deribit.com/api/v2/private/set_email_for_subaccount?email=user_1_1%40email.com&sid=7" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 1667,
  "method" : "private/set_email_for_subaccount",
  "params" : {
    "sid" : 7,
    "email" : "user_1_1@email.com"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 1667,
  "method" : "private/set_email_for_subaccount",
  "params" : {
    "sid" : 7,
    "email" : "user_1_1@email.com"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 1667,
    "result": "ok"
}

Assign an email address to a subaccount. User will receive an email with confirmation link.

Try in API console

Parameters

Parameter Required Type Enum Description
sid true integer The user id for the subaccount
email true string The email address for the subaccount

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/set_email_language

curl -X GET "https://test.deribit.com/api/v2/private/set_email_language?language=en" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3269,
  "method" : "private/set_email_language",
  "params" : {
    "language" : "en"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3269,
  "method" : "private/set_email_language",
  "params" : {
    "language" : "en"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 3269,
  "result": "ok"
}

Changes the language to be used for emails.

Try in API console

Parameters

Parameter Required Type Enum Description
language true string The abbreviated language name. Valid values include "en", "ko", "zh", "ja", "ru"

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/set_password_for_subaccount

curl -X GET "https://test.deribit.com/api/v2/private/set_password_for_subaccount?password=ABCDEFGHIJKLMO&sid=7" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 5819,
  "method" : "private/set_password_for_subaccount",
  "params" : {
    "sid" : 7,
    "password" : "ABCDEFGHIJKLMO"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 5819,
  "method" : "private/set_password_for_subaccount",
  "params" : {
    "sid" : 7,
    "password" : "ABCDEFGHIJKLMO"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 5819,
    "result": "ok"
}

Set the password for the subaccount

Try in API console

Parameters

Parameter Required Type Enum Description
sid true integer The user id for the subaccount
password true string The password for the subaccount

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/toggle_notifications_from_subaccount

curl -X GET "https://test.deribit.com/api/v2/private/toggle_notifications_from_subaccount?sid=7&state=true" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9995,
  "method" : "private/toggle_notifications_from_subaccount",
  "params" : {
    "sid" : 7,
    "state" : true
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9995,
  "method" : "private/toggle_notifications_from_subaccount",
  "params" : {
    "sid" : 7,
    "state" : True
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 9995,
    "result": "ok"
}

Enable or disable sending of notifications for the subaccount.

Try in API console

Parameters

Parameter Required Type Enum Description
sid true integer The user id for the subaccount
state true boolean enable (true) or disable (false) notifications

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/toggle_subaccount_login

curl -X GET "https://test.deribit.com/api/v2/private/toggle_subaccount_login?sid=7&state=enable" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 938,
  "method" : "private/toggle_subaccount_login",
  "params" : {
    "sid" : 7,
    "state" : "enable"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 938,
  "method" : "private/toggle_subaccount_login",
  "params" : {
    "sid" : 7,
    "state" : "enable"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 938,
    "result": "ok"
}

Enable or disable login for a subaccount. If login is disabled and a session for the subaccount exists, this session will be terminated.

Try in API console

Parameters

Parameter Required Type Enum Description
sid true integer The user id for the subaccount
state true string enable
disable
enable or disable login.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

Block Trade

/private/execute_block_trade

curl -X GET "https://test.deribit.com/api/v2/private/execute_block_trade?counterparty_signature=1590485595899.1Mn52L_Q.lNyNBzXXo-_QBT_wDuMgnhA7uS9tBqdQ5TLN6rxbuoAiQhyaJYGJrm5IV_9enp9niY_x8D60AJLm3yEKPUY1Dv3T0TW0n5-ADPpJF7Fpj0eVDZpZ6QCdX8snBWrSJ0TtqevnO64RCBlN1dIm2T70PP9dlhiqPDAUYI4fpB1vLYI&currency=BTC&nonce=bszyprbq&role=maker&timestamp=1590485535899&trades=%5B%7B%22price%22%3A8900.0%2C%22instrument_name%22%3A%22BTC-PERPETUAL%22%2C%22direction%22%3A%22sell%22%2C%22amount%22%3A200000%7D%2C%7B%22price%22%3A0.0133%2C%22instrument_name%22%3A%22BTC-28MAY20-9000-C%22%2C%22direction%22%3A%22sell%22%2C%22amount%22%3A5.0%7D%5D" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "method" : "private/execute_block_trade",
  "params" : {
    "currency" : "BTC",
    "nonce" : "bszyprbq",
    "timestamp" : 1590485535899,
    "role" : "maker",
    "trades" : [
      {
        "instrument_name" : "BTC-PERPETUAL",
        "direction" : "sell",
        "price" : 8900.0,
        "amount" : 200000
      },
      {
        "instrument_name" : "BTC-28MAY20-9000-C",
        "direction" : "sell",
        "amount" : 5.0,
        "price" : 0.0133
      }
    ],
    "counterparty_signature" : "1590485595899.1Mn52L_Q.lNyNBzXXo-_QBT_wDuMgnhA7uS9tBqdQ5TLN6rxbuoAiQhyaJYGJrm5IV_9enp9niY_x8D60AJLm3yEKPUY1Dv3T0TW0n5-ADPpJF7Fpj0eVDZpZ6QCdX8snBWrSJ0TtqevnO64RCBlN1dIm2T70PP9dlhiqPDAUYI4fpB1vLYI"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "method" : "private/execute_block_trade",
  "params" : {
    "currency" : "BTC",
    "nonce" : "bszyprbq",
    "timestamp" : 1590485535899,
    "role" : "maker",
    "trades" : [
      {
        "instrument_name" : "BTC-PERPETUAL",
        "direction" : "sell",
        "price" : 8900.0,
        "amount" : 200000
      },
      {
        "instrument_name" : "BTC-28MAY20-9000-C",
        "direction" : "sell",
        "amount" : 5.0,
        "price" : 0.0133
      }
    ],
    "counterparty_signature" : "1590485595899.1Mn52L_Q.lNyNBzXXo-_QBT_wDuMgnhA7uS9tBqdQ5TLN6rxbuoAiQhyaJYGJrm5IV_9enp9niY_x8D60AJLm3yEKPUY1Dv3T0TW0n5-ADPpJF7Fpj0eVDZpZ6QCdX8snBWrSJ0TtqevnO64RCBlN1dIm2T70PP9dlhiqPDAUYI4fpB1vLYI"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc":"2.0",
  "result":{
    "trades":[
      {
        "trade_seq":30289730,
        "trade_id":"48079573",
        "timestamp":1590485535978,
        "tick_direction":0,
        "state":"filled",
        "self_trade":false,
        "reduce_only":false,
        "price":8900.0,
        "post_only":false,
        "order_type":"limit",
        "order_id":"4009043192",
        "matching_id":"None",
        "mark_price":8895.19,
        "liquidity":"M",
        "instrument_name":"BTC-PERPETUAL",
        "index_price":8900.45,
        "fee_currency":"BTC",
        "fee":-0.00561798,
        "direction":"sell",
        "block_trade_id":"6165",
        "amount":200000.0
      },
      {
        "underlying_price":8902.86,
        "trade_seq":1,
        "trade_id":"48079574",
        "timestamp":1590485535979,
        "tick_direction":1,
        "state":"filled",
        "self_trade":false,
        "reduce_only":false,
        "price":0.0133,
        "post_only":false,
        "order_type":"limit",
        "order_id":"4009043194",
        "matching_id":"None",
        "mark_price":0.01831619,
        "liquidity":"M",
        "iv":62.44,
        "instrument_name":"BTC-28MAY20-9000-C",
        "index_price":8900.45,
        "fee_currency":"BTC",
        "fee":0.002,
        "direction":"sell",
        "block_trade_id":"6165",
        "amount":5.0
      }
    ],
    "timestamp":1590485535980,
    "initiator_user_id":3,
    "id":"6165",
    "executor_user_id":76,
    "currency":"BTC"
  }
}

Creates block trade

The whole request have to be exact the same as in private/verify_block_trade, only role field should be set appropriately - it basically means that both sides have to agree on the same timestamp, nonce, trades fields and server will assure that role field is different between sides (each party accepted own role).

Using the same timestamp and nonce by both sides in private/verify_block_trade assures that even if unintentionally both sides execute given block trade with valid counterparty_signature, the given block trade will be executed only once.

Try in API console

Parameters

Parameter Required Type Enum Description
timestamp true integer Timestamp, shared with other party
nonce true string Nonce, shared with other party
role true string maker
taker
Describes if user wants to be maker or taker of trades
trades true array of objects List of trades for block trade
  ›  instrument_name true string Instrument name
  ›  price true number Price for trade
  ›  amount true number It represents the requested trade size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH
  ›  direction true string buy
sell
Direction of trade from the maker perspective
counterparty_signature true string Signature of block trade generated by private/verify_block_trade_method
currency false string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  executor_user_id integer Id of user that executed block_trade
  ›  id string Block trade id
  ›  initiator_user_id integer Id of user that initiated block_trade
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/get_block_trade

curl -X GET "https://test.deribit.com/api/v2/private/get_block_trade?id=61" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "method" : "private/get_block_trade",
  "params" : {
    "id" : "61"
  },
  "jsonrpc" : "2.0"
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "method" : "private/get_block_trade",
  "params" : {
    "id" : "61"
  },
  "jsonrpc" : "2.0"
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "result": {
    "trades": [
      {
        "trade_seq": 37,
        "trade_id": "92437",
        "timestamp": 1565089523719,
        "tick_direction": 3,
        "state": "filled",
        "self_trade": false,
        "price": 0.0001,
        "order_type": "limit",
        "order_id": "343062",
        "matching_id": null,
        "liquidity": "T",
        "iv": 0,
        "instrument_name": "BTC-9AUG19-10250-C",
        "index_price": 11738,
        "fee_currency": "BTC",
        "fee": 0.00025,
        "direction": "sell",
        "block_trade_id": "61",
        "amount": 10
      },
      {
        "trade_seq": 25350,
        "trade_id": "92435",
        "timestamp": 1565089523719,
        "tick_direction": 3,
        "state": "filled",
        "self_trade": false,
        "price": 11590,
        "order_type": "limit",
        "order_id": "343058",
        "matching_id": null,
        "liquidity": "T",
        "instrument_name": "BTC-PERPETUAL",
        "index_price": 11737.98,
        "fee_currency": "BTC",
        "fee": 0.00000164,
        "direction": "buy",
        "block_trade_id": "61",
        "amount": 190
      }
    ],
    "timestamp": 1565089523720,
    "initiator_user_id": 2,
    "id": "61",
    "executor_user_id": 3,
    "currency": "BTC"
  }
}

Returns information about users block trade

Try in API console

Parameters

Parameter Required Type Enum Description
id true string Block trade id

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  executor_user_id integer Id of user that executed block_trade
  ›  id string Block trade id
  ›  initiator_user_id integer Id of user that initiated block_trade
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/get_last_block_trades_by_currency

curl -X GET "https://test.deribit.com/api/v2/private/get_last_block_trades_by_currency?count=1&currency=BTC" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "method" : "private/get_last_block_trades_by_currency",
  "params" : {
    "currency" : "BTC",
    "count" : 1
  },
  "jsonrpc" : "2.0"
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "method" : "private/get_last_block_trades_by_currency",
  "params" : {
    "currency" : "BTC",
    "count" : 1
  },
  "jsonrpc" : "2.0"
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "result": [
    {
      "trades": [
        {
          "trade_seq": 4,
          "trade_id": "92462",
          "timestamp": 1565093070164,
          "tick_direction": 2,
          "state": "filled",
          "self_trade": false,
          "price": 0.0151,
          "order_type": "limit",
          "order_id": "343121",
          "matching_id": null,
          "liquidity": "M",
          "iv": 72.38,
          "instrument_name": "BTC-9AUG19-11500-P",
          "index_price": 11758.65,
          "fee_currency": "BTC",
          "fee": 0,
          "direction": "sell",
          "block_trade_id": "66",
          "amount": 2.3
        },
        {
          "trade_seq": 41,
          "trade_id": "92460",
          "timestamp": 1565093070164,
          "tick_direction": 2,
          "state": "filled",
          "self_trade": false,
          "price": 11753,
          "order_type": "limit",
          "order_id": "343117",
          "matching_id": null,
          "liquidity": "M",
          "instrument_name": "BTC-9AUG19",
          "index_price": 11758.65,
          "fee_currency": "BTC",
          "fee": 0,
          "direction": "sell",
          "block_trade_id": "66",
          "amount": 50
        }
      ],
      "timestamp": 1565093070165,
      "initiator_user_id": 3,
      "id": "66",
      "executor_user_id": 12,
      "currency": "BTC"
    }
  ]
}

Returns list of last users block trades

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
count false integer Number of requested items, default - 20
start_id false string The id of the newest block trade to be returned
end_id false string The id of the oldest block trade to be returned, start_id is required with end_id

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  executor_user_id integer Id of user that executed block_trade
  ›  id string Block trade id
  ›  initiator_user_id integer Id of user that initiated block_trade
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/invalidate_block_trade_signature

curl -X GET "https://test.deribit.com/api/v2/private/invalidate_block_trade_signature?signature=1565173369982.1M9tO0Q-.z9n9WyZUU5op9pEz6Jtd2CI71QxQMMsCZAexnIfK9HQRT1pKH3clxeIbY7Bqm-yMcWIoE3IfCDPW5VEdiN-6oS0YkKUyXPD500MUf3ULKhfkmH81EZs" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "method" : "private/invalidate_block_trade_signature",
  "params" : {
    "signature" : "1565173369982.1M9tO0Q-.z9n9WyZUU5op9pEz6Jtd2CI71QxQMMsCZAexnIfK9HQRT1pKH3clxeIbY7Bqm-yMcWIoE3IfCDPW5VEdiN-6oS0YkKUyXPD500MUf3ULKhfkmH81EZs"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "method" : "private/invalidate_block_trade_signature",
  "params" : {
    "signature" : "1565173369982.1M9tO0Q-.z9n9WyZUU5op9pEz6Jtd2CI71QxQMMsCZAexnIfK9HQRT1pKH3clxeIbY7Bqm-yMcWIoE3IfCDPW5VEdiN-6oS0YkKUyXPD500MUf3ULKhfkmH81EZs"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc":"2.0",
  "result":"ok"
}

User at any time (before the private/execute_block_trade is called) can invalidate its own signature effectively cancelling block trade

Try in API console

Parameters

Parameter Required Type Enum Description
signature true string Signature of block trade that will be invalidated

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/verify_block_trade

curl -X GET "https://test.deribit.com/api/v2/private/verify_block_trade?currency=BTC&nonce=okpdjkdo&role=maker&timestamp=1565172650935&trades=%5B%7B%22price%22%3A11624%2C%22instrument_name%22%3A%22BTC-PERPETUAL%22%2C%22direction%22%3A%22buy%22%2C%22amount%22%3A40%7D%2C%7B%22price%22%3A0.0707%2C%22instrument_name%22%3A%22BTC-9AUG19-10250-P%22%2C%22direction%22%3A%22buy%22%2C%22amount%22%3A1.2%7D%5D" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "method" : "private/verify_block_trade",
  "params" : {
    "currency" : "BTC",
    "nonce" : "okpdjkdo",
    "timestamp" : 1565172650935,
    "role" : "maker",
    "trades" : [
      {
        "instrument_name" : "BTC-PERPETUAL",
        "direction" : "buy",
        "price" : 11624,
        "amount" : 40
      },
      {
        "instrument_name" : "BTC-9AUG19-10250-P",
        "direction" : "buy",
        "amount" : 1.2,
        "price" : 0.0707
      }
    ]
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "method" : "private/verify_block_trade",
  "params" : {
    "currency" : "BTC",
    "nonce" : "okpdjkdo",
    "timestamp" : 1565172650935,
    "role" : "maker",
    "trades" : [
      {
        "instrument_name" : "BTC-PERPETUAL",
        "direction" : "buy",
        "price" : 11624,
        "amount" : 40
      },
      {
        "instrument_name" : "BTC-9AUG19-10250-P",
        "direction" : "buy",
        "amount" : 1.2,
        "price" : 0.0707
      }
    ]
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc":"2.0",
  "result":{
    "signature":"1565172710935.1ESE83qh.g6fbgRd4VWagaJz7xdi2WaV-q-d3J0njoz1jZavuRudZJZif9uH8XdUAx1LHsu0E3e0ZG_xe1UPYlwo41xRVrkWU6OMgygDRafUkEmBuk9iLqjc9rh4"
  }
}

Verifies and creates block trade signature

Try in API console

Parameters

Parameter Required Type Enum Description
timestamp true integer Timestamp, shared with other party
nonce true string Nonce, shared with other party
role true string maker
taker
Describes if user wants to be maker or taker of trades
trades true array of objects List of trades for block trade
  ›  instrument_name true string Instrument name
  ›  price true number Price for trade
  ›  amount true number It represents the requested trade size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH
  ›  direction true string buy
sell
Direction of trade from the maker perspective
currency false string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  signature string Signature of block trade
It is valid only for 5 minutes “around” given timestamp

Trading

/private/buy

curl -X GET "https://test.deribit.com/api/v2/private/buy?amount=40&instrument_name=ETH-PERPETUAL&label=market0000234&type=market" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 5275,
  "method" : "private/buy",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "amount" : 40,
    "type" : "market",
    "label" : "market0000234"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 5275,
  "method" : "private/buy",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "amount" : 40,
    "type" : "market",
    "label" : "market0000234"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 5275,
  "result": {
    "trades": [
      {
        "trade_seq": 1966056,
        "trade_id": "ETH-2696083",
        "timestamp": 1590483938456,
        "tick_direction": 0,
        "state": "filled",
        "self_trade": false,
        "reduce_only": false,
        "price": 203.3,
        "post_only": false,
        "order_type": "market",
        "order_id": "ETH-584849853",
        "matching_id": null,
        "mark_price": 203.28,
        "liquidity": "T",
        "label": "market0000234",
        "instrument_name": "ETH-PERPETUAL",
        "index_price": 203.33,
        "fee_currency": "ETH",
        "fee": 0.00014757,
        "direction": "buy",
        "amount": 40
      }
    ],
    "order": {
      "web": false,
      "time_in_force": "good_til_cancelled",
      "replaced": false,
      "reduce_only": false,
      "profit_loss": 0.00022929,
      "price": 207.3,
      "post_only": false,
      "order_type": "market",
      "order_state": "filled",
      "order_id": "ETH-584849853",
      "max_show": 40,
      "last_update_timestamp": 1590483938456,
      "label": "market0000234",
      "is_liquidation": false,
      "instrument_name": "ETH-PERPETUAL",
      "filled_amount": 40,
      "direction": "buy",
      "creation_timestamp": 1590483938456,
      "commission": 0.00014757,
      "average_price": 203.3,
      "api": true,
      "amount": 40
    }
  }
}

Places a buy order for an instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
amount true number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH
type false string limit
stop_limit
market
stop_market
The order type, default: "limit"
label false string user defined label for the order (maximum 64 characters)
price false number

The order price in base currency (Only for limit and stop_limit orders)

When adding order with advanced=usd, the field price should be the option price value in USD.

When adding order with advanced=implv, the field price should be a value of implied volatility in percentages. For example, price=100, means implied volatility of 100%

time_in_force false string good_til_cancelled
fill_or_kill
immediate_or_cancel

Specifies how long the order remains in effect. Default "good_til_cancelled"

  • "good_til_cancelled" - unfilled order remains in order book until cancelled
  • "fill_or_kill" - execute a transaction immediately and completely or not at all
  • "immediate_or_cancel" - execute a transaction immediately, and any portion of the order that cannot be immediately filled is cancelled
max_show false number Maximum amount within an order to be shown to other customers, 0 for invisible order
post_only false boolean

If true, the order is considered post-only. If the new price would cause the order to be filled immediately (as taker), the price will be changed to be just below the spread.

Only valid in combination with time_in_force="good_til_cancelled"

reject_post_only false boolean

If an order is considered post-only and this field is set to true then the order is put to order book unmodified or request is rejected and order is canceled.

Only valid in combination with "post_only" set to true

reduce_only false boolean If true, the order is considered reduce-only which is intended to only reduce a current position
stop_price false number Stop price, required for stop limit orders (Only for stop orders)
trigger false string index_price
mark_price
last_price
Defines trigger type, required for "stop_limit" and "stop_market" order types
advanced false string usd
implv
Advanced option order type. (Only for options)
mmp false boolean Order MMP flag, only for order_type 'limit'

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  order object
  ›    ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›    ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›    ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›    ›  api boolean true if created with API
  ›    ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  web boolean true if created via Deribit frontend (optional)
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›    ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›    ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›    ›  original_order_type string Original order type. Optional field
  ›    ›  price number Price in base currency
  ›    ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›    ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›    ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›    ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  post_only boolean true for post-only orders only
  ›    ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›    ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  average_price number Average fill price of the order
  ›    ›  order_id string Unique order identifier
  ›    ›  reduce_only boolean true for reduce-only orders only
  ›    ›  commission number Commission paid so far (in base currency)
  ›    ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›    ›  stop_price number Stop price (Only for future stop orders)
  ›    ›  label string User defined label (up to 64 characters)
  ›    ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  direction string Direction: buy, or sell
  ›    ›  is_liquidation boolean true if order was automatically created during liquidation
  ›    ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›    ›  usd number Option price in USD (Only if advanced="usd")
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›    ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/sell

curl -X GET "https://test.deribit.com/api/v2/private/sell?amount=123&instrument_name=ETH-PERPETUAL&price=1.45610000000000013642e%2B02&stop_price=145&trigger=last_price&type=stop_limit" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2148,
  "method" : "private/sell",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "amount" : 123,
    "type" : "stop_limit",
    "price" : 145.61,
    "stop_price" : 145,
    "trigger" : "last_price"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2148,
  "method" : "private/sell",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "amount" : 123,
    "type" : "stop_limit",
    "price" : 145.61,
    "stop_price" : 145,
    "trigger" : "last_price"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2148,
  "result": {
    "trades": [],
    "order": {
      "triggered": false,
      "trigger": "last_price",
      "time_in_force": "good_til_cancelled",
      "stop_price": 145,
      "reduce_only": false,
      "profit_loss": 0,
      "price": 145.61,
      "post_only": false,
      "order_type": "stop_limit",
      "order_state": "untriggered",
      "order_id": "ETH-SLTS-28",
      "max_show": 123,
      "last_update_timestamp": 1550659803407,
      "label": "",
      "is_liquidation": false,
      "instrument_name": "ETH-PERPETUAL",
      "direction": "sell",
      "creation_timestamp": 1550659803407,
      "api": true,
      "amount": 123
    }
  }
}

Places a sell order for an instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
amount true number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH
type false string limit
stop_limit
market
stop_market
The order type, default: "limit"
label false string user defined label for the order (maximum 64 characters)
price false number

The order price in base currency (Only for limit and stop_limit orders)

When adding order with advanced=usd, the field price should be the option price value in USD.

When adding order with advanced=implv, the field price should be a value of implied volatility in percentages. For example, price=100, means implied volatility of 100%

time_in_force false string good_til_cancelled
fill_or_kill
immediate_or_cancel

Specifies how long the order remains in effect. Default "good_til_cancelled"

  • "good_til_cancelled" - unfilled order remains in order book until cancelled
  • "fill_or_kill" - execute a transaction immediately and completely or not at all
  • "immediate_or_cancel" - execute a transaction immediately, and any portion of the order that cannot be immediately filled is cancelled
max_show false number Maximum amount within an order to be shown to other customers, 0 for invisible order
post_only false boolean

If true, the order is considered post-only. If the new price would cause the order to be filled immediately (as taker), the price will be changed to be just above the spread.

Only valid in combination with time_in_force="good_til_cancelled"

reject_post_only false boolean

If an order is considered post-only and this field is set to true then the order is put to order book unmodified or request is rejected and order is canceled.

Only valid in combination with "post_only" set to true

reduce_only false boolean If true, the order is considered reduce-only which is intended to only reduce a current position
stop_price false number Stop price, required for stop limit orders (Only for stop orders)
trigger false string index_price
mark_price
last_price
Defines trigger type, required for "stop_limit" and "stop_market" order types
advanced false string usd
implv
Advanced option order type. (Only for options)
mmp false boolean Order MMP flag, only for order_type 'limit'

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  order object
  ›    ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›    ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›    ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›    ›  api boolean true if created with API
  ›    ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  web boolean true if created via Deribit frontend (optional)
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›    ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›    ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›    ›  original_order_type string Original order type. Optional field
  ›    ›  price number Price in base currency
  ›    ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›    ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›    ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›    ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  post_only boolean true for post-only orders only
  ›    ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›    ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  average_price number Average fill price of the order
  ›    ›  order_id string Unique order identifier
  ›    ›  reduce_only boolean true for reduce-only orders only
  ›    ›  commission number Commission paid so far (in base currency)
  ›    ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›    ›  stop_price number Stop price (Only for future stop orders)
  ›    ›  label string User defined label (up to 64 characters)
  ›    ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  direction string Direction: buy, or sell
  ›    ›  is_liquidation boolean true if order was automatically created during liquidation
  ›    ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›    ›  usd number Option price in USD (Only if advanced="usd")
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›    ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/edit

curl -X GET "https://test.deribit.com/api/v2/private/edit?advanced=implv&amount=4&order_id=438994&price=222" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3725,
  "method" : "private/edit",
  "params" : {
    "order_id" : "438994",
    "amount" : 4,
    "price" : 222,
    "advanced" : "implv"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3725,
  "method" : "private/edit",
  "params" : {
    "order_id" : "438994",
    "amount" : 4,
    "price" : 222,
    "advanced" : "implv"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 3725,
  "result": {
    "trades": [],
    "order": {
      "time_in_force": "good_til_cancelled",
      "reduce_only": false,
      "profit_loss": 0,
      "price": 0.1448,
      "post_only": false,
      "order_type": "limit",
      "order_state": "open",
      "order_id": "438994",
      "max_show": 4,
      "last_update_timestamp": 1550585797677,
      "label": "",
      "is_liquidation": false,
      "instrument_name": "BTC-22FEB19-3500-C",
      "implv": 222,
      "filled_amount": 0,
      "direction": "buy",
      "creation_timestamp": 1550585741277,
      "commission": 0,
      "average_price": 0,
      "api": false,
      "amount": 4,
      "advanced": "implv"
    }
  }
}

Change price, amount and/or other properties of an order.

Try in API console

Parameters

Parameter Required Type Enum Description
order_id true string The order id
amount true number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH
price false number

The order price in base currency.

When editing an option order with advanced=usd, the field price should be the option price value in USD.

When editing an option order with advanced=implv, the field price should be a value of implied volatility in percentages. For example, price=100, means implied volatility of 100%

post_only false boolean

If true, the order is considered post-only. If the new price would cause the order to be filled immediately (as taker), the price will be changed to be just below or above the spread (accordingly to the original order type).

Only valid in combination with time_in_force="good_til_cancelled"

reduce_only false boolean If true, the order is considered reduce-only which is intended to only reduce a current position
reject_post_only false boolean

If an order is considered post-only and this field is set to true then the order is put to order book unmodified or request is rejected and order is canceled.

Only valid in combination with "post_only" set to true

advanced false string usd
implv
Advanced option order type. If you have posted an advanced option order, it is necessary to re-supply this parameter when editing it (Only for options)
stop_price false number Stop price, required for stop limit orders (Only for stop orders)
mmp false boolean Order MMP flag, only for order_type 'limit'

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  order object
  ›    ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›    ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›    ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›    ›  api boolean true if created with API
  ›    ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  web boolean true if created via Deribit frontend (optional)
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›    ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›    ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›    ›  original_order_type string Original order type. Optional field
  ›    ›  price number Price in base currency
  ›    ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›    ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›    ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›    ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  post_only boolean true for post-only orders only
  ›    ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›    ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  average_price number Average fill price of the order
  ›    ›  order_id string Unique order identifier
  ›    ›  reduce_only boolean true for reduce-only orders only
  ›    ›  commission number Commission paid so far (in base currency)
  ›    ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›    ›  stop_price number Stop price (Only for future stop orders)
  ›    ›  label string User defined label (up to 64 characters)
  ›    ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  direction string Direction: buy, or sell
  ›    ›  is_liquidation boolean true if order was automatically created during liquidation
  ›    ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›    ›  usd number Option price in USD (Only if advanced="usd")
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›    ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/cancel

curl -X GET "https://test.deribit.com/api/v2/private/cancel?order_id=ETH-SLIS-12" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 4214,
  "method" : "private/cancel",
  "params" : {
    "order_id" : "ETH-SLIS-12"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 4214,
  "method" : "private/cancel",
  "params" : {
    "order_id" : "ETH-SLIS-12"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 4214,
  "result": {
    "triggered": false,
    "trigger": "index_price",
    "time_in_force": "good_til_cancelled",
    "stop_price": 144.73,
    "reduce_only": false,
    "profit_loss": 0,
    "price": "market_price",
    "post_only": false,
    "order_type": "stop_market",
    "order_state": "untriggered",
    "order_id": "ETH-SLIS-12",
    "max_show": 5,
    "last_update_timestamp": 1550575961291,
    "label": "",
    "is_liquidation": false,
    "instrument_name": "ETH-PERPETUAL",
    "direction": "sell",
    "creation_timestamp": 1550575961291,
    "api": false,
    "amount": 5
  }
}

Cancel an order, specified by order id

Try in API console

Parameters

Parameter Required Type Enum Description
order_id true string The order id

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

/private/cancel_all

curl -X GET "https://test.deribit.com/api/v2/private/cancel_all?" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8748,
  "method" : "private/cancel_all",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8748,
  "method" : "private/cancel_all",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 8748,
  "result": 37
}

This method cancels all users orders and stop orders within all currencies and instrument kinds.

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
object
result number Total number of successfully cancelled orders

/private/cancel_all_by_currency

curl -X GET "https://test.deribit.com/api/v2/private/cancel_all_by_currency?currency=BTC&kind=option" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 5663,
  "method" : "private/cancel_all_by_currency",
  "params" : {
    "currency" : "BTC",
    "kind" : "option"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 5663,
  "method" : "private/cancel_all_by_currency",
  "params" : {
    "currency" : "BTC",
    "kind" : "option"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 5663,
  "result": 3
}

Cancels all orders by currency, optionally filtered by instrument kind and/or order type.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
kind false string future
option
Instrument kind, if not provided instruments of all kinds are considered
type false string all
limit
stop
Order type - limit, stop or all, default - all

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
object
result number Total number of successfully cancelled orders

/private/cancel_all_by_instrument

curl -X GET "https://test.deribit.com/api/v2/private/cancel_all_by_instrument?instrument_name=ETH-22FEB19-120-P&type=all" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 4122,
  "method" : "private/cancel_all_by_instrument",
  "params" : {
    "instrument_name" : "ETH-22FEB19-120-P",
    "type" : "all"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 4122,
  "method" : "private/cancel_all_by_instrument",
  "params" : {
    "instrument_name" : "ETH-22FEB19-120-P",
    "type" : "all"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 4122,
  "result": 7
}

Cancels all orders by instrument, optionally filtered by order type.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
type false string all
limit
stop
Order type - limit, stop or all, default - all

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
object
result number Total number of successfully cancelled orders

/private/cancel_by_label

curl -X GET "https://test.deribit.com/api/v2/private/cancel_by_label?label=label" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "id" : 47,
  "method" : "private/cancel_by_label",
  "params" : {
    "label" : "label"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "id" : 47,
  "method" : "private/cancel_by_label",
  "params" : {
    "label" : "label"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc":"2.0",
  "id":47,
  "result":4
}

Cancels orders by label. All user's orders (stop orders too), with given label are canceled in all currencies

Try in API console

Parameters

Parameter Required Type Enum Description
label true string user defined label for the order (maximum 64 characters)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
object
result number Total number of successfully cancelled orders

/private/close_position

curl -X GET "https://test.deribit.com/api/v2/private/close_position?instrument_name=ETH-PERPETUAL&price=1.45169999999999987494e%2B02&type=limit" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 6130,
  "method" : "private/close_position",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "type" : "limit",
    "price" : 145.17
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 6130,
  "method" : "private/close_position",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "type" : "limit",
    "price" : 145.17
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 6130,
  "result": {
    "trades": [
      {
        "trade_seq": 1966068,
        "trade_id": "ETH-2696097",
        "timestamp": 1590486335742,
        "tick_direction": 0,
        "state": "filled",
        "self_trade": false,
        "reduce_only": true,
        "price": 202.8,
        "post_only": false,
        "order_type": "limit",
        "order_id": "ETH-584864807",
        "matching_id": null,
        "mark_price": 202.79,
        "liquidity": "T",
        "instrument_name": "ETH-PERPETUAL",
        "index_price": 202.86,
        "fee_currency": "ETH",
        "fee": 0.00007766,
        "direction": "sell",
        "amount": 21
      }
    ],
    "order": {
      "web": false,
      "time_in_force": "good_til_cancelled",
      "replaced": false,
      "reduce_only": true,
      "profit_loss": -0.00025467,
      "price": 198.75,
      "post_only": false,
      "order_type": "limit",
      "order_state": "filled",
      "order_id": "ETH-584864807",
      "max_show": 21,
      "last_update_timestamp": 1590486335742,
      "label": "",
      "is_liquidation": false,
      "instrument_name": "ETH-PERPETUAL",
      "filled_amount": 21,
      "direction": "sell",
      "creation_timestamp": 1590486335742,
      "commission": 0.00007766,
      "average_price": 202.8,
      "api": true,
      "amount": 21
    }
  }
}

Makes closing position reduce only order .

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
type true string limit
market
The order type
price false number Optional price for limit order.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  order object
  ›    ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›    ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›    ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›    ›  api boolean true if created with API
  ›    ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  web boolean true if created via Deribit frontend (optional)
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›    ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›    ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›    ›  original_order_type string Original order type. Optional field
  ›    ›  price number Price in base currency
  ›    ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›    ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›    ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›    ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  post_only boolean true for post-only orders only
  ›    ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›    ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  average_price number Average fill price of the order
  ›    ›  order_id string Unique order identifier
  ›    ›  reduce_only boolean true for reduce-only orders only
  ›    ›  commission number Commission paid so far (in base currency)
  ›    ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›    ›  stop_price number Stop price (Only for future stop orders)
  ›    ›  label string User defined label (up to 64 characters)
  ›    ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  direction string Direction: buy, or sell
  ›    ›  is_liquidation boolean true if order was automatically created during liquidation
  ›    ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›    ›  usd number Option price in USD (Only if advanced="usd")
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›    ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/get_margins

curl -X GET "https://test.deribit.com/api/v2/private/get_margins?amount=10000&instrument_name=BTC-PERPETUAL&price=3725" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7,
  "method" : "private/get_margins",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "amount" : 10000,
    "price" : 3725
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7,
  "method" : "private/get_margins",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "amount" : 10000,
    "price" : 3725
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this:

{
    "jsonrpc": "2.0",
    "result": {
        "buy": 0.01681367,
        "max_price": 42.0,
        "min_price": 42.0,
        "sell": 0.01680479
    }
}

Get margins for given instrument, amount and price.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
amount true number Amount, integer for future, float for option. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
price true number Price

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  buy number Margin when buying
  ›  max_price number The maximum price for the future. Any buy orders you submit higher than this price, will be clamped to this maximum.
  ›  min_price number The minimum price for the future. Any sell orders you submit lower than this price will be clamped to this minimum.
  ›  sell number Margin when selling

/private/get_mmp_config

curl -X GET "https://test.deribit.com/api/v2/private/get_mmp_config?currency=BTC" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7859,
  "method" : "private/get_mmp_config",
  "params" : {
    "currency" : "BTC"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7859,
  "method" : "private/get_mmp_config",
  "params" : {
    "currency" : "BTC"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7859,
  "result": {
    "currency": "BTC",
    "interval": 60,
    "frozen_time": 0,
    "quantity_limit": 0.5
  }
}

Get current config for MMP

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  delta_limit number Delta limit
  ›  frozen_time integer MMP frozen time in seconds, if set to 0 manual reset is required
  ›  interval integer MMP Interval in seconds, if set to 0 MMP is disabled
  ›  quantity_limit number Quantity limit

/private/get_open_orders_by_currency

curl -X GET "https://test.deribit.com/api/v2/private/get_open_orders_by_currency?currency=BTC" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 1953,
  "method" : "private/get_open_orders_by_currency",
  "params" : {
    "currency" : "BTC"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 1953,
  "method" : "private/get_open_orders_by_currency",
  "params" : {
    "currency" : "BTC"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 1953,
    "result": [
        {
            "time_in_force": "good_til_cancelled",
            "reduce_only": false,
            "profit_loss": 0,
            "price": 0.0028,
            "post_only": false,
            "order_type": "limit",
            "order_state": "open",
            "order_id": "146062",
            "max_show": 10,
            "last_update_timestamp": 1550050597036,
            "label": "",
            "is_liquidation": false,
            "instrument_name": "BTC-15FEB19-3250-P",
            "filled_amount": 0,
            "direction": "buy",
            "creation_timestamp": 1550050597036,
            "commission": 0,
            "average_price": 0,
            "api": true,
            "amount": 10
        }
    ]
}

Retrieves list of user's open orders.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
kind false string future
option
Instrument kind, if not provided instruments of all kinds are considered
type false string all
limit
stop_all
stop_limit
stop_market
Order type, default - all

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

/private/get_open_orders_by_instrument

curl -X GET "https://test.deribit.com/api/v2/private/get_open_orders_by_instrument?instrument_name=ETH-22FEB19-120-C" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8442,
  "method" : "private/get_open_orders_by_instrument",
  "params" : {
    "instrument_name" : "ETH-22FEB19-120-C"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8442,
  "method" : "private/get_open_orders_by_instrument",
  "params" : {
    "instrument_name" : "ETH-22FEB19-120-C"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 8442,
    "result": [
        {
            "time_in_force": "good_til_cancelled",
            "reduce_only": false,
            "profit_loss": 0,
            "price": 0.135,
            "post_only": false,
            "order_type": "limit",
            "order_state": "open",
            "order_id": "ETH-252017",
            "max_show": 10,
            "last_update_timestamp": 1550050594882,
            "label": "",
            "is_liquidation": false,
            "instrument_name": "ETH-22FEB19-120-C",
            "filled_amount": 0,
            "direction": "sell",
            "creation_timestamp": 1550050594882,
            "commission": 0,
            "average_price": 0,
            "api": true,
            "amount": 10
        }
    ]
}

Retrieves list of user's open orders within given Instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
type false string all
limit
stop_all
stop_limit
stop_market
Order type, default - all

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

/private/get_order_history_by_currency

curl -X GET "https://test.deribit.com/api/v2/private/get_order_history_by_currency?count=1&currency=BTC&kind=future" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9305,
  "method" : "private/get_order_history_by_currency",
  "params" : {
    "currency" : "BTC",
    "kind" : "future",
    "count" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9305,
  "method" : "private/get_order_history_by_currency",
  "params" : {
    "currency" : "BTC",
    "kind" : "future",
    "count" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9305,
  "result": [
    {
      "time_in_force": "good_til_cancelled",
      "reduce_only": false,
      "profit_loss": 0,
      "price": 3886.5,
      "post_only": false,
      "order_type": "limit",
      "order_state": "filled",
      "order_id": "146475",
      "max_show": 40,
      "last_update_timestamp": 1550661808761,
      "label": "",
      "is_liquidation": false,
      "instrument_name": "BTC-PERPETUAL",
      "filled_amount": 40,
      "direction": "buy",
      "creation_timestamp": 1550661808761,
      "commission": 0.00000547,
      "average_price": 3659.8,
      "api": true,
      "amount": 40
    }
  ]
}

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

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
kind false string future
option
Instrument kind, if not provided instruments of all kinds are considered
count false integer Number of requested items, default - 20
offset false integer The offset for pagination, default - 0
include_old false boolean Include in result orders older than 2 days, default - false
include_unfilled false boolean Include in result fully unfilled closed orders, default - false

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

/private/get_order_history_by_instrument

curl -X GET "https://test.deribit.com/api/v2/private/get_order_history_by_instrument?count=1&instrument_name=BTC-PERPETUAL" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 1032,
  "method" : "private/get_order_history_by_instrument",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "count" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 1032,
  "method" : "private/get_order_history_by_instrument",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "count" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 1032,
  "result": [
    {
      "time_in_force": "good_til_cancelled",
      "reduce_only": false,
      "profit_loss": 0,
      "price": 3886.5,
      "post_only": false,
      "order_type": "limit",
      "order_state": "filled",
      "order_id": "146475",
      "max_show": 40,
      "last_update_timestamp": 1550661808761,
      "label": "",
      "is_liquidation": false,
      "instrument_name": "BTC-PERPETUAL",
      "filled_amount": 40,
      "direction": "buy",
      "creation_timestamp": 1550661808761,
      "commission": 0.00000547,
      "average_price": 3659.8,
      "api": true,
      "amount": 40
    }
  ]
}

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

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
count false integer Number of requested items, default - 20
offset false integer The offset for pagination, default - 0
include_old false boolean Include in result orders older than 2 days, default - false
include_unfilled false boolean Include in result fully unfilled closed orders, default - false

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

/private/get_order_margin_by_ids

curl -X GET "https://test.deribit.com/api/v2/private/get_order_margin_by_ids?ids=%5B%22ETH-349280%22%2C%22ETH-349279%22%2C%22ETH-349278%22%5D" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 5625,
  "method" : "private/get_order_margin_by_ids",
  "params" : {
    "ids" : [
      "ETH-349280",
      "ETH-349279",
      "ETH-349278"
    ]
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 5625,
  "method" : "private/get_order_margin_by_ids",
  "params" : {
    "ids" : [
      "ETH-349280",
      "ETH-349279",
      "ETH-349278"
    ]
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 5625,
  "result": [
    {
      "order_id": "ETH-349278",
      "initial_margin": 0.00091156
    },
    {
      "order_id": "ETH-349279",
      "initial_margin": 0
    },
    {
      "order_id": "ETH-349280",
      "initial_margin": 0
    }
  ]
}

Retrieves initial margins of given orders

Try in API console

Parameters

Parameter Required Type Enum Description
ids true array Ids of orders

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  initial_margin number Initial margin of order, in base currency
  ›  order_id string Unique order identifier

/private/get_order_state

curl -X GET "https://test.deribit.com/api/v2/private/get_order_state?order_id=ETH-331562" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 4316,
  "method" : "private/get_order_state",
  "params" : {
    "order_id" : "ETH-331562"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 4316,
  "method" : "private/get_order_state",
  "params" : {
    "order_id" : "ETH-331562"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 4316,
  "result": {
    "time_in_force": "good_til_cancelled",
    "reduce_only": false,
    "profit_loss": 0.051134,
    "price": 118.94,
    "post_only": false,
    "order_type": "limit",
    "order_state": "filled",
    "order_id": "ETH-331562",
    "max_show": 37,
    "last_update_timestamp": 1550219810944,
    "label": "",
    "is_liquidation": false,
    "instrument_name": "ETH-PERPETUAL",
    "filled_amount": 37,
    "direction": "sell",
    "creation_timestamp": 1550219749176,
    "commission": 0.000031,
    "average_price": 118.94,
    "api": false,
    "amount": 37
  }
}

Retrieve the current state of an order.

Try in API console

Parameters

Parameter Required Type Enum Description
order_id true string The order id

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

/private/get_stop_order_history

curl -X GET "https://test.deribit.com/api/v2/private/get_stop_order_history?count=10&currency=ETH" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2552,
  "method" : "private/get_stop_order_history",
  "params" : {
    "currency" : "ETH",
    "count" : 10
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2552,
  "method" : "private/get_stop_order_history",
  "params" : {
    "currency" : "ETH",
    "count" : 10
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2192,
  "result": [
    {
      "trigger": "index",
      "timestamp": 1555918941451,
      "stop_price": 5285,
      "stop_id": "SLIS-103",
      "order_state": "new",
      "request": "trigger:order",
      "price": 5179.28,
      "order_id": "671473",
      "offset": 277,
      "instrument_name": "BTC-PERPETUAL",
      "amount": 10,
      "direction": "buy"
    }
  ]
}

Retrieves detailed log of the user's stop-orders.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
instrument_name false string Instrument name
count false integer Number of requested items, default - 20
continuation false string Continuation token for pagination

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  continuation string Continuation token for pagination.
  ›  entries array of object
  ›    ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  direction string Direction: buy, or sell
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  order_id string Unique order identifier
  ›    ›  order_state string Order state: "triggered", "cancelled", or "rejected" with rejection reason (e.g. "rejected:reduce_direction").
  ›    ›  order_type string Requested order type: "limit or "market"
  ›    ›  post_only boolean true for post-only orders only
  ›    ›  price number Price in base currency
  ›    ›  reduce_only boolean true for reduce-only orders only
  ›    ›  request string Type of last request performed on the stop order by user or system. "cancel" - when order was cancelled, "trigger:order" - when stop order spawned market or limit order after being triggered
  ›    ›  stop_id string Id of the user stop-order used for the stop-order reference before triggering
  ›    ›  stop_price number Stop price (Only for future stop orders)
  ›    ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

/private/get_user_trades_by_currency

curl -X GET "https://test.deribit.com/api/v2/private/get_user_trades_by_currency?count=2&currency=ETH&start_id=ETH-34066" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9367,
  "method" : "private/get_user_trades_by_currency",
  "params" : {
    "currency" : "ETH",
    "start_id" : "ETH-34066",
    "count" : 2
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9367,
  "method" : "private/get_user_trades_by_currency",
  "params" : {
    "currency" : "ETH",
    "start_id" : "ETH-34066",
    "count" : 2
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9367,
  "result": {
    "trades": [
      {
        "underlying_price": 204.5,
        "trade_seq": 3,
        "trade_id": "ETH-2696060",
        "timestamp": 1590480363130,
        "tick_direction": 2,
        "state": "filled",
        "self_trade": false,
        "reduce_only": false,
        "price": 0.361,
        "post_only": false,
        "order_type": "limit",
        "order_id": "ETH-584827850",
        "matching_id": null,
        "mark_price": 0.364585,
        "liquidity": "T",
        "iv": 0,
        "instrument_name": "ETH-29MAY20-130-C",
        "index_price": 203.72,
        "fee_currency": "ETH",
        "fee": 0.002,
        "direction": "sell",
        "amount": 5
      },
      {
        "underlying_price": 204.82,
        "trade_seq": 3,
        "trade_id": "ETH-2696062",
        "timestamp": 1590480416119,
        "tick_direction": 0,
        "state": "filled",
        "self_trade": false,
        "reduce_only": false,
        "price": 0.015,
        "post_only": false,
        "order_type": "limit",
        "order_id": "ETH-584828229",
        "matching_id": null,
        "mark_price": 0.000596,
        "liquidity": "T",
        "iv": 352.91,
        "instrument_name": "ETH-29MAY20-140-P",
        "index_price": 204.06,
        "fee_currency": "ETH",
        "fee": 0.002,
        "direction": "buy",
        "amount": 5
      }
    ],
    "has_more": true
  }
}

Retrieve the latest user trades that have occurred for instruments in a specific currency symbol.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
kind false string future
option
Instrument kind, if not provided instruments of all kinds are considered
start_id false string The ID number of the first trade to be returned
end_id false string The ID number of the last trade to be returned
count false integer Number of requested items, default - 10
include_old false boolean Include trades older than a few recent days, default - false
sorting false string asc
desc
default
Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  has_more boolean
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/get_user_trades_by_currency_and_time

curl -X GET "https://test.deribit.com/api/v2/private/get_user_trades_by_currency_and_time?count=2&currency=BTC&end_timestamp=1510480630731&start_timestamp=1590480630731" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9292,
  "method" : "private/get_user_trades_by_currency_and_time",
  "params" : {
    "currency" : "BTC",
    "start_timestamp" : 1590480630731,
    "end_timestamp" : 1510480630731,
    "count" : 2
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9292,
  "method" : "private/get_user_trades_by_currency_and_time",
  "params" : {
    "currency" : "BTC",
    "start_timestamp" : 1590480630731,
    "end_timestamp" : 1510480630731,
    "count" : 2
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9292,
  "result": {
    "trades": [
      {
        "underlying_price": 8994.95,
        "trade_seq": 1,
        "trade_id": "48078936",
        "timestamp": 1590480620145,
        "tick_direction": 1,
        "state": "filled",
        "self_trade": false,
        "reduce_only": false,
        "price": 0.028,
        "post_only": false,
        "order_type": "limit",
        "order_id": "4008699030",
        "matching_id": null,
        "mark_price": 0.03135383,
        "liquidity": "M",
        "iv": 38.51,
        "instrument_name": "BTC-27MAY20-8750-C",
        "index_price": 8993.47,
        "fee_currency": "BTC",
        "fee": 0.0004,
        "direction": "sell",
        "amount": 1
      },
      {
        "trade_seq": 299513,
        "trade_id": "47958936",
        "timestamp": 1589923311862,
        "tick_direction": 2,
        "state": "filled",
        "self_trade": false,
        "reduce_only": false,
        "price": 9681.5,
        "post_only": false,
        "order_type": "limit",
        "order_id": "3993343822",
        "matching_id": null,
        "mark_price": 9684,
        "liquidity": "M",
        "instrument_name": "BTC-26JUN20",
        "index_price": 9679.48,
        "fee_currency": "BTC",
        "fee": -2.1e-7,
        "direction": "buy",
        "amount": 10
      }
    ],
    "has_more": false
  }
}

Retrieve the latest user trades that have occurred for instruments in a specific currency symbol and within given time range.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
kind false string future
option
Instrument kind, if not provided instruments of all kinds are considered
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for
count false integer Number of requested items, default - 10
include_old false boolean Include trades older than a few recent days, default - false
sorting false string asc
desc
default
Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  has_more boolean
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/get_user_trades_by_instrument

curl -X GET "https://test.deribit.com/api/v2/private/get_user_trades_by_instrument?count=2&instrument_name=ETH-PERPETUAL&start_seq=1966042" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 5728,
  "method" : "private/get_user_trades_by_instrument",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "start_seq" : 1966042,
    "count" : 2
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 5728,
  "method" : "private/get_user_trades_by_instrument",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "start_seq" : 1966042,
    "count" : 2
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 5728,
  "result": {
    "trades": [
      {
        "trade_seq": 1966042,
        "trade_id": "ETH-2696068",
        "timestamp": 1590480712800,
        "tick_direction": 3,
        "state": "filled",
        "self_trade": false,
        "reduce_only": false,
        "price": 203.8,
        "post_only": false,
        "order_type": "market",
        "order_id": "ETH-584830574",
        "matching_id": null,
        "mark_price": 203.78,
        "liquidity": "T",
        "instrument_name": "ETH-PERPETUAL",
        "index_price": 203.89,
        "fee_currency": "ETH",
        "fee": 0.00036801,
        "direction": "buy",
        "amount": 100
      },
      {
        "trade_seq": 1966043,
        "trade_id": "ETH-2696069",
        "timestamp": 1590480724473,
        "tick_direction": 3,
        "state": "filled",
        "self_trade": false,
        "reduce_only": false,
        "price": 203.8,
        "post_only": false,
        "order_type": "market",
        "order_id": "ETH-584830695",
        "matching_id": null,
        "mark_price": 203.81,
        "liquidity": "T",
        "instrument_name": "ETH-PERPETUAL",
        "index_price": 203.92,
        "fee_currency": "ETH",
        "fee": 0.00036801,
        "direction": "sell",
        "amount": 100
      }
    ],
    "has_more": true
  }
}

Retrieve the latest user trades that have occurred for a specific instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
start_seq false integer The sequence number of the first trade to be returned
end_seq false integer The sequence number of the last trade to be returned
count false integer Number of requested items, default - 10
include_old false boolean Include trades older than a few recent days, default - false
sorting false string asc
desc
default
Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  has_more boolean
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/get_user_trades_by_instrument_and_time

curl -X GET "https://test.deribit.com/api/v2/private/get_user_trades_by_instrument_and_time?count=2&end_timestamp=1590480872894&instrument_name=BTC-PERPETUAL&start_timestamp=1590470872894" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 276,
  "method" : "private/get_user_trades_by_instrument_and_time",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "start_timestamp" : 1590470872894,
    "end_timestamp" : 1590480872894,
    "count" : 2
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 276,
  "method" : "private/get_user_trades_by_instrument_and_time",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "start_timestamp" : 1590470872894,
    "end_timestamp" : 1590480872894,
    "count" : 2
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 276,
  "result": {
    "trades": [
      {
        "trade_seq": 30289127,
        "trade_id": "48078944",
        "timestamp": 1590480866924,
        "tick_direction": 2,
        "state": "filled",
        "self_trade": false,
        "reduce_only": false,
        "price": 8988.5,
        "post_only": false,
        "order_type": "limit",
        "order_id": "4008716877",
        "matching_id": null,
        "mark_price": 8990.52,
        "liquidity": "T",
        "instrument_name": "BTC-PERPETUAL",
        "index_price": 8995.15,
        "fee_currency": "BTC",
        "fee": 0.00037465,
        "direction": "sell",
        "amount": 4490
      },
      {
        "trade_seq": 30289128,
        "trade_id": "48078945",
        "timestamp": 1590480866924,
        "tick_direction": 2,
        "state": "filled",
        "self_trade": false,
        "reduce_only": false,
        "price": 8983.5,
        "post_only": false,
        "order_type": "limit",
        "order_id": "4008716877",
        "matching_id": null,
        "mark_price": 8990.52,
        "liquidity": "T",
        "instrument_name": "BTC-PERPETUAL",
        "index_price": 8995.15,
        "fee_currency": "BTC",
        "fee": 0.00001503,
        "direction": "sell",
        "amount": 180
      }
    ],
    "has_more": true
  }
}

Retrieve the latest user trades that have occurred for a specific instrument and within given time range.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for
count false integer Number of requested items, default - 10
include_old false boolean Include trades older than a few recent days, default - false
sorting false string asc
desc
default
Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  has_more boolean
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

/private/get_user_trades_by_order

curl -X GET "https://test.deribit.com/api/v2/private/get_user_trades_by_order?order_id=ETH-584830574" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3466,
  "method" : "private/get_user_trades_by_order",
  "params" : {
    "order_id" : "ETH-584830574"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3466,
  "method" : "private/get_user_trades_by_order",
  "params" : {
    "order_id" : "ETH-584830574"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 3466,
  "result": [
    {
      "trade_seq": 1966042,
      "trade_id": "ETH-2696068",
      "timestamp": 1590480712800,
      "tick_direction": 3,
      "state": "filled",
      "self_trade": false,
      "reduce_only": false,
      "price": 203.8,
      "post_only": false,
      "order_type": "market",
      "order_id": "ETH-584830574",
      "matching_id": null,
      "mark_price": 203.78,
      "liquidity": "T",
      "instrument_name": "ETH-PERPETUAL",
      "index_price": 203.89,
      "fee_currency": "ETH",
      "fee": 0.00036801,
      "direction": "buy",
      "amount": 100
    }
  ]
}

Retrieve the list of user trades that was created for given order

Try in API console

Parameters

Parameter Required Type Enum Description
order_id true string The order id
sorting false string asc
desc
default
Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
array of amount number
block_trade_id string Block trade id - when trade was part of block trade
direction string Direction: buy, or sell
fee number User's fee in units of the specified fee_currency
fee_currency string Currency, i.e "BTC", "ETH", "USDT"
index_price number Index Price at the moment of trade
instrument_name string Unique instrument identifier
iv number Option implied volatility for the price (Option only)
label string User defined label (presented only when previously set for order by user)
liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
mark_price number Mark Price at the moment of trade
matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
order_type string Order type: "limit, "market", or "liquidation"
post_only string true if user order is post-only
price number Price in base currency
profit_loss number Profit and loss in base currency.
reduce_only string true if user order is reduce-only
self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
timestamp integer The timestamp of the trade
trade_id string Unique (per currency) trade identifier
trade_seq integer The sequence number of the trade within instrument
underlying_price number Underlying price for implied volatility calculations (Options only)

/private/reset_mmp

curl -X GET "https://test.deribit.com/api/v2/private/reset_mmp?currency=BTC" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7859,
  "method" : "private/reset_mmp",
  "params" : {
    "currency" : "BTC"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7859,
  "method" : "private/reset_mmp",
  "params" : {
    "currency" : "BTC"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7859,
  "result": "ok"
}

Reset MMP

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/set_mmp_config

curl -X GET "https://test.deribit.com/api/v2/private/set_mmp_config?currency=BTC&frozen_time=0&interval=60&quantity_limit=3.00000000000000000000e%2B00" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7859,
  "method" : "private/set_mmp_config",
  "params" : {
    "currency" : "BTC",
    "interval" : 60,
    "frozen_time" : 0,
    "quantity_limit" : 3.0
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7859,
  "method" : "private/set_mmp_config",
  "params" : {
    "currency" : "BTC",
    "interval" : 60,
    "frozen_time" : 0,
    "quantity_limit" : 3.0
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7859,
  "result": "ok"
}

Set config for MMP - triggers MMP reset

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
interval true integer MMP Interval in seconds, if set to 0 MMP is disabled
frozen_time true integer MMP frozen time in seconds, if set to 0 manual reset is required
quantity_limit false number Quantity limit
delta_limit false number Delta limit

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result string Result of method execution. ok in case of success

/private/get_settlement_history_by_instrument

curl -X GET "https://test.deribit.com/api/v2/private/get_settlement_history_by_instrument?count=1&instrument_name=ETH-22FEB19&type=settlement" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2192,
  "method" : "private/get_settlement_history_by_instrument",
  "params" : {
    "instrument_name" : "ETH-22FEB19",
    "type" : "settlement",
    "count" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2192,
  "method" : "private/get_settlement_history_by_instrument",
  "params" : {
    "instrument_name" : "ETH-22FEB19",
    "type" : "settlement",
    "count" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2192,
  "result": {
    "settlements": [
      {
        "type": "settlement",
        "timestamp": 1550475692526,
        "session_profit_loss": 0.038358299,
        "profit_loss": -0.001783937,
        "position": -66,
        "mark_price": 121.67,
        "instrument_name": "ETH-22FEB19",
        "index_price": 119.8
      }
    ],
    "continuation": "xY7T6cusbMBNpH9SNmKb94jXSBxUPojJEdCPL4YociHBUgAhWQvEP"
  }
}

Retrieves public settlement, delivery and bankruptcy events filtered by instrument name

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
type false string settlement
delivery
bankruptcy
Settlement type
count false integer Number of requested items, default - 20
continuation false string Continuation token for pagination
search_start_timestamp false integer The latest timestamp to return result for

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  continuation string Continuation token for pagination.
  ›  settlements array of object
  ›    ›  funded number funded amount (bankruptcy only)
  ›    ›  funding number funding (in base currency ; settlement for perpetual product only)
  ›    ›  index_price number underlying index price at time of event (in quote currency; settlement and delivery only)
  ›    ›  instrument_name string instrument name (settlement and delivery only)
  ›    ›  mark_price number mark price for at the settlement time (in quote currency; settlement and delivery only)
  ›    ›  position number position size (in quote currency; settlement and delivery only)
  ›    ›  profit_loss number profit and loss (in base currency; settlement and delivery only)
  ›    ›  session_bankrupcy number value of session bankrupcy (in base currency; bankruptcy only)
  ›    ›  session_profit_loss number total value of session profit and losses (in base currency)
  ›    ›  session_tax number total amount of paid taxes/fees (in base currency; bankruptcy only)
  ›    ›  session_tax_rate number rate of paid texes/fees (in base currency; bankruptcy only)
  ›    ›  socialized number the amount of the socialized losses (in base currency; bankruptcy only)
  ›    ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  type string The type of settlement. settlement, delivery or bankruptcy.

/private/get_settlement_history_by_currency

curl -X GET "https://test.deribit.com/api/v2/private/get_settlement_history_by_currency?count=1&currency=BTC&type=delivery" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8304,
  "method" : "private/get_settlement_history_by_currency",
  "params" : {
    "currency" : "BTC",
    "type" : "delivery",
    "count" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8304,
  "method" : "private/get_settlement_history_by_currency",
  "params" : {
    "currency" : "BTC",
    "type" : "delivery",
    "count" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 6074,
  "result": {
    "settlements": [
      {
        "type": "delivery",
        "timestamp": 1550242800013,
        "session_profit_loss": 1.567969302,
        "profit_loss": -0.251617338,
        "position": 13,
        "mark_price": 0.121679828,
        "instrument_name": "BTC-15FEB19-4000-P",
        "index_price": 3566.08
      }
    ],
    "continuation": "AHmpC39UH5EeGVjryrf731YEhjL16oqCQorSvBFZFAbbwvCN7GCbMFgno7U5JKW"
  }
}

Retrieves settlement, delivery and bankruptcy events that have affected your account.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
type false string settlement
delivery
bankruptcy
Settlement type
count false integer Number of requested items, default - 20
continuation false string Continuation token for pagination
search_start_timestamp false integer The latest timestamp to return result for

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  continuation string Continuation token for pagination.
  ›  settlements array of object
  ›    ›  funded number funded amount (bankruptcy only)
  ›    ›  funding number funding (in base currency ; settlement for perpetual product only)
  ›    ›  index_price number underlying index price at time of event (in quote currency; settlement and delivery only)
  ›    ›  instrument_name string instrument name (settlement and delivery only)
  ›    ›  mark_price number mark price for at the settlement time (in quote currency; settlement and delivery only)
  ›    ›  position number position size (in quote currency; settlement and delivery only)
  ›    ›  profit_loss number profit and loss (in base currency; settlement and delivery only)
  ›    ›  session_bankrupcy number value of session bankrupcy (in base currency; bankruptcy only)
  ›    ›  session_profit_loss number total value of session profit and losses (in base currency)
  ›    ›  session_tax number total amount of paid taxes/fees (in base currency; bankruptcy only)
  ›    ›  session_tax_rate number rate of paid texes/fees (in base currency; bankruptcy only)
  ›    ›  socialized number the amount of the socialized losses (in base currency; bankruptcy only)
  ›    ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  type string The type of settlement. settlement, delivery or bankruptcy.

Market data

/public/get_book_summary_by_currency

curl -X GET "https://test.deribit.com/api/v2/public/get_book_summary_by_currency?currency=BTC&kind=future" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9344,
  "method" : "public/get_book_summary_by_currency",
  "params" : {
    "currency" : "BTC",
    "kind" : "future"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9344,
  "method" : "public/get_book_summary_by_currency",
  "params" : {
    "currency" : "BTC",
    "kind" : "future"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9344,
  "result": [
    {
      "volume_usd": 0,
      "volume": 0,
      "quote_currency": "USD",
      "price_change": -11.1896349,
      "open_interest": 0,
      "mid_price": null,
      "mark_price": 3579.73,
      "low": null,
      "last": null,
      "instrument_name": "BTC-22FEB19",
      "high": null,
      "estimated_delivery_price": 3579.73,
      "creation_timestamp": 1550230036440,
      "bid_price": null,
      "base_currency": "BTC",
      "ask_price": null
    },
    {
      "volume_usd": 22440,
      "volume": 6.24,
      "quote_currency": "USD",
      "price_change": -60.8183509,
      "open_interest": 183180,
      "mid_price": null,
      "mark_price": 3579.73,
      "low": 3591,
      "last": 3595,
      "instrument_name": "BTC-PERPETUAL",
      "high": 3595,
      "funding_8h": 0.0002574,
      "estimated_delivery_price": 3579.73,
      "current_funding": 0,
      "creation_timestamp": 1550230036440,
      "bid_price": null,
      "base_currency": "BTC",
      "ask_price": null
    }
  ]
}

Retrieves the summary information such as open interest, 24h volume, etc. for all instruments for the currency (optionally filtered by kind).

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
kind false string future
option
Instrument kind, if not provided instruments of all kinds are considered

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  ask_price number The current best ask price, null if there aren't any asks
  ›  base_currency string Base currency
  ›  bid_price number The current best bid price, null if there aren't any bids
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  current_funding number Current funding (perpetual only)
  ›  estimated_delivery_price number Estimated delivery price, in USD. For more details, see Documentation > General > Expiration Price
  ›  funding_8h number Funding 8h (perpetual only)
  ›  high number Price of the 24h highest trade
  ›  instrument_name string Unique instrument identifier
  ›  interest_rate number Interest rate used in implied volatility calculations (options only)
  ›  last number The price of the latest trade, null if there weren't any trades
  ›  low number Price of the 24h lowest trade, null if there weren't any trades
  ›  mark_price number The current instrument market price
  ›  mid_price number The average of the best bid and ask, null if there aren't any asks or bids
  ›  open_interest number The total amount of outstanding contracts in the corresponding amount units. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  price_change number 24-hour price change expressed as a percentage, null if there weren't any trades
  ›  quote_currency string Quote currency
  ›  underlying_index string Name of the underlying future, or 'index_price' (options only)
  ›  underlying_price number underlying price for implied volatility calculations (options only)
  ›  volume number The total 24h traded volume (in base currency)
  ›  volume_usd number Volume in usd (futures only)

/public/get_book_summary_by_instrument

curl -X GET "https://test.deribit.com/api/v2/public/get_book_summary_by_instrument?instrument_name=ETH-22FEB19-140-P" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3659,
  "method" : "public/get_book_summary_by_instrument",
  "params" : {
    "instrument_name" : "ETH-22FEB19-140-P"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3659,
  "method" : "public/get_book_summary_by_instrument",
  "params" : {
    "instrument_name" : "ETH-22FEB19-140-P"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 3659,
  "result": [
    {
      "volume": 0.55,
      "underlying_price": 121.38,
      "underlying_index": "index_price",
      "quote_currency": "USD",
      "price_change": -26.7793594,
      "open_interest": 0.55,
      "mid_price": 0.2444,
      "mark_price": 0.179112,
      "low": 0.34,
      "last": 0.34,
      "interest_rate": 0.207,
      "instrument_name": "ETH-22FEB19-140-P",
      "high": 0.34,
      "creation_timestamp": 1550227952163,
      "bid_price": 0.1488,
      "base_currency": "ETH",
      "ask_price": 0.34
    }
  ]
}

Retrieves the summary information such as open interest, 24h volume, etc. for a specific instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  ask_price number The current best ask price, null if there aren't any asks
  ›  base_currency string Base currency
  ›  bid_price number The current best bid price, null if there aren't any bids
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  current_funding number Current funding (perpetual only)
  ›  estimated_delivery_price number Estimated delivery price, in USD. For more details, see Documentation > General > Expiration Price
  ›  funding_8h number Funding 8h (perpetual only)
  ›  high number Price of the 24h highest trade
  ›  instrument_name string Unique instrument identifier
  ›  interest_rate number Interest rate used in implied volatility calculations (options only)
  ›  last number The price of the latest trade, null if there weren't any trades
  ›  low number Price of the 24h lowest trade, null if there weren't any trades
  ›  mark_price number The current instrument market price
  ›  mid_price number The average of the best bid and ask, null if there aren't any asks or bids
  ›  open_interest number The total amount of outstanding contracts in the corresponding amount units. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  price_change number 24-hour price change expressed as a percentage, null if there weren't any trades
  ›  quote_currency string Quote currency
  ›  underlying_index string Name of the underlying future, or 'index_price' (options only)
  ›  underlying_price number underlying price for implied volatility calculations (options only)
  ›  volume number The total 24h traded volume (in base currency)
  ›  volume_usd number Volume in usd (futures only)

/public/get_contract_size

curl -X GET "https://test.deribit.com/api/v2/public/get_contract_size?instrument_name=BTC-PERPETUAL" \
-H "Content-Type: application/json"
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/get_contract_size",
     "id": 42,
     "params": {
        "instrument_name": "BTC-PERPETUAL"}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
    {"jsonrpc": "2.0",
     "method": "public/get_contract_size",
     "id": 42,
     "params": {
        "instrument_name": "BTC-PERPETUAL"}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this:

{
    "jsonrpc": "2.0",
    "result": {
        "contract_size": 10
    }
}

Retrieves contract size of provided instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  contract_size integer Contract size, for futures in USD, for options in base currency of the instrument (BTC, ETH, ...)

/public/get_currencies

curl -X GET "https://test.deribit.com/api/v2/public/get_currencies?" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7538,
  "method" : "public/get_currencies",
  "params" : {

  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7538,
  "method" : "public/get_currencies",
  "params" : {

  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7538,
  "result": [
      {
          "coin_type": "ETHER",
          "currency": "ETH",
          "currency_long": "Ethereum",
          "fee_precision": 4,
          "min_confirmations": 1,
          "min_withdrawal_fee": 0.0001,
          "withdrawal_fee": 0.0006,
          "withdrawal_priorities": []
      },
      {
          "coin_type": "BITCOIN",
          "currency": "BTC",
          "currency_long": "Bitcoin",
          "fee_precision": 4,
          "min_confirmations": 1,
          "min_withdrawal_fee": 0.0001,
          "withdrawal_fee": 0.0001,
          "withdrawal_priorities": [
              {
                  "value": 0.15,
                  "name": "very_low"
              },
              {
                  "value": 1.5,
                  "name": "very_high"
              }
          ]
      }
  ]
}    

Retrieves all cryptocurrencies supported by the API.

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  coin_type string The type of the currency.
  ›  currency string The abbreviation of the currency. This abbreviation is used elsewhere in the API to identify the currency.
  ›  currency_long string The full name for the currency.
  ›  fee_precision integer fee precision
  ›  min_confirmations integer Minimum number of block chain confirmations before deposit is accepted.
  ›  min_withdrawal_fee number The minimum transaction fee paid for withdrawals
  ›  withdrawal_fee number The total transaction fee paid for withdrawals
  ›  withdrawal_priorities array of object
  ›    ›  name string
  ›    ›  value number

/public/get_funding_chart_data

curl -X GET "https://test.deribit.com/api/v2/public/get_funding_chart_data?instrument_name=BTC-PERPETUAL&length=8h" \
-H "Content-Type: application/json"
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/get_funding_chart_data",
     "id": 42,
     "params": {
        "instrument_name": "BTC-PERPETUAL",
        "length": "8h"}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
    {"jsonrpc": "2.0",
     "method": "public/get_funding_chart_data",
     "id": 42,
     "params": {
        "instrument_name": "BTC-PERPETUAL",
        "length": "8h"}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this:

{
    "jsonrpc": "2.0",
    "result": {
        "current_interest": 0.0050006706,
        "data": [{
                "index_price": 8247.27,
                "interest_8h": 0.0049995114,
                "timestamp": 1536569522277
            }],
        "interest_8h": 0.0040080897
    }
}

Retrieve the latest user trades that have occurred for PERPETUAL instruments in a specific currency symbol and within given time range.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
length true string 8h
24h
1m
Specifies time period. 8h - 8 hours, 24h - 24 hours, 1m - 1 month

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  current_interest number Current interest
  ›  data array of object
  ›    ›  index_price number Current index price
  ›    ›  interest_8h number Historical interest 8h value
  ›    ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  interest_8h number Current interest 8h

/public/get_funding_rate_history

curl -X GET "https://test.deribit.com/api/v2/public/get_funding_rate_history?end_timestamp=1569902400000&instrument_name=BTC-PERPETUAL&start_timestamp=1569888000000" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7617,
  "method" : "public/get_funding_rate_history",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "start_timestamp" : 1569888000000,
    "end_timestamp" : 1569902400000
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7617,
  "method" : "public/get_funding_rate_history",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "start_timestamp" : 1569888000000,
    "end_timestamp" : 1569902400000
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7617,
  "result": [
    {
      "timestamp": 1569891600000,
      "index_price": 8222.87,
      "prev_index_price": 8305.72,
      "interest_8h": -0.00009234260068476106,
      "interest_1h": -4.739622041017375e-7
    },
    {
      "timestamp": 1569895200000,
      "index_price": 8286.49,
      "prev_index_price": 8222.87,
      "interest_8h": -0.00006720918180255509,
      "interest_1h": -2.8583510923267753e-7
    },
    {
      "timestamp": 1569898800000,
      "index_price": 8431.97,
      "prev_index_price": 8286.49,
      "interest_8h": -0.00003544496169694662,
      "interest_1h": -0.000003815906848177951
    },
    {
      "timestamp": 1569902400000,
      "index_price": 8422.36,
      "prev_index_price": 8431.97,
      "interest_8h": -0.00001404147515584998,
      "interest_1h": 8.312033064379086e-7
    }
  ]
}

Retrieves hourly historical interest rate for requested PERPETUAL instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  index_price number Price in base currency
  ›  interest_1h float 1hour interest rate
  ›  interest_8h float 8hour interest rate
  ›  prev_index_price number Price in base currency
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

/public/get_funding_rate_value

curl -X GET "https://test.deribit.com/api/v2/public/get_funding_rate_value?end_timestamp=1569974400000&instrument_name=BTC-PERPETUAL&start_timestamp=1569888000000" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7617,
  "method" : "public/get_funding_rate_value",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "start_timestamp" : 1569888000000,
    "end_timestamp" : 1569974400000
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7617,
  "method" : "public/get_funding_rate_value",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "start_timestamp" : 1569888000000,
    "end_timestamp" : 1569974400000
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7617,
  "result": -0.00025056853702101664
}

Retrieves interest rate value for requested period. Applicable only for PERPETUAL instruments.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result float

/public/get_historical_volatility

curl -X GET "https://test.deribit.com/api/v2/public/get_historical_volatility?currency=BTC" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8387,
  "method" : "public/get_historical_volatility",
  "params" : {
    "currency" : "BTC"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8387,
  "method" : "public/get_historical_volatility",
  "params" : {
    "currency" : "BTC"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 8387,
  "result": [
      [
          1549720800000,
          14.747743607344217
      ],
      [
          1549720800000,
          14.747743607344217
      ],
      [
          1549724400000,
          14.74257778551467
      ],
      [
          1549728000000,
          14.73502799931767
      ],
      [
          1549731600000,
          14.73502799931767
      ],
      [
          1549735200000,
          14.73502799931767
      ],
      [
          1550228400000,
          46.371891307340015
      ]
  ]
}

Provides information about historical volatility for given cryptocurrency.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of [timestamp, value]

/public/get_index

curl -X GET "https://test.deribit.com/api/v2/public/get_index?currency=BTC" \
-H "Content-Type: application/json"
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/get_index",
     "id": 42,
     "params": {
        "currency": "BTC"}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
    {"jsonrpc": "2.0",
     "method": "public/get_index",
     "id": 42,
     "params": {
        "currency": "BTC"}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this:

{
    "jsonrpc": "2.0",
    "result": {
        "BTC": 11628.81,
        "edp": 11628.81
    }
}

Retrieves the current index price for the instruments, for the selected currency.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  BTC number The current index price for BTC-USD (only for selected currency == BTC)
  ›  ETH number The current index price for ETH-USD (only for selected currency == ETH)
  ›  edp number Estimated delivery price for the currency. For more details, see Documentation > General > Expiration Price

/public/get_index_price

curl -X GET "https://test.deribit.com/api/v2/public/get_index_price?index_name=btc_usd" \
-H "Content-Type: application/json"
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/get_index_price",
     "id": 42,
     "params": {
        "index_name": "btc_usd"}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
    {"jsonrpc": "2.0",
     "method": "public/get_index_price",
     "id": 42,
     "params": {
        "index_name": "btc_usd"}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this:

{
    "jsonrpc": "2.0",
    "result": {
        "estimated_delivery_price": 11628.81,
        "index_price": 11628.81
    }
}

Retrieves the current index price value for given index name.

Try in API console

Parameters

Parameter Required Type Enum Description
index_name true string btc_usd
eth_usd
btc_usdt
eth_usdt
Index identifier, matches (base) cryptocurrency with quote currency

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  estimated_delivery_price number Estimated delivery price for the market. For more details, see Documentation > General > Expiration Price
  ›  index_price number Value of requested index

/public/get_index_price_names

curl -X GET "https://test.deribit.com/api/v2/public/get_index_price_names" \
-H "Content-Type: application/json"
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/get_index_price_names",
     "id": 42
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
    {"jsonrpc": "2.0",
     "method": "public/get_index_price_names",
     "id": 42
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7617,
  "result": [
    "btc_usd",
    "eth_usd",
    "btc_usdt",
    "eth_usdt"
  ]
}

Retrieves the identifiers of all supported Price Indexes

Try in API console

Parameters

This method takes no parameters

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of string

/public/get_instrument

curl -X GET "https://test.deribit.com/api/v2/public/get_instrument?instrument_name=BTC-12FEB21-31500-P" \
-H "Content-Type: application/json"
var msg = 
{
  "method" : "public/get_instrument",
  "params" : {
    "instrument_name" : "BTC-12FEB21-31500-P"
  },
  "jsonrpc" : "2.0",
  "id" : 0
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "method" : "public/get_instrument",
  "params" : {
    "instrument_name" : "BTC-12FEB21-31500-P"
  },
  "jsonrpc" : "2.0",
  "id" : 0
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 0,
  "result": {
    "tick_size": 0.0001,
    "taker_commission": 0.0005,
    "strike": 31500,
    "settlement_period": "week",
    "quote_currency": "USD",
    "option_type": "put",
    "min_trade_amount": 0.01,
    "maker_commission": 0.0001,
    "kind": "option",
    "is_active": true,
    "instrument_name": "BTC-12FEB21-31500-P",
    "expiration_timestamp": 1613116800000,
    "creation_timestamp": 1611658131000,
    "contract_size": 1,
    "block_trade_commission": 0.00015,
    "base_currency": "BTC"
  },
  "usIn": 1612272393029966,
  "usOut": 1612272393030246,
  "usDiff": 280,
  "testnet": false
}

Retrieves information about instrument

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  base_currency string The underlying currency being traded.
  ›  block_trade_commission number Block Trade commission for instrument
  ›  contract_size integer Contract size for instrument
  ›  creation_timestamp integer The time when the instrument was first created (milliseconds)
  ›  expiration_timestamp integer The time when the instrument will expire (milliseconds)
  ›  instrument_name string Unique instrument identifier
  ›  is_active boolean Indicates if the instrument can currently be traded.
  ›  kind string Instrument kind, "future" or "option"
  ›  leverage integer Maximal leverage for instrument, for futures only
  ›  maker_commission number Maker commission for instrument
  ›  min_trade_amount number Minimum amount for trading. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  option_type string The option type (only for options)
  ›  quote_currency string The currency in which the instrument prices are quoted.
  ›  settlement_period string The settlement period.
  ›  strike number The strike value. (only for options)
  ›  taker_commission number Taker commission for instrument
  ›  tick_size number specifies minimal price change and, as follows, the number of decimal places for instrument prices

/public/get_instruments

curl -X GET "https://test.deribit.com/api/v2/public/get_instruments?currency=BTC&expired=false&kind=future" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7617,
  "method" : "public/get_instruments",
  "params" : {
    "currency" : "BTC",
    "kind" : "future",
    "expired" : false
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7617,
  "method" : "public/get_instruments",
  "params" : {
    "currency" : "BTC",
    "kind" : "future",
    "expired" : False
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 7617,
  "result": [
    {
      "tick_size": 0.01,
      "taker_commission": 0.0005,
      "settlement_period": "week",
      "quote_currency": "USD",
      "min_trade_amount": 1,
      "maker_commission": 0.0001,
      "leverage": 100,
      "kind": "future",
      "is_active": true,
      "instrument_name": "BTC-26JUL19",
      "expiration_timestamp": 1564153200000,
      "creation_timestamp": 1563522420000,
      "contract_size": 10,
      "base_currency": "BTC"
    },
    {
      "tick_size": 0.01,
      "taker_commission": 0.0005,
      "settlement_period": "perpetual",
      "quote_currency": "USD",
      "min_trade_amount": 1,
      "maker_commission": 0.0001,
      "leverage": 100,
      "kind": "future",
      "is_active": true,
      "instrument_name": "BTC-PERPETUAL",
      "expiration_timestamp": 32503734000000,
      "creation_timestamp": 1554806122000,
      "contract_size": 10,
      "base_currency": "BTC"
    }
  ]
}

Retrieves available trading instruments. This method can be used to see which instruments are available for trading, or which instruments have recently expired.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
kind false string future
option
Instrument kind, if not provided instruments of all kinds are considered
expired false boolean Set to true to show recently expired instruments instead of active ones.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  base_currency string The underlying currency being traded.
  ›  block_trade_commission number Block Trade commission for instrument
  ›  contract_size integer Contract size for instrument
  ›  creation_timestamp integer The time when the instrument was first created (milliseconds)
  ›  expiration_timestamp integer The time when the instrument will expire (milliseconds)
  ›  instrument_name string Unique instrument identifier
  ›  is_active boolean Indicates if the instrument can currently be traded.
  ›  kind string Instrument kind, "future" or "option"
  ›  leverage integer Maximal leverage for instrument, for futures only
  ›  maker_commission number Maker commission for instrument
  ›  min_trade_amount number Minimum amount for trading. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  option_type string The option type (only for options)
  ›  quote_currency string The currency in which the instrument prices are quoted.
  ›  settlement_period string The settlement period.
  ›  strike number The strike value. (only for options)
  ›  taker_commission number Taker commission for instrument
  ›  tick_size number specifies minimal price change and, as follows, the number of decimal places for instrument prices

/public/get_last_settlements_by_currency

curl -X GET "https://test.deribit.com/api/v2/public/get_last_settlements_by_currency?count=2&currency=BTC&type=delivery" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 4497,
  "method" : "public/get_last_settlements_by_currency",
  "params" : {
    "currency" : "BTC",
    "type" : "delivery",
    "count" : 2
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 4497,
  "method" : "public/get_last_settlements_by_currency",
  "params" : {
    "currency" : "BTC",
    "type" : "delivery",
    "count" : 2
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 4497,
  "result": {
    "settlements": [
      {
        "type": "delivery",
        "timestamp": 1550242800013,
        "session_profit_loss": 4.703907906,
        "profit_loss": -0.427669766,
        "position": 64,
        "mark_price": 0.121679828,
        "instrument_name": "BTC-15FEB19-4000-P",
        "index_price": 3566.08
      },
      {
        "type": "delivery",
        "timestamp": 1550242800013,
        "session_profit_loss": 3.135938604,
        "profit_loss": -2.539278115,
        "position": 206,
        "mark_price": 0,
        "instrument_name": "BTC-15FEB19-4000-C",
        "index_price": 3566.08
      }
    ],
    "continuation": "29XjjMM7Zc6U4oytmV27f7a6YRb5aSdVijwfuYhHRTLphugjRf1edP8uGLo3w2mWKV23QgrxsmenRGqzucc7"
  }
}

Retrieves historical settlement, delivery and bankruptcy events coming from all instruments within given currency.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
type false string settlement
delivery
bankruptcy
Settlement type
count false integer Number of requested items, default - 20
continuation false string Continuation token for pagination
search_start_timestamp false integer The latest timestamp to return result for

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  continuation string Continuation token for pagination.
  ›  settlements array of object
  ›    ›  funded number funded amount (bankruptcy only)
  ›    ›  funding number funding (in base currency ; settlement for perpetual product only)
  ›    ›  index_price number underlying index price at time of event (in quote currency; settlement and delivery only)
  ›    ›  instrument_name string instrument name (settlement and delivery only)
  ›    ›  mark_price number mark price for at the settlement time (in quote currency; settlement and delivery only)
  ›    ›  position number position size (in quote currency; settlement and delivery only)
  ›    ›  profit_loss number profit and loss (in base currency; settlement and delivery only)
  ›    ›  session_bankrupcy number value of session bankrupcy (in base currency; bankruptcy only)
  ›    ›  session_profit_loss number total value of session profit and losses (in base currency)
  ›    ›  session_tax number total amount of paid taxes/fees (in base currency; bankruptcy only)
  ›    ›  session_tax_rate number rate of paid texes/fees (in base currency; bankruptcy only)
  ›    ›  socialized number the amount of the socialized losses (in base currency; bankruptcy only)
  ›    ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  type string The type of settlement. settlement, delivery or bankruptcy.

/public/get_last_settlements_by_instrument

curl -X GET "https://test.deribit.com/api/v2/public/get_last_settlements_by_instrument?count=1&instrument_name=BTC-22FEB19&type=settlement" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 5482,
  "method" : "public/get_last_settlements_by_instrument",
  "params" : {
    "instrument_name" : "BTC-22FEB19",
    "type" : "settlement",
    "count" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 5482,
  "method" : "public/get_last_settlements_by_instrument",
  "params" : {
    "instrument_name" : "BTC-22FEB19",
    "type" : "settlement",
    "count" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 5482,
  "result": {
    "settlements": [
      {
        "type": "settlement",
        "timestamp": 1550502000023,
        "session_profit_loss": 0.116509752,
        "profit_loss": -9.999999999886402e-10,
        "position": 240,
        "mark_price": 3578.16,
        "instrument_name": "BTC-22FEB19",
        "index_price": 3796.43
      }
    ],
    "continuation": "2Z7mdtavzYvfuyYcHkJXvPTr9ZSMsEzM3sLCH7AbYEDd1AzTXY2hnhegQDiaP1TtU4b5iSJZ4"
  }
}

Retrieves historical public settlement, delivery and bankruptcy events filtered by instrument name.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
type false string settlement
delivery
bankruptcy
Settlement type
count false integer Number of requested items, default - 20
continuation false string Continuation token for pagination
search_start_timestamp false integer The latest timestamp to return result for

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  continuation string Continuation token for pagination.
  ›  settlements array of object
  ›    ›  funded number funded amount (bankruptcy only)
  ›    ›  funding number funding (in base currency ; settlement for perpetual product only)
  ›    ›  index_price number underlying index price at time of event (in quote currency; settlement and delivery only)
  ›    ›  instrument_name string instrument name (settlement and delivery only)
  ›    ›  mark_price number mark price for at the settlement time (in quote currency; settlement and delivery only)
  ›    ›  position number position size (in quote currency; settlement and delivery only)
  ›    ›  profit_loss number profit and loss (in base currency; settlement and delivery only)
  ›    ›  session_bankrupcy number value of session bankrupcy (in base currency; bankruptcy only)
  ›    ›  session_profit_loss number total value of session profit and losses (in base currency)
  ›    ›  session_tax number total amount of paid taxes/fees (in base currency; bankruptcy only)
  ›    ›  session_tax_rate number rate of paid texes/fees (in base currency; bankruptcy only)
  ›    ›  socialized number the amount of the socialized losses (in base currency; bankruptcy only)
  ›    ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  type string The type of settlement. settlement, delivery or bankruptcy.

/public/get_last_trades_by_currency

curl -X GET "https://test.deribit.com/api/v2/public/get_last_trades_by_currency?count=1&currency=BTC" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9290,
  "method" : "public/get_last_trades_by_currency",
  "params" : {
    "currency" : "BTC",
    "count" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9290,
  "method" : "public/get_last_trades_by_currency",
  "params" : {
    "currency" : "BTC",
    "count" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 9290,
    "result": {
        "trades": [
            {
                "trade_seq": 36798,
                "trade_id": "277976",
                "timestamp": 1590476708320,
                "tick_direction": 2,
                "price": 8767.08,
                "mark_price": 8829.7,
                "instrument_name": "BTC-PERPETUAL",
                "index_price": 8878.53,
                "direction": "sell",
                "amount": 100
            }
        ],
        "has_more": true
    }
}

Retrieve the latest trades that have occurred for instruments in a specific currency symbol.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
kind false string future
option
Instrument kind, if not provided instruments of all kinds are considered
start_id false string The ID number of the first trade to be returned
end_id false string The ID number of the last trade to be returned
count false integer Number of requested items, default - 10
include_old false boolean Include trades older than a few recent days, default - false
sorting false string asc
desc
default
Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  has_more boolean
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  price number Price in base currency
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument

/public/get_last_trades_by_currency_and_time

curl -X GET "https://test.deribit.com/api/v2/public/get_last_trades_by_currency_and_time?count=1&currency=BTC&end_timestamp=1590480022768&start_timestamp=1590470022768" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 1469,
  "method" : "public/get_last_trades_by_currency_and_time",
  "params" : {
    "currency" : "BTC",
    "start_timestamp" : 1590470022768,
    "end_timestamp" : 1590480022768,
    "count" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 1469,
  "method" : "public/get_last_trades_by_currency_and_time",
  "params" : {
    "currency" : "BTC",
    "start_timestamp" : 1590470022768,
    "end_timestamp" : 1590480022768,
    "count" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 1469,
    "result": {
        "trades": [
            {
                "trade_seq": 3471,
                "trade_id": "48077291",
                "timestamp": 1590470616101,
                "tick_direction": 2,
                "price": 0.032,
                "mark_price": 0.04070324,
                "iv": 74.74,
                "instrument_name": "BTC-25SEP20-6000-P",
                "index_price": 8899.93,
                "direction": "sell",
                "amount": 0.5
            }
        ],
        "has_more": true
    }
}

Retrieve the latest trades that have occurred for instruments in a specific currency symbol and within given time range.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
kind false string future
option
Instrument kind, if not provided instruments of all kinds are considered
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for
count false integer Number of requested items, default - 10
include_old false boolean Include trades older than a few recent days, default - false
sorting false string asc
desc
default
Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  has_more boolean
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  price number Price in base currency
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument

/public/get_last_trades_by_instrument

curl -X GET "https://test.deribit.com/api/v2/public/get_last_trades_by_instrument?count=1&instrument_name=BTC-PERPETUAL" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9267,
  "method" : "public/get_last_trades_by_instrument",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "count" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9267,
  "method" : "public/get_last_trades_by_instrument",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "count" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 9267,
    "result": {
        "trades": [
            {
                "trade_seq": 36798,
                "trade_id": "277976",
                "timestamp": 1590476708320,
                "tick_direction": 2,
                "price": 8767.08,
                "mark_price": 8829.7,
                "instrument_name": "BTC-PERPETUAL",
                "index_price": 8878.53,
                "direction": "sell",
                "amount": 100
            }
        ],
        "has_more": true
    }
}

Retrieve the latest trades that have occurred for a specific instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
start_seq false integer The sequence number of the first trade to be returned
end_seq false integer The sequence number of the last trade to be returned
count false integer Number of requested items, default - 10
include_old false boolean Include trades older than a few recent days, default - false
sorting false string asc
desc
default
Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  has_more boolean
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  price number Price in base currency
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument

/public/get_last_trades_by_instrument_and_time

curl -X GET "https://test.deribit.com/api/v2/public/get_last_trades_by_instrument_and_time?count=1&end_timestamp=1590480022768&instrument_name=ETH-PERPETUAL" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3983,
  "method" : "public/get_last_trades_by_instrument_and_time",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "end_timestamp" : 1590480022768,
    "count" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3983,
  "method" : "public/get_last_trades_by_instrument_and_time",
  "params" : {
    "instrument_name" : "ETH-PERPETUAL",
    "end_timestamp" : 1590480022768,
    "count" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 3983,
    "result": {
        "trades": [
            {
                "trade_seq": 1966031,
                "trade_id": "ETH-2696055",
                "timestamp": 1590479408216,
                "tick_direction": 0,
                "price": 203.6,
                "mark_price": 203.41,
                "instrument_name": "ETH-PERPETUAL",
                "index_price": 203.45,
                "direction": "buy",
                "amount": 10
            }
        ],
        "has_more": true
    }
}

Retrieve the latest trades that have occurred for a specific instrument and within given time range.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for
count false integer Number of requested items, default - 10
include_old false boolean Include trades older than a few recent days, default - false
sorting false string asc
desc
default
Direction of results sorting (default value means no sorting, results will be returned in order in which they left the database)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  has_more boolean
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  price number Price in base currency
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument

/public/get_mark_price_history

curl -X GET "https://test.deribit.com/api/v2/public/get_mark_price_history?end_timestamp=1609376810000&instrument_name=BTC-25JUN21-50000-C&start_timestamp=1609376800000" \
-H "Content-Type: application/json"
var msg = 
{
  "id" : 1,
  "method" : "public/get_mark_price_history",
  "params" : {
    "instrument_name" : "BTC-25JUN21-50000-C",
    "start_timestamp" : 1609376800000,
    "end_timestamp" : 1609376810000
  },
  "jsonrpc" : "2.0"
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "id" : 1,
  "method" : "public/get_mark_price_history",
  "params" : {
    "instrument_name" : "BTC-25JUN21-50000-C",
    "start_timestamp" : 1609376800000,
    "end_timestamp" : 1609376810000
  },
  "jsonrpc" : "2.0"
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{"jsonrpc":"2.0",
  "id": 25,
  "result": [
    [1608142381229,0.5165791606037885],
    [1608142380231,0.5165737855432504],
    [1608142379227,0.5165768236356326]
  ]
}

Public request for 5min history of markprice values for the instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array Markprice history values as an array of arrays with 2 values each. The inner values correspond to the timestamp in ms and the markprice itself.

/public/get_order_book

curl -X GET "https://test.deribit.com/api/v2/public/get_order_book?depth=5&instrument_name=BTC-PERPETUAL" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8772,
  "method" : "public/get_order_book",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "depth" : 5
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8772,
  "method" : "public/get_order_book",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL",
    "depth" : 5
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc":"2.0",
    "id":8772,
    "result":{
        "timestamp":1550757626706,
        "stats":{
            "volume":93.35589552,
            "price_change": 0.6913,
            "low":3940.75,
            "high":3976.25
        },
        "state":"open",
        "settlement_price":3925.85,
        "open_interest":45.27600333464605,
        "min_price":3932.22,
        "max_price":3971.74,
        "mark_price":3931.97,
        "last_price":3955.75,
        "instrument_name":"BTC-PERPETUAL",
        "index_price":3910.46,
        "funding_8h":0.00455263,
        "current_funding":0.00500063,
        "change_id":474988,
        "bids":[
            [
                3955.75,
                30.0
            ],
            [
                3940.75,
                102020.0
            ],
            [
                3423.0,
                42840.0
            ]
        ],
        "best_bid_price":3955.75,
        "best_bid_amount":30.0,
        "best_ask_price":0.0,
        "best_ask_amount":0.0,
        "asks":[

        ]
    }
}

Retrieves the order book, along with other market values for a given instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string The instrument name for which to retrieve the order book, see getinstruments to obtain instrument names.
depth false number The number of entries to return for bids and asks.

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  ask_iv number (Only for option) implied volatility for best ask
  ›  asks array of [price, amount] List of asks
  ›  best_ask_amount number It represents the requested order size of all best asks
  ›  best_ask_price number The current best ask price, null if there aren't any asks
  ›  best_bid_amount number It represents the requested order size of all best bids
  ›  best_bid_price number The current best bid price, null if there aren't any bids
  ›  bid_iv number (Only for option) implied volatility for best bid
  ›  bids array of [price, amount] List of bids
  ›  current_funding number Current funding (perpetual only)
  ›  delivery_price number The settlement price for the instrument. Only when state = closed
  ›  funding_8h number Funding 8h (perpetual only)
  ›  greeks object Only for options
  ›    ›  delta number (Only for option) The delta value for the option
  ›    ›  gamma number (Only for option) The gamma value for the option
  ›    ›  rho number (Only for option) The rho value for the option
  ›    ›  theta number (Only for option) The theta value for the option
  ›    ›  vega number (Only for option) The vega value for the option
  ›  index_price number Current index price
  ›  instrument_name string Unique instrument identifier
  ›  interest_rate number Interest rate used in implied volatility calculations (options only)
  ›  last_price number The price for the last trade
  ›  mark_iv number (Only for option) implied volatility for mark price
  ›  mark_price number The mark price for the instrument
  ›  max_price number The maximum price for the future. Any buy orders you submit higher than this price, will be clamped to this maximum.
  ›  min_price number The minimum price for the future. Any sell orders you submit lower than this price will be clamped to this minimum.
  ›  open_interest number The total amount of outstanding contracts in the corresponding amount units. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  settlement_price number The settlement price for the instrument. Only when state = open
  ›  state string The state of the order book. Possible values are open and closed.
  ›  stats object
  ›    ›  high number Highest price during 24h
  ›    ›  low number Lowest price during 24h
  ›    ›  price_change number 24-hour price change expressed as a percentage, null if there weren't any trades
  ›    ›  volume number Volume during last 24h in base currency
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  underlying_index number Name of the underlying future, or index_price (options only)
  ›  underlying_price number Underlying price for implied volatility calculations (options only)

/public/get_trade_volumes

curl -X GET "https://test.deribit.com/api/v2/public/get_trade_volumes?" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 6387,
  "method" : "public/get_trade_volumes"
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 6387,
  "method" : "public/get_trade_volumes"
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 6387,
  "result": [
    {
      "puts_volume": 48,
      "futures_volume": 6.2557,
      "currency_pair": "btc_usd",
      "calls_volume": 145
    },
    {
      "puts_volume": 122.65,
      "futures_volume": 374.3921,
      "currency_pair": "eth_usd",
      "calls_volume": 37.4
    }
  ]
}

Retrieves aggregated 24h trade volumes for different instrument types and currencies.

Try in API console

Parameters

Parameter Required Type Enum Description
extended false boolean Request for extended statistics. Including also 7 and 30 days volumes (default false)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result array of object
  ›  calls_volume number Total 24h trade volume for call options. This is expressed in the base currency, e.g. BTC for btc_usd
  ›  calls_volume_30d number Total 30d trade volume for call options. This is expressed in the base currency, e.g. BTC for btc_usd
  ›  calls_volume_7d number Total 7d trade volume for call options. This is expressed in the base currency, e.g. BTC for btc_usd
  ›  currency_pair string Currency pair: "btc_usd" or "eth_usd"
  ›  futures_volume number Total 24h trade volume for futures. This is expressed in the base currency, e.g. BTC for btc_usd
  ›  futures_volume_30d number Total 30d trade volume for futures. This is expressed in the base currency, e.g. BTC for btc_usd
  ›  futures_volume_7d number Total 7d trade volume for futures. This is expressed in the base currency, e.g. BTC for btc_usd
  ›  puts_volume number Total 24h trade volume for put options. This is expressed in the base currency, e.g. BTC for btc_usd
  ›  puts_volume_30d number Total 30d trade volume for put options. This is expressed in the base currency, e.g. BTC for btc_usd
  ›  puts_volume_7d number Total 7d trade volume for put options. This is expressed in the base currency, e.g. BTC for btc_usd

/public/get_tradingview_chart_data

curl -X GET "https://test.deribit.com/api/v2/public/get_tradingview_chart_data?end_timestamp=1554376800000&instrument_name=BTC-5APR19&resolution=30&start_timestamp=1554373800000" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 833,
  "method" : "public/get_tradingview_chart_data",
  "params" : {
    "instrument_name" : "BTC-5APR19",
    "start_timestamp" : 1554373800000,
    "end_timestamp" : 1554376800000,
    "resolution" : "30"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 833,
  "method" : "public/get_tradingview_chart_data",
  "params" : {
    "instrument_name" : "BTC-5APR19",
    "start_timestamp" : 1554373800000,
    "end_timestamp" : 1554376800000,
    "resolution" : "30"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 833,
  "result": {
    "volume": [
      19.007942601,
      20.095877981
    ],
    "cost": [
      19000.0,
      23400.0
    ],
    "ticks": [
      1554373800000,
      1554375600000
    ],
    "status": "ok",
    "open": [
      4963.42,
      4986.29
    ],
    "low": [
      4728.94,
      4726.6
    ],
    "high": [
      5185.45,
      5250.87
    ],
    "close": [
      5052.95,
      5013.59
    ]
  },
  "usIn": 1554381680742493,
  "usOut": 1554381680742698,
  "usDiff": 205,
  "testnet": false
}

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

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for
resolution true string 1
3
5
10
15
30
60
120
180
360
720
1D
Chart bars resolution given in full minutes or keyword 1D (only some specific resolutions are supported)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  close array of number List of prices at close (one per candle)
  ›  cost array of number List of cost bars (volume in quote currency, one per candle)
  ›  high array of number List of highest price levels (one per candle)
  ›  low array of number List of lowest price levels (one per candle)
  ›  open array of number List of prices at open (one per candle)
  ›  status string Status of the query: ok or no_data
  ›  ticks array of integer Values of the time axis given in milliseconds since UNIX epoch
  ›  volume array of number List of volume bars (in base currency, one per candle)

/public/get_volatility_index_data

curl -X GET "https://test.deribit.com/api/v2/public/get_volatility_index_data?currency=BTC&end_timestamp=1599376800000&resolution=60&start_timestamp=1599373800000" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 833,
  "method" : "public/get_volatility_index_data",
  "params" : {
    "currency" : "BTC",
    "start_timestamp" : 1599373800000,
    "end_timestamp" : 1599376800000,
    "resolution" : "60"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 833,
  "method" : "public/get_volatility_index_data",
  "params" : {
    "currency" : "BTC",
    "start_timestamp" : 1599373800000,
    "end_timestamp" : 1599376800000,
    "resolution" : "60"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc":"2.0",
  "id":5,
  "result":
  {
    "data": [[1598019300000,0.210084879,0.212860821,0.210084879,0.212860821],
      [1598019360000,0.212869011,0.212987527,0.212869011,0.212987527],
      [1598019420000,0.212987723,0.212992597,0.212987723,0.212992597]]}
}

Public market data request for volatility index candles. Supported resolutions 1

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
start_timestamp true integer The earliest timestamp to return result for
end_timestamp true integer The most recent timestamp to return result for
resolution true string 1
60
3600
43200
1D
Time resolution given in full seconds or keyword 1D (only some specific resolutions are supported)

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object Volatility index candles.
  ›  data array Candles as an array of arrays with 5 values each. The inner values correspond to the timestamp in ms, open, high, low, and close values of the volatility index correspondingly.

/public/ticker

curl -X GET "https://test.deribit.com/api/v2/public/ticker?instrument_name=BTC-PERPETUAL" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 8106,
  "method" : "public/ticker",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 8106,
  "method" : "public/ticker",
  "params" : {
    "instrument_name" : "BTC-PERPETUAL"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 8106,
  "result": {
    "best_ask_amount": 3010
    "best_ask_price": 3562.75,
    "best_bid_amount": 135710,
    "best_bid_price": 3562.5,
    "current_funding": 0,
    "funding_8h": 0.00018344,
    "index_price": 3563.53,
    "instrument_name": "BTC-PERPETUAL",
    "last_price": 3562.25,
    "mark_price": 3562.62,
    "max_price": 3598.21,
    "min_price": 3526.96,
    "open_interest": 23126.924145440054,
    "settlement_price": 3573.77,
    "state": "open",
    "stats": {
      "volume": 85934.31950267,
      "price_change": 0.6913,
      "low": 3492,
      "high": 3660.25
    },
    "timestamp": 1550153198202
  }
}

Get ticker for an instrument.

Try in API console

Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  ask_iv number (Only for option) implied volatility for best ask
  ›  best_ask_amount number It represents the requested order size of all best asks
  ›  best_ask_price number The current best ask price, null if there aren't any asks
  ›  best_bid_amount number It represents the requested order size of all best bids
  ›  best_bid_price number The current best bid price, null if there aren't any bids
  ›  bid_iv number (Only for option) implied volatility for best bid
  ›  current_funding number Current funding (perpetual only)
  ›  delivery_price number The settlement price for the instrument. Only when state = closed
  ›  funding_8h number Funding 8h (perpetual only)
  ›  greeks object Only for options
  ›    ›  delta number (Only for option) The delta value for the option
  ›    ›  gamma number (Only for option) The gamma value for the option
  ›    ›  rho number (Only for option) The rho value for the option
  ›    ›  theta number (Only for option) The theta value for the option
  ›    ›  vega number (Only for option) The vega value for the option
  ›  index_price number Current index price
  ›  instrument_name string Unique instrument identifier
  ›  interest_rate number Interest rate used in implied volatility calculations (options only)
  ›  last_price number The price for the last trade
  ›  mark_iv number (Only for option) implied volatility for mark price
  ›  mark_price number The mark price for the instrument
  ›  max_price number The maximum price for the future. Any buy orders you submit higher than this price, will be clamped to this maximum.
  ›  min_price number The minimum price for the future. Any sell orders you submit lower than this price will be clamped to this minimum.
  ›  open_interest number The total amount of outstanding contracts in the corresponding amount units. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  settlement_price number The settlement price for the instrument. Only when state = open
  ›  state string The state of the order book. Possible values are open and closed.
  ›  stats object
  ›    ›  high number Highest price during 24h
  ›    ›  low number Lowest price during 24h
  ›    ›  price_change number 24-hour price change expressed as a percentage, null if there weren't any trades
  ›    ›  volume number Volume during last 24h in base currency
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  underlying_index number Name of the underlying future, or index_price (options only)
  ›  underlying_price number Underlying price for implied volatility calculations (options only)

Wallet

/private/cancel_transfer_by_id

curl -X GET "https://test.deribit.com/api/v2/private/cancel_transfer_by_id?currency=BTC&id=2" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9187,
  "method" : "private/cancel_transfer_by_id",
  "params" : {
    "currency" : "BTC",
    "id" : 2
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9187,
  "method" : "private/cancel_transfer_by_id",
  "params" : {
    "currency" : "BTC",
    "id" : 2
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 9187,
    "result": {
        "amount": 0.2,
        "created_timestamp": 1550579457727,
        "currency": "BTC",
        "direction": "payment",
        "id": 2,
        "other_side": "2MzyQc5Tkik61kJbEpJV5D5H9VfWHZK9Sgy",
        "state": "cancelled",
        "type": "user",
        "updated_timestamp": 1550579457727
    }
}

Cancel transfer

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
id true integer Id of transfer
tfa false string TFA code, required when TFA is enabled for current account

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  amount number Amount of funds in given currency
  ›  created_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  direction string Transfer direction
  ›  id integer Id of transfer
  ›  other_side string For transfer from/to subaccount returns this subaccount name, for transfer to other account returns address, for transfer from other account returns that accounts username.
  ›  state string Transfer state, allowed values : prepared, confirmed, cancelled, waiting_for_admin, rejection_reason
  ›  type string Type of transfer: user - sent to user, subaccount - sent to subaccount
  ›  updated_timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/cancel_withdrawal

curl -X GET "https://test.deribit.com/api/v2/private/cancel_withdrawal?currency=BTC&id=1" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7420,
  "method" : "private/cancel_withdrawal",
  "params" : {
    "currency" : "BTC",
    "id" : 1
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7420,
  "method" : "private/cancel_withdrawal",
  "params" : {
    "currency" : "BTC",
    "id" : 1
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 7420,
    "result": {
        "address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz",
        "amount": 0.5,
        "confirmed_timestamp": null,
        "created_timestamp": 1550571443070,
        "currency": "BTC",
        "fee": 0.0001,
        "id": 1,
        "priority": 0.15,
        "state": "cancelled",
        "transaction_id": null,
        "updated_timestamp": 1550571443070
    }
}

Cancels withdrawal request

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
id true number The withdrawal id

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  address string Address in proper format for currency
  ›  amount number Amount of funds in given currency
  ›  confirmed_timestamp integer The timestamp (milliseconds since the Unix epoch) of withdrawal confirmation, null when not confirmed
  ›  created_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  fee number Fee in currency
  ›  id integer Withdrawal id in Deribit system
  ›  priority number Id of priority level
  ›  state string Withdrawal state, allowed values : unconfirmed, confirmed, cancelled, completed, interrupted, rejected
  ›  transaction_id string Transaction id in proper format for currency, null if id is not available
  ›  updated_timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/create_deposit_address

curl -X GET "https://test.deribit.com/api/v2/private/create_deposit_address?currency=BTC" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7538,
  "method" : "private/create_deposit_address",
  "params" : {
    "currency" : "BTC"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7538,
  "method" : "private/create_deposit_address",
  "params" : {
    "currency" : "BTC"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 7538,
    "result": {
        "address": "2N8udZGBc1hLRCFsU9kGwMPpmYUwMFTuCwB",
        "creation_timestamp": 1550575165170,
        "currency": "BTC",
        "type": "deposit"
    }
}

Creates deposit address in currency

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object Object if address is created, null otherwise
  ›  address string Address in proper format for currency
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  type string Address type/purpose, allowed values : deposit, withdrawal, transfer

/private/get_current_deposit_address

curl -X GET "https://test.deribit.com/api/v2/private/get_current_deposit_address?currency=BTC" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 3461,
  "method" : "private/get_current_deposit_address",
  "params" : {
    "currency" : "BTC"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 3461,
  "method" : "private/get_current_deposit_address",
  "params" : {
    "currency" : "BTC"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 3461,
    "result": {
        "address": "2N8udZGBc1hLRCFsU9kGwMPpmYUwMFTuCwB",
        "creation_timestamp": 1550575165170,
        "currency": "BTC",
        "type": "deposit"
    }
}


Retrieve deposit address for currency

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object Object if address is created, null otherwise
  ›  address string Address in proper format for currency
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  type string Address type/purpose, allowed values : deposit, withdrawal, transfer

/private/get_deposits

curl -X GET "https://test.deribit.com/api/v2/private/get_deposits?count=10&currency=BTC&offset=0" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 5611,
  "method" : "private/get_deposits",
  "params" : {
    "currency" : "BTC",
    "count" : 10,
    "offset" : 0
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 5611,
  "method" : "private/get_deposits",
  "params" : {
    "currency" : "BTC",
    "count" : 10,
    "offset" : 0
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 5611,
  "result": {
        "count": 1,
        "data": [
          {
              "address": "2N35qDKDY22zmJq9eSyiAerMD4enJ1xx6ax",
              "amount": 5,
              "currency": "BTC",
              "received_timestamp": 1549295017670,
              "state": "completed",
              "transaction_id": "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda",
              "updated_timestamp": 1549295130159
          }
      ]
  }
}

Retrieve the latest users deposits

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
count false integer Number of requested items, default - 10
offset false integer The offset for pagination, default - 0

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  count integer Total number of results available
  ›  data array of object
  ›    ›  address string Address in proper format for currency
  ›    ›  amount number Amount of funds in given currency
  ›    ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  received_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  state string Deposit state, allowed values : pending, completed, rejected, replaced
  ›    ›  transaction_id string Transaction id in proper format for currency, null if id is not available
  ›    ›  updated_timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/get_transfers

curl -X GET "https://test.deribit.com/api/v2/private/get_transfers?count=10&currency=BTC" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 7606,
  "method" : "private/get_transfers",
  "params" : {
    "currency" : "BTC",
    "count" : 10
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 7606,
  "method" : "private/get_transfers",
  "params" : {
    "currency" : "BTC",
    "count" : 10
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 7606,
    "result": {
        "count": 2,
        "data": [
            {
                "amount": 0.2,
                "created_timestamp": 1550579457727,
                "currency": "BTC",
                "direction": "payment",
                "id": 2,
                "other_side": "2MzyQc5Tkik61kJbEpJV5D5H9VfWHZK9Sgy",
                "state": "prepared",
                "type": "user",
                "updated_timestamp": 1550579457727
            },
            {
                "amount": 0.3,
                "created_timestamp": 1550579255800,
                "currency": "BTC",
                "direction": "payment",
                "id": 1,
                "other_side": "new_user_1_1",
                "state": "confirmed",
                "type": "subaccount",
                "updated_timestamp": 1550579255800
            }
        ]
    }
}

Adds new entry to address book of given type

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
count false integer Number of requested items, default - 10
offset false integer The offset for pagination, default - 0

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  count integer Total number of results available
  ›  data array of object
  ›    ›  amount number Amount of funds in given currency
  ›    ›  created_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  direction string Transfer direction
  ›    ›  id integer Id of transfer
  ›    ›  other_side string For transfer from/to subaccount returns this subaccount name, for transfer to other account returns address, for transfer from other account returns that accounts username.
  ›    ›  state string Transfer state, allowed values : prepared, confirmed, cancelled, waiting_for_admin, rejection_reason
  ›    ›  type string Type of transfer: user - sent to user, subaccount - sent to subaccount
  ›    ›  updated_timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/get_withdrawals

curl -X GET "https://test.deribit.com/api/v2/private/get_withdrawals?count=10&currency=BTC&offset=0" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 2745,
  "method" : "private/get_withdrawals",
  "params" : {
    "currency" : "BTC",
    "count" : 10,
    "offset" : 0
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 2745,
  "method" : "private/get_withdrawals",
  "params" : {
    "currency" : "BTC",
    "count" : 10,
    "offset" : 0
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 2745,
  "result": {
      "count": 1,
      "data": [
          {
              "address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz",
              "amount": 0.5,
              "confirmed_timestamp": null,
              "created_timestamp": 1550571443070,
              "currency": "BTC",
              "fee": 0.0001,
              "id": 1,
              "priority": 0.15,
              "state": "unconfirmed",
              "transaction_id": null,
              "updated_timestamp": 1550571443070
          }
      ]
  }
}

Retrieve the latest users withdrawals

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
count false integer Number of requested items, default - 10
offset false integer The offset for pagination, default - 0

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  count integer Total number of results available
  ›  data array of object
  ›    ›  address string Address in proper format for currency
  ›    ›  amount number Amount of funds in given currency
  ›    ›  confirmed_timestamp integer The timestamp (milliseconds since the Unix epoch) of withdrawal confirmation, null when not confirmed
  ›    ›  created_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  fee number Fee in currency
  ›    ›  id integer Withdrawal id in Deribit system
  ›    ›  priority number Id of priority level
  ›    ›  state string Withdrawal state, allowed values : unconfirmed, confirmed, cancelled, completed, interrupted, rejected
  ›    ›  transaction_id string Transaction id in proper format for currency, null if id is not available
  ›    ›  updated_timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/submit_transfer_to_subaccount

curl -X GET "https://test.deribit.com/api/v2/private/submit_transfer_to_subaccount?amount=1.21234000000000001762e%2B01&currency=ETH&destination=20" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 210,
  "method" : "private/submit_transfer_to_subaccount",
  "params" : {
    "currency" : "ETH",
    "amount" : 12.1234,
    "destination" : 20
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 210,
  "method" : "private/submit_transfer_to_subaccount",
  "params" : {
    "currency" : "ETH",
    "amount" : 12.1234,
    "destination" : 20
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 210,
  "result": {
    "updated_timestamp": 1550226218504,
    "type": "subaccount",
    "state": "confirmed",
    "other_side": "MySubAccount",
    "id": 1,
    "direction": "payment",
    "currency": "ETH",
    "created_timestamp": 1550226218504,
    "amount": 12.1234
  }
}

Transfer funds to subaccount.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
amount true number Amount of funds to be transferred
destination true integer Id of destination subaccount. Can be found in My Account >> Subaccounts tab

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  amount number Amount of funds in given currency
  ›  created_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  direction string Transfer direction
  ›  id integer Id of transfer
  ›  other_side string For transfer from/to subaccount returns this subaccount name, for transfer to other account returns address, for transfer from other account returns that accounts username.
  ›  state string Transfer state, allowed values : prepared, confirmed, cancelled, waiting_for_admin, rejection_reason
  ›  type string Type of transfer: user - sent to user, subaccount - sent to subaccount
  ›  updated_timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/submit_transfer_to_user

curl -X GET "https://test.deribit.com/api/v2/private/submit_transfer_to_user?amount=1.34559999999999995168e%2B01&currency=ETH&destination=0x4aa0753d798d668056920094d65321a8e8913e26" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 9421,
  "method" : "private/submit_transfer_to_user",
  "params" : {
    "currency" : "ETH",
    "amount" : 13.456,
    "destination" : "0x4aa0753d798d668056920094d65321a8e8913e26"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 9421,
  "method" : "private/submit_transfer_to_user",
  "params" : {
    "currency" : "ETH",
    "amount" : 13.456,
    "destination" : "0x4aa0753d798d668056920094d65321a8e8913e26"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
  "jsonrpc": "2.0",
  "id": 9421,
  "result": {
    "updated_timestamp": 1550232862350,
    "type": "user",
    "state": "prepared",
    "other_side": "0x4aa0753d798d668056920094d65321a8e8913e26",
    "id": 3,
    "direction": "payment",
    "currency": "ETH",
    "created_timestamp": 1550232862350,
    "amount": 13.456
  }
}

Transfer funds to another user.

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
amount true number Amount of funds to be transferred
destination true string Destination wallet's address taken from address book
tfa false string TFA code, required when TFA is enabled for current account

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  amount number Amount of funds in given currency
  ›  created_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  direction string Transfer direction
  ›  id integer Id of transfer
  ›  other_side string For transfer from/to subaccount returns this subaccount name, for transfer to other account returns address, for transfer from other account returns that accounts username.
  ›  state string Transfer state, allowed values : prepared, confirmed, cancelled, waiting_for_admin, rejection_reason
  ›  type string Type of transfer: user - sent to user, subaccount - sent to subaccount
  ›  updated_timestamp integer The timestamp (milliseconds since the Unix epoch)

/private/withdraw

curl -X GET "https://test.deribit.com/api/v2/private/withdraw?address=2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz&amount=4.00000000000000022204e-01&currency=BTC&priority=mid" \
-H "Authorization: Bearer 1529453804065.h2QrBgvn.oS36pCOmuK9EX7954lzCSkUioEtTMg7F5ShToM0ZfYlqU05OquXkQIe2_DDEkPhzmoPp1fBp0ycXShR_0jf-SMSXEdVqxLRWuOw-_StG5BMjToiAl27CbHY4P92MPhlMblTOtTImE81-5dFdyDVydpBwmlfKM3OSQ39kulP9bbfw-2jhyegOL0AgqJTY_tj554oHCQFTbq0A0ZWukukmxL2yu6iy34XdzaJB26Igy-3UxGBMwFu53EhjKBweh7xyP2nDm57-wybndJMtSyTGDXH3vjBVclo1iup5yRP" \
-H "Content-Type: application/json"
var msg = 
{
  "jsonrpc" : "2.0",
  "id" : 6931,
  "method" : "private/withdraw",
  "params" : {
    "currency" : "BTC",
    "address" : "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz",
    "amount" : 0.4,
    "priority" : "mid"
  }
};
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the response...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    // ------------------- 
    // Before sending message, make sure that your connection
    // is authenticated (use public/auth call before) 
    // ------------------- 
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

msg = \
{
  "jsonrpc" : "2.0",
  "id" : 6931,
  "method" : "private/withdraw",
  "params" : {
    "currency" : "BTC",
    "address" : "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz",
    "amount" : 0.4,
    "priority" : "mid"
  }
}

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       ###############
       # Before sending message, make sure that your connection
       # is authenticated (use public/auth call before) 
       ###############
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the response...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

The above command returns JSON structured like this (real example):

{
    "jsonrpc": "2.0",
    "id": 6931,
    "result": {
        "address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz",
        "amount": 0.4,
        "confirmed_timestamp": null,
        "created_timestamp": 1550574558607,
        "currency": "BTC",
        "fee": 0.0001,
        "id": 4,
        "priority": 1,
        "state": "unconfirmed",
        "transaction_id": null,
        "updated_timestamp": 1550574558607
    }
}

Creates a new withdrawal request

Try in API console

Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol
address true string Address in currency format, it must be in address book
amount true number Amount of funds to be withdrawn
priority false string insane
extreme_high
very_high
high
mid
low
very_low
Withdrawal priority, optional for BTC, default: high
tfa false string TFA code, required when TFA is enabled for current account

Response

Name Type Description
id integer The id that was sent in the request
jsonrpc string The JSON-RPC version (2.0)
result object
  ›  address string Address in proper format for currency
  ›  amount number Amount of funds in given currency
  ›  confirmed_timestamp integer The timestamp (milliseconds since the Unix epoch) of withdrawal confirmation, null when not confirmed
  ›  created_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  fee number Fee in currency
  ›  id integer Withdrawal id in Deribit system
  ›  priority number Id of priority level
  ›  state string Withdrawal state, allowed values : unconfirmed, confirmed, cancelled, completed, interrupted, rejected
  ›  transaction_id string Transaction id in proper format for currency, null if id is not available
  ›  updated_timestamp integer The timestamp (milliseconds since the Unix epoch)

Subscriptions

The subscribe method can be used to subscribe to one or more channels. This section provides an overview of the channels and the notifications that the subscriber will receive for each of those channels.

In most cases the channel name is constructed from a couple of elements. This makes it possible to specify exactly which information is required, and/or the frequency or aggregation level. These elements are considered parameters for the subscription.

For example, when subscribing to the channel book.BTC-27JUL18.10.20.100ms, the element BTC-27JUL18 specifies that the name of the instrument (see naming), 10 means that the results should be grouped to that precision, etc.

As described in notifications, response data includes fields required by JSON-RPC and part dedicated for subscription data.

Name Type Description
jsonrpc string The JSON-RPC version (2.0)
method string Here it's always subscription
params object
  ›  channel string The same channel as given when subscribing to notifications
  ›  data object Data specific for the channel

For all the following channel types only specific data part will be described.

announcements

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["announcements"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["announcements"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
         "channel": "announcements",
         "data": {
            "action": "new",
            "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
            "id": 1532593832021,
            "important": true,
            "publication_timestamp": 1532593832021,
            "title": "Example announcement"
        }
    }
}

General announcements concerning the Deribit platform.

Try in API console

Channel Parameters

This channel takes no parameters

Response

Name Type Description
data object
  ›  action string Action taken by the platform administrators. Published a new announcement, or deleted the old one
  ›  body string HTML-formatted announcement body
  ›  confirmation boolean Whether the user confirmation is required for this announcement
  ›  id integer Announcement's identifier
  ›  important boolean Whether the announcement is marked as important
  ›  publication_timestamp integer The timestamp (milliseconds since the Unix epoch) of announcement publication
  ›  title string Announcement's title
  ›  unread integer The number of previous unread announcements (optional, only for authorized users).

book.{instrument_name}.{group}.{depth}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["book.ETH-PERPETUAL.100.1.100ms"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["book.ETH-PERPETUAL.100.1.100ms"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "timestamp" : 1554375447971,
      "instrument_name" : "ETH-PERPETUAL",
      "change_id" : 109615,
      "bids" : [
        [
          160,
          40
        ]
      ],
      "asks" : [
        [
          161,
          20
        ]
      ]
    },
    "channel" : "book.ETH-PERPETUAL.100.1.100ms"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Notifies about changes to the order book for a certain instrument.

Notifications are sent once per specified interval, with prices grouped by (rounded to) the specified group, showing the complete order book to the specified depth (number of price levels).

The 'asks' and the 'bids' elements in the response are both a 'list of lists'. Each element in the outer list is a list of exactly two elements: price and amount.

price is a price level (USD per BTC, rounded as specified by the 'group' parameter for the susbcription).

amount indicates the amount of all orders at price level. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
group true string none
1
2
5
10
25
100
250
Group prices (by rounding). Use none for no grouping.
For ETH cryptocurrency, real group is divided by 100.0, e.g. given value 5 means using 0.05

Allowed values for BTC - none, 1, 2, 5, 10
Allowed values for ETH - none, 5, 10, 25, 100, 250
depth true integer 1
10
20
Number of price levels to be included.
interval true string 100ms Frequency of notifications. Events will be aggregated over this interval.

Response

Name Type Description
data object
  ›  asks array of [price, amount] List of asks
  ›  bids array of [price, amount] List of bids
  ›  change_id integer id of the notification
  ›  instrument_name string Unique instrument identifier
  ›  timestamp integer The timestamp of last change (milliseconds since the Unix epoch)

book.{instrument_name}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["book.BTC-PERPETUAL.100ms"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["book.BTC-PERPETUAL.100ms"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send first notification like this:

{
  "params" : {
    "data" : {
      "type" : "snapshot",
      "timestamp" : 1554373962454,
      "instrument_name" : "BTC-PERPETUAL",
      "change_id" : 297217,
      "bids" : [
        [
          "new",
          5042.34,
          30
        ],
        [
          "new",
          5041.94,
          20
        ]
      ],
      "asks" : [
        [
          "new",
          5042.64,
          40
        ],
        [
          "new",
          5043.3,
          40
        ]
      ]
    },
    "channel" : "book.BTC-PERPETUAL.100ms"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "type" : "change",
      "timestamp" : 1554373911330,
      "prev_change_id" : 297217,
      "instrument_name" : "BTC-PERPETUAL",
      "change_id" : 297218,
      "bids" : [
        [
          "delete",
          5041.94,
          0
        ],
        [
          "delete",
          5042.34,
          0
        ]
      ],
      "asks" : [

      ]
    },
    "channel" : "book.BTC-PERPETUAL.100ms"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Notifies about changes to the order book for a certain instrument.

The first notification will contain the whole book (bid and ask amounts for all prices). After that there will only be information about changes to individual price levels.

The first notification will contain the amounts for all price levels (list of ['new', price, amount] tuples). All following notifications will contain a list of tuples with action, price level and new amount ([action, price, amount]). Action can be either new, change or delete.

Each notification will contain a change_id field, and each message except for the first one will contain a field prev_change_id. If prev_change_id is equal to the change_id of the previous message, this means that no messages have been missed.

The amount for perpetual and futures is in USD units, for options it is in corresponding cryptocurrency contracts, e.g., BTC or ETH.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
interval true string raw
100ms
Frequency of notifications. Events will be aggregated over this interval.

Response

Name Type Description
data object
  ›  asks array of [action, price, amount] The first notification will contain the amounts for all price levels (a list of ["new", price, amount] tuples). All following notifications will contain a list of tuples with action, price level and new amount ([action, price, amount]). Action can be new, change or delete.
  ›  bids array of [action, price, amount] (See 'asks' above.)
  ›  change_id integer Identifier of the notification
  ›  instrument_name string Unique instrument identifier
  ›  prev_change_id integer Identifier of the previous notification (it's not included for the first notification)
  ›  timestamp integer The timestamp of last change (milliseconds since the Unix epoch)
  ›  type string Type of notification: snapshot for initial, change for others. The field is only included in aggregated response (when input parameter interval != raw)

chart.trades.{instrument_name}.{resolution}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["chart.trades.BTC-PERPETUAL.1"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["chart.trades.BTC-PERPETUAL.1"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "volume" : 0.05219351,
      "tick" : 1573645080000,
      "open" : 8869.79,
      "low" : 8788.25,
      "high" : 8870.31,
      "cost" : 460,
      "close" : 8791.25
    },
    "channel" : "chart.trades.BTC-PERPETUAL.1"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Publicly available market data used to generate a TradingView candle chart. During single resolution period, many events can be sent, each with updated values for the recent period.

NOTICE When there is no trade during the requested resolution period (e.g. 1 minute), then filling sample is generated which uses data from the last available trade candle (open and close values).

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
resolution true string 1
3
5
10
15
30
60
120
180
360
720
1D
Chart bars resolution given in full minutes or keyword 1D (only some specific resolutions are supported)

Response

Name Type Description
data object
  ›  close number The close price for the candle
  ›  cost number Cost data for the candle
  ›  high number The highest price level for the candle
  ›  low number The lowest price level for the candle
  ›  open number The open price for the candle'
  ›  tick integer The timestamp (milliseconds since the Unix epoch)
  ›  volume number Volume data for the candle

deribit_price_index.{index_name}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["deribit_price_index.btc_usd"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["deribit_price_index.btc_usd"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "timestamp" : 1550588002899,
      "price" : 3937.89,
      "index_name" : "btc_usd"
    },
    "channel" : "deribit_price_index.btc_usd"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Provides information about current value (price) for Deribit Index

Try in API console

Channel Parameters

Parameter Required Type Enum Description
index_name true string btc_usd
eth_usd
btc_usdt
eth_usdt
Index identifier, matches (base) cryptocurrency with quote currency

Response

Name Type Description
data object
  ›  index_name string Index identifier, matches (base) cryptocurrency with quote currency
  ›  price number Current index price
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

deribit_price_ranking.{index_name}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["deribit_price_ranking.btc_usd"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["deribit_price_ranking.btc_usd"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : [
      {
        "weight" : 14.29,
        "timestamp" : 1573202284040,
        "price" : 9109.35,
        "original_price" : 9109.35,
        "identifier" : "bitfinex",
        "enabled" : true
      },
      {
        "weight" : 14.29,
        "timestamp" : 1573202284055,
        "price" : 9084.83,
        "original_price" : 9084.83,
        "identifier" : "bitstamp",
        "enabled" : true
      },
      {
        "weight" : 14.29,
        "timestamp" : 1573202283191,
        "price" : 9079.91,
        "original_price" : 9079.91,
        "identifier" : "bittrex",
        "enabled" : true
      },
      {
        "weight" : 14.29,
        "timestamp" : 1573202284094,
        "price" : 9085.81,
        "original_price" : 9085.81,
        "identifier" : "coinbase",
        "enabled" : true
      },
      {
        "weight" : 14.29,
        "timestamp" : 1573202283881,
        "price" : 9086.27,
        "original_price" : 9086.27,
        "identifier" : "gemini",
        "enabled" : true
      },
      {
        "weight" : 14.29,
        "timestamp" : 1573202283420,
        "price" : 9088.38,
        "original_price" : 9088.38,
        "identifier" : "itbit",
        "enabled" : true
      },
      {
        "weight" : 14.29,
        "timestamp" : 1573202283459,
        "price" : 9083.6,
        "original_price" : 9083.6,
        "identifier" : "kraken",
        "enabled" : true
      },
      {
        "weight" : 0,
        "timestamp" : 0,
        "price" : null,
        "original_price" : null,
        "identifier" : "lmax",
        "enabled" : false
      }
    ],
    "channel" : "deribit_price_ranking.btc_usd"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Provides information about current value (price) for stock exchanges used to calculate Deribit Index

Try in API console

Channel Parameters

Parameter Required Type Enum Description
index_name true string btc_usd
eth_usd
btc_usdt
eth_usdt
Index identifier, matches (base) cryptocurrency with quote currency

Response

Name Type Description
data array of object
  ›  enabled boolean Stock exchange status
  ›  identifier string Stock exchange identifier
  ›  original_price number Index price retrieved from stock's data
  ›  price number Adjusted stock exchange index price, used for Deribit price index calculations
  ›  timestamp integer The timestamp of the last update from stock exchange
  ›  weight number The weight of the ranking given in percent

deribit_volatility_index.{index_name}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["deribit_volatility_index.btc_usd"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["deribit_volatility_index.btc_usd"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "volatility" : 148.516853994,
      "vix_median_ema" : 148.516511748,
      "vix_iqr_ema" : 148.516853994,
      "vix_ema" : 148.503035637,
      "timestamp" : 1606480389173,
      "index_name" : "btc_usd",
      "ed" : 148.516853994
    },
    "channel" : "deribit_volatility_index.btc_usd"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Provides volatility index subscription

Try in API console

Channel Parameters

Parameter Required Type Enum Description
index_name true string btc_usd
eth_usd
btc_usdt
eth_usdt
Index identifier, matches (base) cryptocurrency with quote currency

Response

Name Type Description
data object
  ›  index_name string Index identifier, matches (base) cryptocurrency with quote currency
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  volatility number Value of the corresponding volatility
  ›  volatility_use_mark number Value of the corresponding volatility

estimated_expiration_price.{index_name}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["estimated_expiration_price.btc_usd"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["estimated_expiration_price.btc_usd"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "seconds" : 180929,
      "price" : 3939.73,
      "is_estimated" : false
    },
    "channel" : "estimated_expiration_price.btc_usd"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Returns calculated (estimated) ending price for given index.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
index_name true string btc_usd
eth_usd
btc_usdt
eth_usdt
Index identifier, matches (base) cryptocurrency with quote currency

Response

Name Type Description
data object
  ›  is_estimated boolean When true then price is given as an estimated value, otherwise it's current index price
  ›  left_ticks number number of time ticks that are left until expiration (field added when price is estimated)
  ›  price number Index current or estimated price
  ›  seconds integer Number of seconds till finalizing the nearest instrument
  ›  total_ticks number number of total time ticks (field added when price is estimated)

instrument.state.{kind}.{currency}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["instrument.state.any.any"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["instrument.state.any.any"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "timestamp" : 1553080940000,
      "state" : "created",
      "instrument_name" : "BTC-22MAR19"
    },
    "channel" : "instrument.state.any.any"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about new or terminated instruments of given kind in given currency.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
kind true string future
option
any
Instrument kind or "any" for all
currency true string BTC
ETH
USDT
any
The currency symbol or "any" for all

Response

Name Type Description
data object
  ›  instrument_name string Unique instrument identifier
  ›  state string State of instrument - possible values: created, started, settled, closed, terminated
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

markprice.options.{index_name}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["markprice.options.btc_usd"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["markprice.options.btc_usd"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : [
      {
        "mark_price" : 0.06968487603001122,
        "iv" : 1.5000001635583038,
        "instrument_name" : "BTC-22FEB19-3750-C"
      },
      {
        "mark_price" : 0.11710577915095444,
        "iv" : 1.5000001635583038,
        "instrument_name" : "BTC-22FEB19-3500-C"
      },
      {
        "mark_price" : 0.09814100017129308,
        "iv" : 1.5000001635583038,
        "instrument_name" : "BTC-22FEB19-4250-P"
      },
      {
        "mark_price" : 0.008084913622698415,
        "iv" : 1.5000001635583038,
        "instrument_name" : "BTC-22FEB19-3500-P"
      },
      {
        "mark_price" : 0.03613861512644225,
        "iv" : 1.5000001635583038,
        "instrument_name" : "BTC-22FEB19-4000-C"
      }
    ],
    "channel" : "markprice.options.btc_usd"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Provides information about options markprices.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
index_name true string btc_usd
eth_usd
btc_usdt
eth_usdt
Index identifier, matches (base) cryptocurrency with quote currency

Response

Name Type Description
data array of object
  ›  instrument_name string Unique instrument identifier
  ›  iv number Value of the volatility of the underlying instrument
  ›  mark_price number The mark price for the instrument

perpetual.{instrument_name}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["perpetual.BTC-PERPETUAL.raw"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["perpetual.BTC-PERPETUAL.raw"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "timestamp" : 1571386349530,
      "interest" : 0.004999511380756577,
      "index_price" : 7872.88
    },
    "channel" : "perpetual.BTC-PERPETUAL.raw"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Provide current interest rate - but only for perpetual instruments. Other types won't generate any notification.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
interval true string 100ms
raw
Frequency of notifications. Events will be aggregated over this interval. The value raw means no aggregation will be applied

Response

Name Type Description
data object
  ›  index_price number Current index price
  ›  interest number Current interest
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

platform_state

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["platform_state"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["platform_state"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
    "jsonrpc": "2.0",
    "method": "subscription",
    "params": {
         "channel": "platform_state",
         "data": {
            "locked": true
        }
    }
}

Information about platform state.

Try in API console

Channel Parameters

This channel takes no parameters

Response

Name Type Description
data object
  ›  currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  locked boolean Value is set to 'true' when platform is locked

quote.{instrument_name}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["quote.BTC-PERPETUAL"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["quote.BTC-PERPETUAL"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "timestamp" : 1550658624149,
      "instrument_name" : "BTC-PERPETUAL",
      "best_bid_price" : 3914.97,
      "best_bid_amount" : 40,
      "best_ask_price" : 3996.61,
      "best_ask_amount" : 50
    },
    "channel" : "quote.BTC-PERPETUAL"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Best bid/ask price and size.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name

Response

Name Type Description
data object
  ›  best_ask_amount number It represents the requested order size of all best asks
  ›  best_ask_price number The current best ask price, null if there aren't any asks
  ›  best_bid_amount number It represents the requested order size of all best bids
  ›  best_bid_price number The current best bid price, null if there aren't any bids
  ›  instrument_name string Unique instrument identifier
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)

ticker.{instrument_name}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["ticker.BTC-PERPETUAL.raw"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["ticker.BTC-PERPETUAL.raw"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "timestamp" : 1550652954406,
      "stats" : {
        "volume" : null,
        "price_change" : null,
        "low" : null,
        "high" : null
      },
      "state" : "open",
      "settlement_price" : 3960.14,
      "open_interest" : 0.12759952124659626,
      "min_price" : 3943.21,
      "max_price" : 3982.84,
      "mark_price" : 3940.06,
      "last_price" : 3906,
      "instrument_name" : "BTC-PERPETUAL",
      "index_price" : 3918.51,
      "funding_8h" : 0.01520525,
      "current_funding" : 0.00499954,
      "best_bid_price" : 3914.97,
      "best_bid_amount" : 40,
      "best_ask_price" : 3996.61,
      "best_ask_amount" : 50
    },
    "channel" : "ticker.BTC-PERPETUAL.raw"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Key information about the instrument

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
interval true string 100ms
raw
Frequency of notifications. Events will be aggregated over this interval. The value raw means no aggregation will be applied

Response

Name Type Description
data object
  ›  ask_iv number (Only for option) implied volatility for best ask
  ›  best_ask_amount number It represents the requested order size of all best asks
  ›  best_ask_price number The current best ask price, null if there aren't any asks
  ›  best_bid_amount number It represents the requested order size of all best bids
  ›  best_bid_price number The current best bid price, null if there aren't any bids
  ›  bid_iv number (Only for option) implied volatility for best bid
  ›  current_funding number Current funding (perpetual only)
  ›  delivery_price number The settlement price for the instrument. Only when state = closed
  ›  funding_8h number Funding 8h (perpetual only)
  ›  greeks object Only for options
  ›    ›  delta number (Only for option) The delta value for the option
  ›    ›  gamma number (Only for option) The gamma value for the option
  ›    ›  rho number (Only for option) The rho value for the option
  ›    ›  theta number (Only for option) The theta value for the option
  ›    ›  vega number (Only for option) The vega value for the option
  ›  index_price number Current index price
  ›  instrument_name string Unique instrument identifier
  ›  interest_rate number Interest rate used in implied volatility calculations (options only)
  ›  last_price number The price for the last trade
  ›  mark_iv number (Only for option) implied volatility for mark price
  ›  mark_price number The mark price for the instrument
  ›  max_price number The maximum price for the future. Any buy orders you submit higher than this price, will be clamped to this maximum.
  ›  min_price number The minimum price for the future. Any sell orders you submit lower than this price will be clamped to this minimum.
  ›  open_interest number The total amount of outstanding contracts in the corresponding amount units. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  settlement_price number The settlement price for the instrument. Only when state = open
  ›  state string The state of the order book. Possible values are open and closed.
  ›  stats object
  ›    ›  high number Highest price during 24h
  ›    ›  low number Lowest price during 24h
  ›    ›  price_change number 24-hour price change expressed as a percentage, null if there weren't any trades
  ›    ›  volume number Volume during last 24h in base currency
  ›  timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  underlying_index number Name of the underlying future, or index_price (options only)
  ›  underlying_price number Underlying price for implied volatility calculations (options only)

trades.{instrument_name}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["trades.BTC-PERPETUAL.raw"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["trades.BTC-PERPETUAL.raw"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : [
      {
        "trade_seq" : 30289442,
        "trade_id" : "48079269",
        "timestamp" : 1590484512188,
        "tick_direction" : 2,
        "price" : 8950,
        "mark_price" : 8948.9,
        "instrument_name" : "BTC-PERPETUAL",
        "index_price" : 8955.88,
        "direction" : "sell",
        "amount" : 10
      }
    ],
    "channel" : "trades.BTC-PERPETUAL.raw"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about trades for an instrument.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
interval true string 100ms
raw
Frequency of notifications. Events will be aggregated over this interval. The value raw means no aggregation will be applied

Response

Name Type Description
data object
  ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  block_trade_id string Block trade id - when trade was part of block trade
  ›  direction string Direction: buy, or sell
  ›  index_price number Index Price at the moment of trade
  ›  instrument_name string Unique instrument identifier
  ›  iv number Option implied volatility for the price (Option only)
  ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›  mark_price number Mark Price at the moment of trade
  ›  price number Price in base currency
  ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›  timestamp integer The timestamp of the trade
  ›  trade_id string Unique (per currency) trade identifier
  ›  trade_seq integer The sequence number of the trade within instrument

trades.{kind}.{currency}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["trades.option.BTC.raw"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "public/subscribe",
     "id": 42,
     "params": {
        "channels": ["trades.option.BTC.raw"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : [
      {
        "trade_seq" : 2,
        "trade_id" : "48079289",
        "timestamp" : 1590484589306,
        "tick_direction" : 2,
        "price" : 0.0075,
        "mark_price" : 0.01062686,
        "iv" : 47.58,
        "instrument_name" : "BTC-27MAY20-9000-C",
        "index_price" : 8956.17,
        "direction" : "sell",
        "amount" : 3
      }
    ],
    "channel" : "trades.option.BTC.raw"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about trades in any instrument of a given kind and given currency.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
kind true string future
option
Instrument kind, "future" or "option"
currency true string BTC
ETH
USDT
any
The currency symbol or "any" for all
interval true string 100ms
raw
Frequency of notifications. Events will be aggregated over this interval. The value raw means no aggregation will be applied

Response

Name Type Description
data array of object
  ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  block_trade_id string Block trade id - when trade was part of block trade
  ›  direction string Direction: buy, or sell
  ›  index_price number Index Price at the moment of trade
  ›  instrument_name string Unique instrument identifier
  ›  iv number Option implied volatility for the price (Option only)
  ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›  mark_price number Mark Price at the moment of trade
  ›  price number Price in base currency
  ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›  timestamp integer The timestamp of the trade
  ›  trade_id string Unique (per currency) trade identifier
  ›  trade_seq integer The sequence number of the trade within instrument

user.changes.{instrument_name}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.changes.BTC-PERPETUAL.raw"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.changes.BTC-PERPETUAL.raw"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "trades" : [
        {
          "trade_seq" : 866638,
          "trade_id" : "1430914",
          "timestamp" : 1605780344032,
          "tick_direction" : 1,
          "state" : "filled",
          "self_trade" : false,
          "reduce_only" : false,
          "profit_loss" : 0.00004898,
          "price" : 17391,
          "post_only" : false,
          "order_type" : "market",
          "order_id" : "3398016",
          "matching_id" : null,
          "mark_price" : 17391,
          "liquidity" : "T",
          "instrument_name" : "BTC-PERPETUAL",
          "index_price" : 17501.88,
          "fee_currency" : "BTC",
          "fee" : 1.6e-7,
          "direction" : "sell",
          "amount" : 10
        }
      ],
      "positions" : [
        {
          "total_profit_loss" : 1.69711368,
          "size_currency" : 10.646886321,
          "size" : 185160,
          "settlement_price" : 16025.83,
          "realized_profit_loss" : 0.012454598,
          "realized_funding" : 0.01235663,
          "open_orders_margin" : 0,
          "mark_price" : 17391,
          "maintenance_margin" : 0.234575865,
          "leverage" : 33,
          "kind" : "future",
          "instrument_name" : "BTC-PERPETUAL",
          "initial_margin" : 0.319750953,
          "index_price" : 17501.88,
          "floating_profit_loss" : 0.906961435,
          "direction" : "buy",
          "delta" : 10.646886321,
          "average_price" : 15000
        }
      ],
      "orders" : [
        {
          "web" : true,
          "time_in_force" : "good_til_cancelled",
          "replaced" : false,
          "reduce_only" : false,
          "profit_loss" : 0.00009166,
          "price" : 15665.5,
          "post_only" : false,
          "order_type" : "market",
          "order_state" : "filled",
          "order_id" : "3398016",
          "max_show" : 10,
          "last_update_timestamp" : 1605780344032,
          "label" : "",
          "is_liquidation" : false,
          "instrument_name" : "BTC-PERPETUAL",
          "filled_amount" : 10,
          "direction" : "sell",
          "creation_timestamp" : 1605780344032,
          "commission" : 1.6e-7,
          "average_price" : 17391,
          "api" : false,
          "amount" : 10
        }
      ],
      "instrument_name" : "BTC-PERPETUAL"
    },
    "channel" : "user.changes.BTC-PERPETUAL.raw"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about user's updates related to order, trades, etc. in an instrument.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
interval true string 100ms
raw
Frequency of notifications. Events will be aggregated over this interval. The value raw means no aggregation will be applied

Response

Name Type Description
data array of object
  ›  instrument_name string Unique instrument identifier
  ›  orders array of object
  ›    ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›    ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›    ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›    ›  api boolean true if created with API
  ›    ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  web boolean true if created via Deribit frontend (optional)
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›    ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›    ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›    ›  original_order_type string Original order type. Optional field
  ›    ›  price number Price in base currency
  ›    ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›    ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›    ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›    ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  post_only boolean true for post-only orders only
  ›    ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›    ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  average_price number Average fill price of the order
  ›    ›  order_id string Unique order identifier
  ›    ›  reduce_only boolean true for reduce-only orders only
  ›    ›  commission number Commission paid so far (in base currency)
  ›    ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›    ›  stop_price number Stop price (Only for future stop orders)
  ›    ›  label string User defined label (up to 64 characters)
  ›    ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  direction string Direction: buy, or sell
  ›    ›  is_liquidation boolean true if order was automatically created during liquidation
  ›    ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›    ›  usd number Option price in USD (Only if advanced="usd")
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›    ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".
  ›  position array of object
  ›    ›  average_price number Average price of trades that built this position
  ›    ›  average_price_usd number Only for options, average price in USD
  ›    ›  delta number Delta parameter
  ›    ›  direction string Direction: buy, sell or zero
  ›    ›  floating_profit_loss number Floating profit or loss
  ›    ›  floating_profit_loss_usd number Only for options, floating profit or loss in USD
  ›    ›  gamma number Only for options, Gamma parameter
  ›    ›  index_price number Current index price
  ›    ›  initial_margin number Initial margin
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  kind string Instrument kind, "future" or "option"
  ›    ›  leverage integer Current available leverage for future position
  ›    ›  maintenance_margin number Maintenance margin
  ›    ›  mark_price number Current mark price for position's instrument
  ›    ›  open_orders_margin number Open orders margin
  ›    ›  realized_funding number Realized Funding in current session included in session realized profit or loss, only for positions of perpetual instruments
  ›    ›  realized_profit_loss number Realized profit or loss
  ›    ›  settlement_price number Last settlement price for position's instrument 0 if instrument wasn't settled yet
  ›    ›  size number Position size for futures size in quote currency (e.g. USD), for options size is in base currency (e.g. BTC)
  ›    ›  size_currency number Only for futures, position size in base currency
  ›    ›  theta number Only for options, Theta parameter
  ›    ›  total_profit_loss number Profit or loss from position
  ›    ›  vega number Only for options, Vega parameter
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

user.changes.{kind}.{currency}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.changes.future.BTC.raw"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.changes.future.BTC.raw"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "trades" : [
        {
          "trade_seq" : 866638,
          "trade_id" : "1430914",
          "timestamp" : 1605780344032,
          "tick_direction" : 1,
          "state" : "filled",
          "self_trade" : false,
          "reduce_only" : false,
          "profit_loss" : 0.00004898,
          "price" : 17391,
          "post_only" : false,
          "order_type" : "market",
          "order_id" : "3398016",
          "matching_id" : null,
          "mark_price" : 17391,
          "liquidity" : "T",
          "instrument_name" : "BTC-PERPETUAL",
          "index_price" : 17501.88,
          "fee_currency" : "BTC",
          "fee" : 1.6e-7,
          "direction" : "sell",
          "amount" : 10
        }
      ],
      "positions" : [
        {
          "total_profit_loss" : 1.69711368,
          "size_currency" : 10.646886321,
          "size" : 185160,
          "settlement_price" : 16025.83,
          "realized_profit_loss" : 0.012454598,
          "realized_funding" : 0.01235663,
          "open_orders_margin" : 0,
          "mark_price" : 17391,
          "maintenance_margin" : 0.234575865,
          "leverage" : 33,
          "kind" : "future",
          "instrument_name" : "BTC-PERPETUAL",
          "initial_margin" : 0.319750953,
          "index_price" : 17501.88,
          "floating_profit_loss" : 0.906961435,
          "direction" : "buy",
          "delta" : 10.646886321,
          "average_price" : 15000
        }
      ],
      "orders" : [
        {
          "web" : true,
          "time_in_force" : "good_til_cancelled",
          "replaced" : false,
          "reduce_only" : false,
          "profit_loss" : 0.00009166,
          "price" : 15665.5,
          "post_only" : false,
          "order_type" : "market",
          "order_state" : "filled",
          "order_id" : "3398016",
          "max_show" : 10,
          "last_update_timestamp" : 1605780344032,
          "label" : "",
          "is_liquidation" : false,
          "instrument_name" : "BTC-PERPETUAL",
          "filled_amount" : 10,
          "direction" : "sell",
          "creation_timestamp" : 1605780344032,
          "commission" : 1.6e-7,
          "average_price" : 17391,
          "api" : false,
          "amount" : 10
        }
      ],
      "instrument_name" : "BTC-PERPETUAL"
    },
    "channel" : "user.changes.future.BTC.raw"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about changes in user's updates related to order, trades, etc. in instruments of a given kind and currency.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
kind true string future
option
any
Instrument kind or "any" for all
currency true string BTC
ETH
USDT
any
The currency symbol or "any" for all
interval true string 100ms
raw
Frequency of notifications. Events will be aggregated over this interval. The value raw means no aggregation will be applied

Response

Name Type Description
data array of object
  ›  instrument_name string Unique instrument identifier
  ›  orders array of object
  ›    ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›    ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›    ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›    ›  api boolean true if created with API
  ›    ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  web boolean true if created via Deribit frontend (optional)
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›    ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›    ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›    ›  original_order_type string Original order type. Optional field
  ›    ›  price number Price in base currency
  ›    ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›    ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›    ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›    ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  post_only boolean true for post-only orders only
  ›    ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›    ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  average_price number Average fill price of the order
  ›    ›  order_id string Unique order identifier
  ›    ›  reduce_only boolean true for reduce-only orders only
  ›    ›  commission number Commission paid so far (in base currency)
  ›    ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›    ›  stop_price number Stop price (Only for future stop orders)
  ›    ›  label string User defined label (up to 64 characters)
  ›    ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›    ›  direction string Direction: buy, or sell
  ›    ›  is_liquidation boolean true if order was automatically created during liquidation
  ›    ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›    ›  usd number Option price in USD (Only if advanced="usd")
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›    ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".
  ›  position array of object
  ›    ›  average_price number Average price of trades that built this position
  ›    ›  average_price_usd number Only for options, average price in USD
  ›    ›  delta number Delta parameter
  ›    ›  direction string Direction: buy, sell or zero
  ›    ›  floating_profit_loss number Floating profit or loss
  ›    ›  floating_profit_loss_usd number Only for options, floating profit or loss in USD
  ›    ›  gamma number Only for options, Gamma parameter
  ›    ›  index_price number Current index price
  ›    ›  initial_margin number Initial margin
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  kind string Instrument kind, "future" or "option"
  ›    ›  leverage integer Current available leverage for future position
  ›    ›  maintenance_margin number Maintenance margin
  ›    ›  mark_price number Current mark price for position's instrument
  ›    ›  open_orders_margin number Open orders margin
  ›    ›  realized_funding number Realized Funding in current session included in session realized profit or loss, only for positions of perpetual instruments
  ›    ›  realized_profit_loss number Realized profit or loss
  ›    ›  settlement_price number Last settlement price for position's instrument 0 if instrument wasn't settled yet
  ›    ›  size number Position size for futures size in quote currency (e.g. USD), for options size is in base currency (e.g. BTC)
  ›    ›  size_currency number Only for futures, position size in base currency
  ›    ›  theta number Only for options, Theta parameter
  ›    ›  total_profit_loss number Profit or loss from position
  ›    ›  vega number Only for options, Vega parameter
  ›  trades array of object
  ›    ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›    ›  block_trade_id string Block trade id - when trade was part of block trade
  ›    ›  direction string Direction: buy, or sell
  ›    ›  fee number User's fee in units of the specified fee_currency
  ›    ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›    ›  index_price number Index Price at the moment of trade
  ›    ›  instrument_name string Unique instrument identifier
  ›    ›  iv number Option implied volatility for the price (Option only)
  ›    ›  label string User defined label (presented only when previously set for order by user)
  ›    ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›    ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›    ›  mark_price number Mark Price at the moment of trade
  ›    ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›    ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›    ›  order_type string Order type: "limit, "market", or "liquidation"
  ›    ›  post_only string true if user order is post-only
  ›    ›  price number Price in base currency
  ›    ›  profit_loss number Profit and loss in base currency.
  ›    ›  reduce_only string true if user order is reduce-only
  ›    ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›    ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›    ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›    ›  timestamp integer The timestamp of the trade
  ›    ›  trade_id string Unique (per currency) trade identifier
  ›    ›  trade_seq integer The sequence number of the trade within instrument
  ›    ›  underlying_price number Underlying price for implied volatility calculations (Options only)

user.mmp_trigger.{currency}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.mmp_trigger.btc"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.mmp_trigger.btc"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "frozen_until" : 0
    },
    "channel" : "user.mmp_trigger.btc"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Triggered when one of mmp limits is crossed

Try in API console

Channel Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
data object
  ›  frozen_until integer Timestamp until user will be frozen, i 0 it means that user is frozen until manual reset.

user.orders.{instrument_name}.raw

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.orders.BTC-PERPETUAL.raw"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.orders.BTC-PERPETUAL.raw"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "time_in_force" : "good_til_cancelled",
      "replaced" : false,
      "reduce_only" : false,
      "profit_loss" : 0,
      "price" : 10502.52,
      "post_only" : false,
      "original_order_type" : "market",
      "order_type" : "limit",
      "order_state" : "open",
      "order_id" : "5",
      "max_show" : 200,
      "last_update_timestamp" : 1581507423789,
      "label" : "",
      "is_liquidation" : false,
      "instrument_name" : "BTC-PERPETUAL",
      "filled_amount" : 0,
      "direction" : "buy",
      "creation_timestamp" : 1581507423789,
      "commission" : 0,
      "average_price" : 0,
      "api" : false,
      "amount" : 200
    },
    "channel" : "user.orders.BTC-PERPETUAL.raw"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about changes in user's orders for given instrument.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name

Response

Name Type Description
data object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

user.orders.{instrument_name}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.orders.BTC-PERPETUAL.100ms"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.orders.BTC-PERPETUAL.100ms"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : [
      {
        "time_in_force" : "good_til_cancelled",
        "replaced" : false,
        "reduce_only" : false,
        "profit_loss" : 0,
        "price" : 10460.43,
        "post_only" : false,
        "original_order_type" : "market",
        "order_type" : "limit",
        "order_state" : "open",
        "order_id" : "4",
        "max_show" : 200,
        "last_update_timestamp" : 1581507159533,
        "label" : "",
        "is_liquidation" : false,
        "instrument_name" : "BTC-PERPETUAL",
        "filled_amount" : 0,
        "direction" : "buy",
        "creation_timestamp" : 1581507159533,
        "commission" : 0,
        "average_price" : 0,
        "api" : false,
        "amount" : 200
      }
    ],
    "channel" : "user.orders.BTC-PERPETUAL.100ms"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about changes in user's orders for given instrument.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
interval true string 100ms Frequency of notifications. Events will be aggregated over this interval.

Response

Name Type Description
data array of object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

user.orders.{kind}.{currency}.raw

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.orders.any.any.raw"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.orders.any.any.raw"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "time_in_force" : "good_til_cancelled",
      "replaced" : false,
      "reduce_only" : false,
      "profit_loss" : 0,
      "price" : 10542.68,
      "post_only" : false,
      "original_order_type" : "market",
      "order_type" : "limit",
      "order_state" : "open",
      "order_id" : "6",
      "max_show" : 200,
      "last_update_timestamp" : 1581507583024,
      "label" : "",
      "is_liquidation" : false,
      "instrument_name" : "BTC-PERPETUAL",
      "filled_amount" : 0,
      "direction" : "buy",
      "creation_timestamp" : 1581507583024,
      "commission" : 0,
      "average_price" : 0,
      "api" : false,
      "amount" : 200
    },
    "channel" : "user.orders.any.any.raw"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about changes in user's orders in instruments of a given kind and currency.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
kind true string future
option
any
Instrument kind or "any" for all
currency true string BTC
ETH
USDT
any
The currency symbol or "any" for all

Response

Name Type Description
data object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

user.orders.{kind}.{currency}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.orders.future.BTC.100ms"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.orders.future.BTC.100ms"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : [
      {
        "time_in_force" : "good_til_cancelled",
        "reduce_only" : false,
        "profit_loss" : 0,
        "price" : 3928.5,
        "post_only" : false,
        "order_type" : "limit",
        "order_state" : "open",
        "order_id" : "476137",
        "max_show" : 120,
        "last_update_timestamp" : 1550826337209,
        "label" : "",
        "is_liquidation" : false,
        "instrument_name" : "BTC-PERPETUAL",
        "filled_amount" : 0,
        "direction" : "buy",
        "creation_timestamp" : 1550826337209,
        "commission" : 0,
        "average_price" : 0,
        "api" : false,
        "amount" : 120
      }
    ],
    "channel" : "user.orders.future.BTC.100ms"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about changes in user's orders in instruments of a given kind and currency.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
kind true string future
option
any
Instrument kind or "any" for all
currency true string BTC
ETH
USDT
any
The currency symbol or "any" for all
interval true string 100ms Frequency of notifications. Events will be aggregated over this interval.

Response

Name Type Description
data array of object
  ›  mmp_cancelled boolean true if order was cancelled by mmp trigger (optional)
  ›  order_state string Order state: "open", "filled", "rejected", "cancelled", "untriggered"
  ›  max_show number Maximum amount within an order to be shown to other traders, 0 for invisible order.
  ›  api boolean true if created with API
  ›  amount number It represents the requested order size. For perpetual and futures the amount is in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  web boolean true if created via Deribit frontend (optional)
  ›  instrument_name string Unique instrument identifier
  ›  advanced string advanced type: "usd" or "implv" (Only for options; field is omitted if not applicable).
  ›  triggered boolean Whether the stop order has been triggered (Only for stop orders)
  ›  block_trade boolean true if order made from block_trade trade, added only in that case.
  ›  original_order_type string Original order type. Optional field
  ›  price number Price in base currency
  ›  time_in_force string Order time in force: "good_til_cancelled", "fill_or_kill", "immediate_or_cancel"
  ›  auto_replaced boolean Options, advanced orders only - true if last modification of the order was performed by the pricing engine, otherwise false.
  ›  stop_order_id string Id of the stop order that was triggered to create the order (Only for orders that were created by triggered stop orders).
  ›  last_update_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  post_only boolean true for post-only orders only
  ›  replaced boolean true if the order was edited (by user or - in case of advanced options orders - by pricing engine), otherwise false.
  ›  filled_amount number Filled amount of the order. For perpetual and futures the filled_amount is in USD units, for options - in units or corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  average_price number Average fill price of the order
  ›  order_id string Unique order identifier
  ›  reduce_only boolean true for reduce-only orders only
  ›  commission number Commission paid so far (in base currency)
  ›  app_name string Name of the application that placed the order on behalf of the user (optional).
  ›  stop_price number Stop price (Only for future stop orders)
  ›  label string User defined label (up to 64 characters)
  ›  creation_timestamp integer The timestamp (milliseconds since the Unix epoch)
  ›  direction string Direction: buy, or sell
  ›  is_liquidation boolean true if order was automatically created during liquidation
  ›  order_type string Order type: "limit", "market", "stop_limit", "stop_market"
  ›  usd number Option price in USD (Only if advanced="usd")
  ›  profit_loss number Profit and loss in base currency.
  ›  implv number Implied volatility in percent. (Only if advanced="implv")
  ›  trigger string Trigger type (Only for stop orders). Allowed values: "index_price", "mark_price", "last_price".

user.portfolio.{currency}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.portfolio.btc"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.portfolio.btc"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : {
      "total_pl" : 0.00000425,
      "session_upl" : 0.00000425,
      "session_rpl" : -2e-8,
      "projected_maintenance_margin" : 0.00009141,
      "projected_initial_margin" : 0.00012542,
      "projected_delta_total" : 0.0043,
      "portfolio_margining_enabled" : false,
      "options_vega" : 0,
      "options_value" : 0,
      "options_theta" : 0,
      "options_session_upl" : 0,
      "options_session_rpl" : 0,
      "options_pl" : 0,
      "options_gamma" : 0,
      "options_delta" : 0,
      "margin_balance" : 0.2340038,
      "maintenance_margin" : 0.00009141,
      "initial_margin" : 0.00012542,
      "futures_session_upl" : 0.00000425,
      "futures_session_rpl" : -2e-8,
      "futures_pl" : 0.00000425,
      "estimated_liquidation_ratio" : 0.01822795,
      "equity" : 0.2340038,
      "delta_total" : 0.0043,
      "currency" : "BTC",
      "balance" : 0.23399957,
      "available_withdrawal_funds" : 0.23387415,
      "available_funds" : 0.23387838
    },
    "channel" : "user.portfolio.btc"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Provides information about current user portfolio

Try in API console

Channel Parameters

Parameter Required Type Enum Description
currency true string BTC
ETH
USDT
The currency symbol

Response

Name Type Description
data object
  ›  available_funds number The account's available funds
  ›  available_withdrawal_funds number The account's available to withdrawal funds
  ›  balance number The account's balance
  ›  currency string The selected currency
  ›  delta_total number The sum of position deltas
  ›  equity number The account's current equity
  ›  estimated_liquidation_ratio number Estimated Liquidation Ratio is returned only for users without portfolio margining enabled. Multiplying it by future position's market price returns its estimated liquidation price.
  ›  futures_pl number Futures profit and Loss
  ›  futures_session_rpl number Futures session realized profit and Loss
  ›  futures_session_upl number Futures session unrealized profit and Loss
  ›  initial_margin number The account's initial margin
  ›  maintenance_margin number The maintenance margin.
  ›  margin_balance number The account's margin balance
  ›  options_delta number Options summary delta
  ›  options_gamma number Options summary gamma
  ›  options_pl number Options profit and Loss
  ›  options_session_rpl number Options session realized profit and Loss
  ›  options_session_upl number Options session unrealized profit and Loss
  ›  options_theta number Options summary theta
  ›  options_value number Options value
  ›  options_vega number Options summary vega
  ›  portfolio_margining_enabled boolean When true portfolio margining is enabled for user
  ›  projected_delta_total number The sum of position deltas without positions that will expire during closest expiration
  ›  projected_initial_margin number Projected initial margin
  ›  projected_maintenance_margin number Projected maintenance margin
  ›  session_rpl number Session realized profit and loss
  ›  session_upl number Session unrealized profit and loss
  ›  total_pl number Profit and loss

user.trades.{instrument_name}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.trades.BTC-PERPETUAL.raw"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.trades.BTC-PERPETUAL.raw"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : [
      {
        "trade_seq" : 30289432,
        "trade_id" : "48079254",
        "timestamp" : 1590484156350,
        "tick_direction" : 0,
        "state" : "filled",
        "self_trade" : false,
        "reduce_only" : false,
        "price" : 8954,
        "post_only" : false,
        "order_type" : "market",
        "order_id" : "4008965646",
        "matching_id" : null,
        "mark_price" : 8952.86,
        "liquidity" : "T",
        "instrument_name" : "BTC-PERPETUAL",
        "index_price" : 8956.73,
        "fee_currency" : "BTC",
        "fee" : 0.00000168,
        "direction" : "sell",
        "amount" : 20
      },
      {
        "trade_seq" : 30289433,
        "trade_id" : "48079255",
        "timestamp" : 1590484156350,
        "tick_direction" : 1,
        "state" : "filled",
        "self_trade" : false,
        "reduce_only" : false,
        "price" : 8954,
        "post_only" : false,
        "order_type" : "market",
        "order_id" : "4008965646",
        "matching_id" : null,
        "mark_price" : 8952.86,
        "liquidity" : "T",
        "instrument_name" : "BTC-PERPETUAL",
        "index_price" : 8956.73,
        "fee_currency" : "BTC",
        "fee" : 0.00000168,
        "direction" : "sell",
        "amount" : 20
      }
    ],
    "channel" : "user.trades.BTC-PERPETUAL.raw"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about user's trades in an instrument.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
instrument_name true string Instrument name
interval true string 100ms
raw
Frequency of notifications. Events will be aggregated over this interval. The value raw means no aggregation will be applied

Response

Name Type Description
data array of object
  ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  block_trade_id string Block trade id - when trade was part of block trade
  ›  direction string Direction: buy, or sell
  ›  fee number User's fee in units of the specified fee_currency
  ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  index_price number Index Price at the moment of trade
  ›  instrument_name string Unique instrument identifier
  ›  iv number Option implied volatility for the price (Option only)
  ›  label string User defined label (presented only when previously set for order by user)
  ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›  mark_price number Mark Price at the moment of trade
  ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›  order_type string Order type: "limit, "market", or "liquidation"
  ›  post_only string true if user order is post-only
  ›  price number Price in base currency
  ›  profit_loss number Profit and loss in base currency.
  ›  reduce_only string true if user order is reduce-only
  ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›  timestamp integer The timestamp of the trade
  ›  trade_id string Unique (per currency) trade identifier
  ›  trade_seq integer The sequence number of the trade within instrument
  ›  underlying_price number Underlying price for implied volatility calculations (Options only)

user.trades.{kind}.{currency}.{interval}

Subscriptions are only available via websockets.

// To subscribe to this channel:
var msg = 
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.trades.future.BTC.100ms"]}
    };
var ws = new WebSocket('wss://test.deribit.com/ws/api/v2');
ws.onmessage = function (e) {
    // do something with the notifications...
    console.log('received from server : ', e.data);
};
ws.onopen = function () {
    ws.send(JSON.stringify(msg));
};
import asyncio
import websockets
import json

# To subscribe to this channel:
msg = \
    {"jsonrpc": "2.0",
     "method": "private/subscribe",
     "id": 42,
     "params": {
        "channels": ["user.trades.future.BTC.100ms"]}
    }

async def call_api(msg):
   async with websockets.connect('wss://test.deribit.com/ws/api/v2') as websocket:
       await websocket.send(msg)
       while websocket.open:
           response = await websocket.recv()
           # do something with the notifications...
           print(response)

asyncio.get_event_loop().run_until_complete(call_api(json.dumps(msg)))

This subscription will send next notifications like this:

{
  "params" : {
    "data" : [
      {
        "trade_seq" : 74405,
        "trade_id" : "48079262",
        "timestamp" : 1590484255886,
        "tick_direction" : 2,
        "state" : "filled",
        "self_trade" : false,
        "reduce_only" : false,
        "price" : 8947,
        "post_only" : false,
        "order_type" : "limit",
        "order_id" : "4008978075",
        "matching_id" : null,
        "mark_price" : 8970.03,
        "liquidity" : "T",
        "instrument_name" : "BTC-25SEP20",
        "index_price" : 8953.53,
        "fee_currency" : "BTC",
        "fee" : 0.00049961,
        "direction" : "sell",
        "amount" : 8940
      }
    ],
    "channel" : "user.trades.future.BTC.100ms"
  },
  "method" : "subscription",
  "jsonrpc" : "2.0"
}

Get notifications about user's trades in any instrument of a given kind and given currency.

Try in API console

Channel Parameters

Parameter Required Type Enum Description
kind true string future
option
any
Instrument kind or "any" for all
currency true string BTC
ETH
USDT
any
The currency symbol or "any" for all
interval true string 100ms
raw
Frequency of notifications. Events will be aggregated over this interval. The value raw means no aggregation will be applied

Response

Name Type Description
data array of object
  ›  amount number Trade amount. For perpetual and futures - in USD units, for options it is amount of corresponding cryptocurrency contracts, e.g., BTC or ETH.
  ›  block_trade_id string Block trade id - when trade was part of block trade
  ›  direction string Direction: buy, or sell
  ›  fee number User's fee in units of the specified fee_currency
  ›  fee_currency string Currency, i.e "BTC", "ETH", "USDT"
  ›  index_price number Index Price at the moment of trade
  ›  instrument_name string Unique instrument identifier
  ›  iv number Option implied volatility for the price (Option only)
  ›  label string User defined label (presented only when previously set for order by user)
  ›  liquidation string Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
  ›  liquidity string Describes what was role of users order: "M" when it was maker order, "T" when it was taker order
  ›  mark_price number Mark Price at the moment of trade
  ›  matching_id string Always null, except for a self-trade which is possible only if self-trading is switched on for the account (in that case this will be id of the maker order of the subscriber)
  ›  order_id string Id of the user order (maker or taker), i.e. subscriber's order id that took part in the trade
  ›  order_type string Order type: "limit, "market", or "liquidation"
  ›  post_only string true if user order is post-only
  ›  price number Price in base currency
  ›  profit_loss number Profit and loss in base currency.
  ›  reduce_only string true if user order is reduce-only
  ›  self_trade boolean true if the trade is against own order. This can only happen when your account has self-trading enabled. Contact an administrator if you think you need that
  ›  state string Order state: "open", "filled", "rejected", "cancelled", "untriggered" or "archive" (if order was archived)
  ›  tick_direction integer Direction of the "tick" (0 = Plus Tick, 1 = Zero-Plus Tick, 2 = Minus Tick, 3 = Zero-Minus Tick).
  ›  timestamp integer The timestamp of the trade
  ›  trade_id string Unique (per currency) trade identifier
  ›  trade_seq integer The sequence number of the trade within instrument
  ›  underlying_price number Underlying price for implied volatility calculations (Options only)

RPC Error Codes

Error Code Short message Description
0 or absent Success, No error.
9999 "api_not_enabled" User didn't enable API for the Account.
10000 "authorization_required" Authorization issue, invalid or absent signature etc.
10001 "error" Some general failure, no public information available.
10002 "qty_too_low" Order quantity is too low.
10003 "order_overlap" Rejection, order overlap is found and self-trading is not enabled.
10004 "order_not_found" Attempt to operate with order that can't be found by specified id.
10005 "price_too_low <Limit>" Price is too low, <Limit> defines current limit for the operation.
10006 "price_too_low4idx <Limit>" Price is too low for current index, <Limit> defines current bottom limit for the operation.
10007 "price_too_high <Limit>" Price is too high, <Limit> defines current up limit for the operation.
10008 "price_too_high4idx <Limit>" Price is too high for current index, <Limit> defines current up limit for the operation.
10009 "not_enough_funds" Account has not enough funds for the operation.
10010 "already_closed" Attempt of doing something with closed order.
10011 "price_not_allowed" This price is not allowed for some reason.
10012 "book_closed" Operation for instrument which order book had been closed.
10013 "pme_max_total_open_orders <Limit>" Total limit of open orders has been exceeded, it is applicable for PME users.
10014 "pme_max_future_open_orders <Limit>" Limit of count of futures' open orders has been exceeded, it is applicable for PME users.
10015 "pme_max_option_open_orders <Limit>" Limit of count of options' open orders has been exceeded, it is applicable for PME users.
10016 "pme_max_future_open_orders_size <Limit>" Limit of size for futures has been exceeded, it is applicable for PME users.
10017 "pme_max_option_open_orders_size <Limit>" Limit of size for options has been exceeded, it is applicable for PME users.
10018 "non_pme_max_future_position_size <Limit>" Limit of size for futures has been exceeded, it is applicable for non-PME users.
10019 "locked_by_admin" Trading is temporary locked by admin.
10020 "invalid_or_unsupported_instrument" Instrument name is not valid.
10021 "invalid_amount" Amount is not valid.
10022 "invalid_quantity" quantity was not recognized as a valid number (for API v1).
10023 "invalid_price" price was not recognized as a valid number.
10024 "invalid_max_show" max_show parameter was not recognized as a valid number.
10025 "invalid_order_id" Order id is missing or its format was not recognized as valid.
10026 "price_precision_exceeded" Extra precision of the price is not supported.
10027 "non_integer_contract_amount" Futures contract amount was not recognized as integer.
10028 "too_many_requests" Allowed request rate has been exceeded.
10029 "not_owner_of_order" Attempt to operate with not own order.
10030 "must_be_websocket_request" REST request where Websocket is expected.
10031 "invalid_args_for_instrument" Some of arguments are not recognized as valid.
10032 "whole_cost_too_low" Total cost is too low.
10033 "not_implemented" Method is not implemented yet.
10034 "stop_price_too_high" Stop price is too high.
10035 "stop_price_too_low" Stop price is too low.
10036 "invalid_max_show_amount" Max Show Amount is not valid.
10040 "retry" Request can't be processed right now and should be retried.
10041 "settlement_in_progress" Settlement is in progress. Every day at settlement time for several seconds, the system calculates user profits and updates balances. That time trading is paused for several seconds till the calculation is completed.
10043 "price_wrong_tick" Price has to be rounded to a certain tick size.
10044 "stop_price_wrong_tick" Stop Price has to be rounded to a certain tick size.
10045 "can_not_cancel_liquidation_order" Liquidation order can't be canceled.
10046 "can_not_edit_liquidation_order" Liquidation order can't be edited.
10047 "matching_engine_queue_full" Reached limit of pending Matching Engine requests for user.
10048 "not_on_this_server" The requested operation is not available on this server.
10049 "cancel_on_disconnect_failed" Enabling Cancel On Disconnect for the connection failed.
10066 "too_many_concurrent_requests" The client has sent too many public requests that have not yet been executed.
11008 "already_filled" This request is not allowed in regards to the filled order.
11029 "invalid_arguments" Some invalid input has been detected.
11030 "other_reject <Reason>" Some rejects which are not considered as very often, more info may be specified in <Reason>.
11031 "other_error <Error>" Some errors which are not considered as very often, more info may be specified in <Error>.
11035 "no_more_stops <Limit>" Allowed amount of stop orders has been exceeded.
11036 "invalid_stop_price_" Invalid StopPx (too high or too low) as to the last, current index or market price
11037 "outdated_instrument_for_IV_order" Instrument already not available for trading.
11038 "no_adv_for_futures" Advanced orders are not available for futures.
11039 "no_adv_postonly" Advanced post-only orders are not supported yet.
11041 "not_adv_order" Advanced order properties can't be set if the order is not advanced.
11042 "permission_denied" Permission for the operation has been denied.
11043 "bad_argument" Bad argument has been passed.
11044 "not_open_order" Attempt to do open order operations with the not open order.
11045 "invalid_event" Event name has not been recognized.
11046 "outdated_instrument" At several minutes to instrument expiration, corresponding advanced implied volatility orders are not allowed.
11047 "unsupported_arg_combination" The specified combination of arguments is not supported.
11048 "wrong_max_show_for_option" Wrong Max Show for options.
11049 "bad_arguments" Several bad arguments have been passed.
11050 "bad_request" Request has not been parsed properly.
11051 "system_maintenance" System is under maintenance.
11052 "subscribe_error_unsubscribed" Subscription error. However, subscription may fail without this error, please check list of subscribed channels returned, as some channels can be not subscribed due to wrong input or lack of permissions.
11053 "transfer_not_found" Specified transfer is not found.
11090 "invalid_addr" Invalid address.
11091 "invalid_transfer_address" Invalid addres for the transfer.
11092 "address_already_exist" The address already exists.
11093 "max_addr_count_exceeded" Limit of allowed addresses has been reached.
11094 "internal_server_error" Some unhandled error on server. Please report to admin. The details of the request will help to locate the problem.
11095 "disabled_deposit_address_creation" Deposit address creation has been disabled by admin.
11096 "address_belongs_to_user" Withdrawal instead of transfer.
12000 "bad_tfa" Wrong TFA code
12001 "too_many_subaccounts" Limit of subbacounts is reached.
12002 "wrong_subaccount_name" The input is not allowed as name of subaccount.
12998 "tfa_over_limit" The number of failed TFA attempts is limited.
12003 "login_over_limit" The number of failed login attempts is limited.
12004 "registration_over_limit" The number of registration requests is limited.
12005 "country_is_banned" The country is banned (possibly via IP check).
12100 "transfer_not_allowed" Transfer is not allowed. Possible wrong direction or other mistake.
12999 "tfa_used" TFA code is correct but it is already used. Please, use next code.
13000 "invalid_login" Login name is invalid (not allowed or it contains wrong characters).
13001 "account_not_activated" Account must be activated.
13002 "account_blocked" Account is blocked by admin.
13003 "tfa_required" This action requires TFA authentication.
13004 "invalid_credentials" Invalid credentials has been used.
13005 "pwd_match_error" Password confirmation error.
13006 "security_error" Invalid Security Code.
13007 "user_not_found" User's security code has been changed or wrong.
13008 "request_failed" Request failed because of invalid input or internal failure.
13009 "unauthorized" Wrong or expired authorization token or bad signature. For example, please check scope of the token, "connection" scope can't be reused for other connections.
13010 "value_required" Invalid input, missing value.
13011 "value_too_short" Input is too short.
13012 "unavailable_in_subaccount" Subaccount restrictions.
13013 "invalid_phone_number" Unsupported or invalid phone number.
13014 "cannot_send_sms" SMS sending failed -- phone number is wrong.
13015 "invalid_sms_code" Invalid SMS code.
13016 "invalid_input" Invalid input.
13017 "subscription_failed" Subscription failed, invalid subscription parameters.
13018 "invalid_content_type" Invalid content type of the request.
13019 "orderbook_closed" Closed, expired order book.
13020 "not_found" Instrument is not found, invalid instrument name.
13021 "forbidden" Not enough permissions to execute the request, forbidden.
13025 "method_switched_off_by_admin" API method temporarily switched off by administrator.
13031 "verification_required" API method allowed only for verified users
13503 "unavailable" Method is currently not available.
13666 "request_cancelled_by_user" Request was cancelled by user with other api request.
13777 "replaced" Edit request was replaced by other one
-32602 "Invalid params" See JSON-RPC spec.
-32601 "Method not found" See JSON-RPC spec.
-32700 "Parse error" See JSON-RPC spec.
-32000 "Missing params" See JSON-RPC spec.

FIX API

Deribit FIX API is a subset of FIX version 4.4, but also includes some tags from 5.0 version and several custom tags. Deribit uses the standard header and trailer structure for all messages. To enable the API, sign in and go to Account > Security > API Tab and use the checkbox. 'Access Secret' is the user's secret key provided by Deribit. Important Note: Do not reveal to anybody your 'Access Secret', as it can be used to gain full control over your account.

The FIX server can be reached at www.deribit.com:9881 (raw tcp) or www.deribit.com:9883 (ssl). The FIX server for the test network can be reached at test.deribit.com:9881 (raw tcp) or test.deribit.com:9883 (ssl).

Each request message can include:

Tag Name Type Required Comments
8 BeginString String Yes Identifies beginning of new message and protocol version. Must always be first in the message.
9 BodyLength Length Yes Message length in bytes, not including fields 8, 9 and 10. See refer to FIX specification on how to compute this field. Must always be the first field in the message.
35 MsgType String Yes The type of the message. See below for available types
49 SenderCompID String Yes A user defined client name
56 TargetCompID String Yes Constant value: DERIBITSERVER
34 MsgSeqNum SeqNum Yes A sequence number for the message, starts with 1, and must be incremented by 1 for every message.
52 SendingTime UTCTimestamp No The time the request is sent. This field is ignored by the server
10 CheckSum String Yes The checksum of all of all preceding messages. See refer to FIX specification on how to compute this field. Must always be the last field in the message.

Responses sent by the server will at least include:

Tag Name Type Comments
8 BeginString String Identifies beginning of new message and protocol version. Must always be first in the message.
9 BodyLength Length Message length in bytes, not including fields 8, 9 and 10. See refer to FIX specification on how to verify this field. Must always be the first field in the message.
35 MsgType String The type of the message. See below for available types
49 SenderCompID String Constant value: DERIBITSERVER
56 TargetCompID String A user defined client name
34 MsgSeqNum SeqNum A server-chosen sequence number for the message.
52 SendingTime UTCTimestamp The time the request is sent. This field is ignored by the server
10 CheckSum String The checksum of all of all preceding messages. See refer to FIX specification on how to verify this field. Must always be the last field in the message.

Logon(A)

Logon(A) must the first message sent by the client to initiate a session. If authentication succeeds, the exchange should echo the message back to the client. If authentication fails, the exchange will respond with a LogOut(5) message with an appropriate reason.

Arguments

Tag Name Type Required Comments
108 HeartBtInt int Yes Used to declare the timeout interval in seconds for generating heartbeats.
95 RawDataLength Length No Number of bytes in raw data field. Not required, as the normal RawData is base64 text here
96 RawData data Yes The timestamp and a Base64 encoded nonce (see below)
553 Username String Yes API Access Key. This can be obtained from the API tab on your account settings.
554 Password String Yes See below
9002 UseWordsafeTags Boolean No If present and set to Y, all of the tag values for our custom tags start at 5000 instead of 100000. This can be used for FIX libraries that don't allow higher tag numbers. This will setting will apply for the remainder of the connection. For example, Volume24h(100087) would become 5078.
9001 CancelOnDisconnect Boolean No Boolean, to enable or disable session-level cancel on disconnect. Default - false(N).
9004 DeribitAppId String No Registered application Client ID. It is necessary for registered applications only.
9005 DeribitAppSig String No Registered application Signature. It is necessary for registered applications only. It is calculated in a similar way to the Password(554) but with Application Secret instead of Access Secret: base64(sha256(RawData ++ application_secret)), see below
9007 DeribitSequential Boolean No Custom tag to adapt Deribit internal messaging to sequential FIX messaging. If the tag is present and set to 'Y', the messages are sent with sequential ordering, i.e., there is no priority for direct "call responses" over notifications. Please note this may lead to slower call-return information delivery in comparison with other user which do not use this flag
9009 UnsubscribeExecutionReports Boolean No Custom tag. Default - false (N). If the tag is present and set to 'Y' this connection is unsubscribed from notificational Execution Reports about order changes. Only responses to order operation requests in this connection will be sent as Execution Reports, but no notifications such as orders from other connection or trades initiated by counterparty

The RawData(96) tag contains a timestamp and a nonce, separated by an ASCII period (.). The timestamp needs to be a strictly increasing integer. We recommend using a timestamp in milliseconds. The nonce is composed base64-encoded randomly chosen bytes. For safety reasons, it is important that the nonce is sufficiently long and sourced from a cryptographically secure random number generator. We recommend at least 32 bytes, but the nonce can be up to 512 bytes.

The Password(554) tag contains a base64 encoded SHA256 hash of the concatenation of the RawData(96) content and the access secret: base64(sha256(RawData ++ access_secret)), here ++ denotes operation of the concatenation.

Optional custom tag DeribitAppSig(9005) contains a base64 encoded SHA256 hash of the concatenation of the RawData(96) content and the Application secret: base64(sha256(RawData ++ application_secret)), here ++ denotes operation of the concatenation. This tag is used for registered applications only.

CancelOnDisconnect(9001) controls "Close on Disconnect". If this tag is not provided, the default setting from the account is used.

Response

When the login is successful, the server will echo back the request.

If the login was not successful, the server will respond with a Logout(5) message, and close the connection.

Logout(5)

Logout(5) can be sent by either party in order to terminate a session. The sending party should always wait for the echo of the logout request before they close the socket. Closing connections in any other way is considered abnormal behaviour. Nonetheless, if CancelOnDisconnect(9001) was set at Logon, all orders will be cancelled at Logout.

Arguments

Tag Name Type Required Comments
58 text String No Free format text string specifying the logout reason. This is ignored by the server
9003 DontCancelOnDisconnect Boolean No If Y then it disables CancelOnDisconnect for this connection even if CancelOnDisconnect was enabled in Logon or account settings. Default - false(N), no changes for CancelOnDisconnect flag.

Heartbeat(0)

When either end of a FIX connection has not sent or received any data for HeartBtInt seconds (as specified in the Logon(A) message), it will transmit a Heartbeat(0) message. When either end of a FIX connection has not received any data for HeartBtInt seconds, it will transmit a Test Request(1) message. If there is still no response, the session should be considered lost and corrective action should be initiated.

Arguments

Tag Name Type Required Comments
112 TestReqId String Varies The identifier when responding to Test Request(1) message. When not responding to a Test Request(1) message, this tag can be left out

Response

When the heartbeat has been received successfully, the server will echo back the request as confirmation.

Test Request(1)

The Test Request(1) message forces a heartbeat from the opposing application. The opposing application responds with a Heartbeat(0) containing the TestReqID(112).

Arguments

Tag Name Type Required Comments
112 TestReqId String Yes Mirrors the original request ID.

Resend Request(2)

The Resend Request(2) message is used by the server to initiate the retransmission of messages. This function is utilized if a sequence number gap is detected, if the receiving application lost a message, or as a function of the initialization process.

Arguments

Tag Name Type Required Comments
7 BeginSeqNo Yes The first message to repeat
16 EndSeqNo Yes The last message to repeat

Reject(3)

The Reject(3) message should be issued when a message is received but cannot be properly processed due to a session-level or data structure rule violation. An example of when a reject may be appropriate would be the receipt of a message with invalid basic data (e.g. missing tags) which successfully passes decryption.

Arguments

Tag Name Type Required Comments
45 RefSeqNum SeqNum Yes MsgSeqNum(34) of the rejected message
372 RefMsgType String No The MsgType(35) of the FIX message being referenced
373 SessionRejectReason int No Code to identity reason for rejection. See FIX specification for possible values.
58 Text String No Text string explaining the reason for rejection.

Security List Request(x)

The SecurityListRequest(x) message is used to return a list of securities (instruments) from the Deribit.

Arguments

Tag Name Type Required Comments
320 SecurityReqId String Yes A user-generated ID for this request. This can be used to match the request to the response.
559 SecurityListRequestType int Yes 0 or 4 – in any case list of instruments is returned

Response

The server will respond with a Security List(y) message, where the SecurityReq(320) is equal to that of the request.

Security List(y)

The SecurityList(y) message is used to return a list of securities that matches the criteria specified in a Security List Request(x).

Arguments

Tag Name Type Required Comments
320 SecurityReqId String Yes The SecurityReqId(320) of the request that this is a response for
322 SecurityResponseID String Yes Identifier for the Security List(x) message
560 SecurityRequestResult int Yes 0 indicates a successful response. This is the only possible value in the Deribit FIX API
146 NoRelatedSym int No Specifies the number of repeating instruments specified
=>55 Symbol String No Common, "human understood" representation of the security, e.g., BTC-28JUL17, see instrument naming convention
=>107 SecurityDesc String No Free form security description. At the time of writing, this is either 'future' or 'option'
=>167 SecurityType String No FUT or OPT
=>201 PutOrCall int No Used to express option right, 0 – put, 1 – call.
=>202 StrikePrice Price No Strike price
=>947 StrikeCurrency Currency No Strike Currency
=>15 Currency Currency No Currency of option
=>2576 InstrumentPricePrecision int No number of decimal places for instrument prices (usually 4 for options, 2 for futures)
=>969 MinPriceIncrement float No Minimum price tick for a given Instrument
=>311 UnderlyingSymbol String No Underlyig symbol for options.
=>225 IssueDate UTCTimestamp No Date instrument was issued.
=>541 MaturityDate UTCTimestamp No Expiration date, YYYYMMDD
=>1079 MaturityTime UTCTimestamp No Expiration time
=>562 MinTradeVol Qty No The minimum trading volume for a security
=>63 SettlType String No Indicates order settlement period. E.g., M1 – month, W1 – week, W2 – 2 weeks etc
=>120 SettlCurrency Currency No Currency code of settlement denomination.
=>479 CommCurrency Currency No Specifies currency to be use for Commission.
=>231 ContractMultiplier float No Specifies the ratio or multiply factor to convert from contracts to total units.

Market Data Request(V)

Market Data Request(V) can be used to request market data in snapshot or the incremental form. Deribit uses his message for order book requests and its change notification.

Arguments

Tag Name Type Required Comments
262 MdReqId String Yes Unique ID assigned to this request.
263 SubscriptionRequestType int Yes 0 = Snapshot, 1 = Snapshot + Subscribe, 2 = Unsubscribe
264 MarketDepth int No See remark about MDUpdateType below.
265 MDUpdateType int when SubscriptionRequestType=1 The type of update to subscribe to.
100007 DeribitTradeAmount int No Amount of trades returned in the snapshot response to request for snapshot of recent trades, default 20, maximum 1000
100008 DeribitSinceTimestamp int No UTC Timestamp in milliseconds (integer number of milliseconds), if specified, the response returns the trades happened since that timestamp, applicable to the request for recent trades snapshot
Group MDEntryTypes
267 NoMdEntryTypes int Yes Number of entry types in the request.
=>269 MDEntryType int Yes 0 = Bid (Bid side of the order book), 1 = Offer (Ask side of the order book), 2 = Trade (Info about recent trades)
Group Instruments
146 NoRelatedSym int No Number of symbols requested. Necessary if more than 1 Symbol requested
=>55 Symbol String Yes Instrument symbol.

When requesting a subscription (SubscriptionRequestType=1), the only supported combinations are:

If multiple instrument symbols are specified then the system responds with multiple market data messages corresponding to those instruments.

Response

If the server is unable to supply the requested data, it will respond with a Market Data Request Reject(Y) message.

If the request called for a snapshot (i.e. SubscriptionRequestType(263)=0 or SubscriptionRequestType(263)=1), the server will respond with a Market Data - Snapshot/Full Refresh(W) message.

If the request called for a snapshot (i.e. SubscriptionRequestType(263)=0 or SubscriptionRequestType(263)=1), the server will start sending with a Market Data - Incremental Refresh(X) messages.

Market Data Request Reject(Y)

If a Market Data Request(V) message is not accepted, the exchange responds with a Market Data Request Reject(Y) message

Arguments

Tag Name Type Required Comments
58 Text String No Free format text string
262 MDReqID String Yes ID of the original request
281 MDReqRejReason char Yes

Market Data Snapshot/Full Refresh(W)

Market Data Snapshot/Full Refresh(W) is used as the response to a Market Data Request(V) message.

Arguments

Tag Name Type Required Comments
55 Symbol String Yes Instrument symbol
262 MDReqID String No ID of the original request, if it is applicable
311 UnderlyingSymbol String For options Underlying symbol
810 UnderlyingPx Price For options Price of the underlying instrument
231 ContractMultiplier float No Specifies a multiply factor to convert from contracts to total units
201 PutOrCall int No Indicates whether an Option is for a put or call. Only for Options. 0 = Put, 1 = Call
100087 TradeVolume24h Qty No Defines 24h trade volume for the Symbol in the corresponding contract units
100090 MarkPrice Price No Defines mark price for the Symbol
746 OpenInterest float No Defines open interest for the Symbol
100092 CurrentFunding Price No Current funding (perpetual only)
100093 Funding8h Price No Funding 8h (perpetual only)
268 NoMDEntries int Yes Repeating group . Specifies the number of entries in the group.
=>279 MDUpdateAction Char No Type of Market Data update action. 0 = New, 1 = Change, 2 = Delete
=>269 MDEntryType int No 0 = Bid (Bid side of the order book), 1 = Offer (Ask side of the order book), 2 = Trade (in case of request for info about recent trades), 3 = Index Value (value of Index for INDEX instruments like BTC-DERIBIT-INDEX ), 6 = Settlement Price (Estimated Delivery Price for INDEX instruments like BTC-DERIBIT-INDEX )
=>270 MDEntryPx Price No Price of an entry
=>271 MDEntrySize Qty No Size of an entry in Contract units corresponding to the ContractMultiplier in SecurityList
=>272 MDEntryDate UTCTimestamp No The timestamp for trade
=>100009 DeribitTradeId int No Id of the trade, in case of the request for trades
=>54 Side int No Side of trade (1 = Buy, 2 = Sell)
=>44 IndexPrice Price No For trades, this is the index price at the trade moment (Deribit index).
=>58 Text String No The trade sequence number
=>37 OrderId String No For trade – taker's matching order id
=>198 SecondaryOrderId String No For trade – maker's matching order id
=>39 OrdStatus int No For trade – order status (0 = New, 1 = Partially filled, 2 = Filled, 4 = Cancelled)
=>100010 DeribitLabel String No User defined 64 character label of the order, in case of the request for trades
=>100091 DeribitLiquidation String No Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation
=>58 Text String No Text to describe the Market Data Entry. Part of repeating group. (Markprice based Volatility Index entry marked by Text = "markprice_based")

CurrentFunding and Funding8h are present only in W message, not in X message below.

Market Data Incremental Refresh(x)

Market Data – Incremental Refresh(X) message is used for incremental updates in case of Market Data Request(V) for Snapshot + Subscribe

Arguments

Tag Name Type Required Comments
55 Symbol String Yes Instrument symbol
262 MDReqID String No ID of the original request, if it is applicable
231 ContractMultiplier float No Specifies a multiply factor to convert from contracts to total units
201 PutOrCall int No Indicates whether an Option is for a put or call. Only for Options. 0 = Put, 1 = Call
100090 MarkPrice Price No Defines mark price for the Symbol
746 OpenInterest float No Defines open interest for the Symbol
268 NoMDEntries int Yes Repeating group . Specifies the number of entries in the group.
=>279 MDUpdateAction char No Type of Market Data update action. Valid values: 0 = New, 1 = Change, 2 = Delete
=>269 MDEntryType int No 0 = Bid (Bid side of the order book), 1 = Offer (Ask side of the order book), 2 = Trade (in case of request for info about recent trades)
=>270 MDEntryPx Price No Price of an entry
=>271 MDEntrySize Qty No Size of an entry in Contract units corresponding to the ContractMultiplier in SecurityList
=>272 MDEntryDate String UTCTimestamp The timestamp for trade
=>100009 DeribitTradeId int No Id of the trade, in case of the request for trades
=>54 Side int No Side of trade (1 = Buy, 2 = Sell)
=>37 OrderId String No For trade – order id
=>198 SecondaryOrderId String No For trade – matching order id
=>39 OrdStatus int No For trade – order status (0 = New, 1 = Partially filled, 2 = Filled, 4 = Cancelled)
=>100010 DeribitLabel String No User defined 64 character label of the order, in case of the request for trades
=>44 IndexPrice Price No For trades, this is the index price at the trade moment (Deribit index).
=>58 Text String No The trade sequence number
=>100091 DeribitLiquidation String No Optional field (only for trades caused by liquidation): "M" when maker side of trade was under liquidation, "T" when taker side was under liquidation, "MT" when both sides of trade were under liquidation

New Order Single(D)

The NEW ORDER SINGLE(D) is used by the client to submit new orders to the exchange. Note Deribit doesn't store client identifiers (for the sake of speed of execution), i.e., client software should manage matching client-server identifiers using.

Arguments

Tag Name Type Required Comments
11 ClOrdID String Yes Unique identifier for the order as assigned by the client
54 Side int Yes 1 = Buy, 2 = Sell
38 OrderQty Qty Yes Order quantity. Please, note that Quantity is defined in Contract units corresponding to the ContractMultiplier in SecurityList
44 Price Price Yes Price
55 Symbol String Yes Instrument symbol, e.g., BTC-1JAN16
18 ExecInst MultipleCharValue No Currently is used to place POST ONLY orders: 6 = "Participate don't initiate", and REDUCE ONLY orders: E = " Do not increase - DNI"
40 OrdType char No Order type. Valid values: 1 = Market, 2 = Limit. (default Limit)
59 TimeInForce char No Specifies how long the order remains in effect. Absence of this field is interpreted as "Good Till Cancel". Valid values: 1 = Good Till Cancel (GTC), 3 = Immediate or Cancel (IOC), 4 = Fill or Kill (FOK)
100010 DeribitLabel String no A custom label for your order, max 64 characters.
100012 DeribitAdvOrderType char no Used to create advanced order for options. If it is present: 0 = Implied Volatility Order (price defines fixed implied volatility in %) , 1 = USD Order (price defines fixed USD price of the option)
9008 DeribitMMProtection Boolean No Order MMP flag, default 'N'. Important: manual admin action is necessary to activate MMP for an account

Response

Upon receiving a new order, the exchange responds with the Execution Report(8) message communicating whether the order was accepted or rejected.

Tag Name Required Comments
527 SecondaryExecID No ID of the last order change
11 ClOrdID Yes Deribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41 OrigClOrdId Yes The original value assigned by the client in the New Order Single(D) message
39 OrdStatus Yes 0 = New, 1 = Partially filled, 2 = Filled, 8 = Rejected
54 Side Yes 1 = Buy, 2 = Sell
60 TransactTime Yes Time the transaction represented by this Execution Report occurred. Fix timestamp.
12 Comission No Commission in corresponding CommCurrency. It represents cumulative value for the order.
151 LeavesQty Yes Order quantity open for further execution (LeavesQty = OrderQty - CumQty) in Contract units corresponding to the ContractMultiplier in SecurityList
14 CumQty Yes Total executed quantity or 0.0 in Contract units corresponding to the ContractMultiplier in SecurityList
38 OrderQty Yes Order quantity in Contract units corresponding to the ContractMultiplier in SecurityList
40 OrdType Yes 1 = Market, 2 = Limit, 4 = Stop Limit, S = Stop Market
44 Price Yes Price
18 ExecInst No Currently is used to mark POST ONLY orders: 6 = "Participate don't initiate", and REDUCE ONLY orders: E = " Do not increase - DNI"
103 OrdRejReason Yes
58 Text No Free format text string, usually exceptions
207 SecurityExchange No "Deribit"
55 Symbol Yes Instrument symbol
854 QtyType No Type of quantity specified in a quantity. Currently only 1 - Contracts.
231 ContractMultiplier No Specifies a multiply factor to convert from contracts to total units
6 AvgPx No Average execution price or 0.0 if not executed yet or rejected
210 MaxShow No Maximum quantity (e.g. number of shares) within an order to be shown to other customers
9008 DeribitMMProtection No Order MMP flag. Important: manual admin action is necessary to activate MMP for an account
100012 DeribitAdvOrderType No if it is present then it denotes advanced order for options: 0 = Implied Volatility Order, 1 = USD Order
1188 Volatility No volatility for Implied Volatility Orders (options orders with fixed volatility)
839 PeggedPrice No value of fixed USD price for USD Orders (options orders with fixed USD price)
31 LastPx No Price of this last fill.
32 LastQty No Quantity bought/sold on this last fill.
1362 NoFills No Number of fill entries for the order
=>1363 FillExecID No Unique identifier of execution, concatenated via '#' symbol and trade sequence number, e.g., BTC-28SEP18#38.
=>1364 FillPx No Price of this partial fill
=>1365 FillQty No Quantity bought/sold on this partial fill
=>1443 FillLiquidityInd No Indicator to identify whether this fill was a result of a liquidity provider providing or liquidity taker taking the liquidity. '1' -- Added Liquidity, '2' -- Removed Liquidity

Order Cancel Request(F)

This message requests the cancellation of a particular order. If an order has been partially filled, only the remaining quantity can be cancelled. The request should be accepted only if an order can successfully be cancelled without executing further. The server generated identifiers should be used as OrigClOrdId, Deribit doesn't store client identifiers.

Arguments

Tag Name Required Comments
11 ClOrdID Yes Order identifier
41 OrigClOrdId Yes Order identifier assigned by Deribit

Response on failure

Order Cancel Reject(9) is issued by the exchange upon receipt of Order Cancel Request(F) message which cannot be executed.

Tag Name Required Comments
52 SendingTime Yes
11 ClOrdID Yes Order identifier
41 OrigClOrdId Yes Order identifier assigned by Deribit
39 OrdStatus No If it is applicable
58 Text No Text string explaining the reason for rejection

Response on success

The following Execution Report(8) is sent by the exchange upon successfully processing a cancel request.

Tag Name Required Comments
52 SendingTime Yes
11 ClOrdID Yes Deribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41 OrigClOrdId Yes The original value assigned by the client in the New Order Single(D) message
150 ExecType No 4 = Cancelled, 6 = Pending Cancel
39 OrdStatus Yes 0 = New, 1 = Partial, 4 = Cancelled, 6 = Pending Cancel, 8 = Rejected
58 Text Yes Text string describing the result

This brief Execution Report comes faster and just indicates that the order was canceled. Besides, this brief report, the server always sends last state of the canceled order as another Execution Report with Text="notification" and all details about the canceled order. MMP orders: if the MMP order was canceled by user request the DeribitMMProtection (9008) flag is removed from the notification Execution Report. Presence of the DeribitMMProtection (9008) flag in Execution Report with status "canceled" means that the order has been canceled by MMP protection.

Order Mass Cancel Request(q)

Order Mass Cancel Request(q) message will trigger cancellation of a group of orders.

Arguments

Tag Name Required Comments
11 ClOrdID Yes Unique ID of Order Mass Cancel Request (q) as assigned by the client.
530 MassCancelRequestType Yes Specifies the type of cancellation requested. Supported values: 7 (all orders), 5 (orders by security type), 1 (orders by symbol).
167 SecurityType If MassCancelRequestType=5 possible values 'FUT', 'OPT'. The security type for which to cancel orders.
55 Symbol If MassCancelRequestType=1 The symbols for which to cancel all orders
15 Currency No If to cancel only certain currency if applicable. See also [#security-list-y][Security List].

Response

After the cancellation, the server responds with a Order Mass Cancel Report(r).

Tag Name Type Required Comments
11 ClOrdID String Yes Deribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
530 MassCancelRequestType Yes Specifies the type of cancellation requested. Supported values: 1 (all orders), 5 (orders by security type), 7 (orders by symbol).
531 MassCancelResponse No If successful, echoes the MassCancelRequestType.
58 Text No 'success', if deletion was successful
532 MassCancelRejectReason No Reason why deletion failed. 1=Unknown security, 5=Unknown security type

Order Mass Status Request(AF)

Order Mass Status Request(AF) message requests the status of currently open orders. The exchange should respond with a series of Execution Report(8) messages detailing orders.

Arguments

Tag Name Required Comments
584 MassStatusReqID Yes Client-assigned unique ID of this request
585 MassStatusReqType Yes Specifies the scope of the mass status request. (see below)

This message can be used in two ways: to request status of all your open orders, or to request the status of a single order (which needn't be open).

To request the status of all orders, choose a random MassStatusRequestId, and set MassStatusReqType=7. The server will respond with a series of Execution Reports(8) messages, where the first message contains MassStatusReqType=7 and TotNumReports will be set to the number of reports to be expected as a follow-up.

To request the status of specific order, set MassStatusReqType=1, and set MassStatusReqId to the order ID

Response

When the client requests the status of current orders, the exchange should reply with a series of special Execution Reports(8), one for every order requested.

Tag Name Type Required Comments
11 ClOrdID String Yes Deribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41 OrigClOrdId String Yes The original value assigned by the client in the New Order Single(D) message
39 OrdStatus char Yes 0 = New, 1 = Partially filled, 2 = Filled, 8 = Rejected
54 Side char Yes 1 = Buy, 2 = Sell
60 TransactTime Yes Time the transaction represented by this Execution Report occurred. Fix timestamp.
12 Comission No Commission in corresponding CommCurrency. It represents cumulative value for the order.
151 LeavesQty Qty Yes Order quantity open for further execution (LeavesQty = OrderQty - CumQty) in Contract units corresponding to the ContractMultiplier in SecurityList
14 CumQty Qty Yes Total executed quantity or 0.0 in Contract units corresponding to the ContractMultiplier in SecurityList
38 OrderQty Qty Yes Order quantity in Contract units corresponding to the ContractMultiplier in SecurityList
40 OrdType char Yes 1 = Market, 2 = Limit, 4 = Stop Limit, S = Stop Market
44 Price Price Yes Price
18 ExecInst MultipleCharValue No Currently is used to mark POST ONLY orders: 6 = "Participate don't initiate", and REDUCE ONLY orders: E = " Do not increase - DNI"
103 OrdRejReason int Yes Code to identify reason for order rejection.
58 Text String No Free format text string, usually exceptions
207 SecurityExchange String No "Deribit"
55 Symbol String Yes Instrument symbol
854 QtyType String No Type of quantity specified in a quantity. Currently only 1 - Contracts.
231 ContractMultiplier float No Specifies a multiply factor to convert from contracts to total units
6 AvgPx float No Average execution price or 0.0 if not executed yet or rejected
210 MaxShow Qty No Maximum quantity (e.g. number of shares) within an order to be shown to other customers in Contract units corresponding to the ContractMultiplier in SecurityList
9008 DeribitMMProtection Boolean No Order MMP flag. Important: manual admin action is necessary to activate MMP for an account
100012 DeribitAdvOrderType char No if it is present then it denotes advanced order for options: 0 = Implied Volatility Order, 1 = USD Order
1188 Volatility float No volatility for Implied Volatility Orders (options orders with fixed volatility)
839 PeggedPrice Price No value of fixed USD price for USD Orders (options orders with fixed USD price)
31 LastPx No Price of this last fill.
32 LastQty No Quantity bought/sold on this last fill.
1362 NoFills NumInGroup No Number of fill entries for the order
=>1363 FillExecID String No Unique identifier of execution, concatenated via '#' symbol and trade sequence number, e.g., BTC-28SEP18#38.
=>1364 FillPx Price No Price of this partial fill
=>1365 FillQty Qty No Quantity bought/sold on this partial fill
=>1443 FillLiquidityInd int No Indicator to identify whether this fill was a result of a liquidity provider providing or liquidity taker taking the liquidity. '1' -- Added Liquidity, '2' -- Removed Liquidity

When responding to a MassStatusReqType=7 request, the server precedes the Execution Reports(8) messages with a special Execution Reports(8) message:

Tag Name Type Required Comments
584 MassStatusReqID String Yes The MassStatusReqID from the request. (Only for the first message response to a MassStatusReqType=7 request.)
585 MassStatusReqType int Yes The MassStatusReqType from the request. (Only for the first message response to a MassStatusReqType=7 request.)
911 TotNumReports int Yes The total number of reports following this initial report

Request For Positions(AN)

Request For Positions(AN) is used by the owner of a position to request a Position Report.

Arguments

Tag Name Type Required Comments
710 PosReqID String Yes Unique identifier for the Request for Positions(AN) as assigned by the submitter.
724 PosReqType int Yes 0 = Positions (currently)
263 SubscriptionRequestType int No 0=Receive snapshot, 1=subscribe, 2=unsubscribe
15 Currency currency No To request for certain currency only. If it is missing -- all currencies are reported

Response

The server will respond with a Position Report(AP) message.

Position Report(AP)

The Position Report(AP) message is returned by the holder of a position in response to a Request for Position(AN) message.

Arguments

Tag Name Required Comments
721 PosMaintRptID Yes Unique identifier for this position report
710 PosReqID No Unique identifier for the Request for Positions associated with this report.
724 PosReqType No 0 = Positions (currently)
728 PosReqResult No 0 = success, 1 = unsupported request for positions
702 NoPositions No Number of position entries following
=>703 PosType No Type of quantity. Values: "TQ" - Transaction Quantity.
=>704 LongQty No Qty for long position (0 for short position) in Contract units corresponding to the ContractMultiplier in SecurityList
=>705 ShortQty No Qty for short position (0 for long position) in Contract units corresponding to the ContractMultiplier in SecurityList
=>55 Symbol No Instrument symbol
=>854 QtyType No Type of quantity specified in a quantity. Currently only 1 - Contracts.
=>231 ContractMultiplier No Specifies a multiply factor to convert from contracts to total units
=>883 UnderlyingEndPrice No Mark price (reference price)
=>54 Side No 1 = Buy, 2 = Sell
=>730 SettlPrice No Average price
=>96 RawData No Additional info, semi-colon separated: maintenance margin;initial margin;floating P/L
=>100088 DeribitLiquidationPrice No Estimated liquidation price
=>100089 DeribitSizeInCurrency No Size in the underlying currency, for example BTC or ETH

User Request(BE)

This message is used to request a report on a user's status and user account info.

Arguments

Tag Name Required Comments
923 UserRequestID Yes The request ID
924 UserRequestType Yes Should be equal to 4 (Request individual user status), only UserRequestType=4 supported for now
553 Username Yes API authenticated 'Access Key', user can request only own info, should be the same as for previous LOGON(A)
15 Currency No Currency of the report. See also [#security-list-y][Security List]. Default is BTC.

Response

The server will respond with a User Response(BF) message.

User Response(BF)

This message is used to respond to a USER REQUEST(BE) message, it reports the status of the user and user's account info.

Response

Tag Name Required Comments
923 UserRequestID Yes The request ID
553 Username Yes User's API 'Access Key'
926 UserStatus No 1 = logged in, current implementation accepts USER REQUEST-s only from logged in users
15 Currency No Currency of the report. See also [#security-list-y][Security List]. Default is BTC.
100001 DeribitUserEquity No Equity of the user
100002 DeribitUserBalance No Balance of the user
100003 DeribitUserInitialMargin No Initial margin of the user
100004 DeribitUserMaintenanceMargin No Maintenance margin of the user
100005 DeribitUnrealizedPl No Unrealized P/L of the user
100006 DeribitRealizedPl No Realized P/L of the user
100011 DeribitTotalPl No Total P/L of the user
100013 DeribitMarginBalance No Margin Balance

Order Cancel/Replace Request(G)

To change/edit the parameters of an existing order

Arguments

Tag Name Type Required Comments
41 OrigClOrdID String Yes
11 ClOrdId String Yes
54 Side char Yes original side, 1=buy, 2=sell
38 OrderQty Qty order quantity. Please, note that Quantity is defined in Contract units. See ContractMultiplier in SecurityList
40 OrdType char Yes currently 2 - 'limit'
44 Price Price order price (for advanced options orders it could be volatility or USD value if applicable)
55 Symbol String Yes instrument name is required from performance reasons.
18 ExecInst MultipleCharValue No Currently is used for POST ONLY orders: 6 = "Participate don't initiate", and REDUCE ONLY orders: E = " Do not increase - DNI"
9008 DeribitMMProtection Boolean No Order MMP flag, if it is absent then current MMP flag of the order is not changed. N removes the flag if it is set. Important: manual admin action is necessary to activate MMP for an account

Response

see New Order Single response

Execution Reports(8) about order changes

Notification

The report Execution Reports(8) is similar to New Order Single or Cancel/Replace responses

Tag Name Required Comments
527 SecondaryExecID No ID of the order change, may be absent in case of status reports
11 ClOrdID Yes Deribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41 OrigClOrdId Yes The original value assigned by the client in the New Order Single(D) message
39 OrdStatus Yes 0 = New, 1 = Partially filled, 2 = Filled, 8 = Rejected
54 Side Yes 1 = Buy, 2 = Sell
60 TransactTime Yes Time the transaction represented by this Execution Report occurred. Fix timestamp.
12 Comission No Commission in corresponding CommCurrency. It represents cumulative value for the order.
151 LeavesQty Yes Order quantity open for further execution (LeavesQty = OrderQty - CumQty) in Contract units corresponding to the ContractMultiplier in SecurityList
14 CumQty Yes Total executed quantity or 0.0 in Contract units corresponding to the ContractMultiplier in SecurityList
38 OrderQty Yes Order quantity in Contract units corresponding to the ContractMultiplier in SecurityList
5127 ConditionTriggerMethod No Trigger for a stop order 1 = Mark Price, 2 = Last Price, 3 = corresponding Index Price
40 OrdType Yes 1 = Market, 2 = Limit, 4 = Stop Limit, S = Stop Market
44 Price No Price, maybe be absent for Market and Stop Market orders
18 ExecInst No Currently is used to mark POST ONLY orders: 6 = "Participate don't initiate", and REDUCE ONLY orders: E = " Do not increase - DNI"
99 StopPx No Stop price for stop limit orders
103 OrdRejReason Yes
58 Text No Free format text string, usually exceptions
207 SecurityExchange No "Deribit"
55 Symbol Yes Instrument symbol
854 QtyType No Type of quantity specified in a quantity. Currently only 1 - Contracts.
231 ContractMultiplier No Specifies a multiply factor to convert from contracts to total units
6 AvgPx No Average execution price or 0.0 if not executed yet or rejected
210 MaxShow No Maximum quantity (e.g. number of shares) within an order to be shown to other customers
100012 DeribitAdvOrderType No if it is present then it denotes advanced order for options: 0 = Implied Volatility Order, 1 = USD Order
1188 Volatility No volatility for Implied Volatility Orders (options orders with fixed volatility)
839 PeggedPrice No value of fixed USD price for USD Orders (options orders with fixed USD price)
31 LastPx No Price of this last fill.
32 LastQty No Quantity bought/sold on this last fill.
9008 DeribitMMProtection No Order MMP flag.
1362 NoFills No Number of fill entries for the order
=>1363 FillExecID No Unique identifier of execution, concatenated via '#' symbol and trade sequence number, e.g., BTC-28SEP18#38.
=>1364 FillPx No Price of this partial fill
=>1365 FillQty No Quantity bought/sold on this partial fill
=>1443 FillLiquidityInd No Indicator to identify whether this fill was a result of a liquidity provider providing or liquidity taker taking the liquidity. '1' -- Added Liquidity, '2' -- Removed Liquidity

Security Status Request(e)

This message provides for the ability to request the status of a security.

Arguments

Tag Name Required Comments
324 SecurityStatusReqID Yes ID of the request
55 Symbol Yes Instrument symbol
263 SubscriptionRequestType Yes 0 = Snapshot - currently only snapshot is supported

Response

The server will respond with a Security Status (f) message.

Security Status (f)

The Security Status (f) message provides for the ability to report changes in status to a security.

Response

Tag Name Required Comments
324 SecurityStatusReqID No
55 Symbol Yes Instrument symbol
326 SecurityTradingStatus No Identifies the trading status, currently only: 7 = Ready to trade, 8 = Not Available for trading, 20 = Unknown or Invalid
330 BuyVolume No Volume in contracts, absent if there weren't any trades
331 SellVolume No Volume in contracts, absent if there weren't any trades
332 HighPx No Price of the 24h highest trade, absent if there weren't any trades
333 LowPx No Price of the 24h lowest trade, absent if there weren't any trades
31 LastPx No The price of the latest trade, absent if there weren't any trades

MMProtection Limits (MM)

Important: manual admin action is necessary to activate MMP for an account. The MMProtection Limits (MM) message can be used to set or get the limits for market maker protection -- MMP.

Arguments

Tag Name Required Comments
20114 ProtectionRequestID Yes Unique identifier assigned by the requestor. Will be returned in responses.
15 Currency Yes BTC, ETH
20110 Protection Qty Limit C Specify the limit of the total traded contracts per underlying within the exposure time interval when market maker protection is triggered. When this value is met or exceeded the system automatically removes the quotes for the instruments connected to the underlying.
20111 Protection Delta Limit C The limit of the delta value per underlying within the exposure time interval when market maker protection is triggered. When this value is met or exceeded the system automatically removes the quotes for the instruments connected to the underlying
20112 Frozen Limit C Time interval in seconds when quotes are rejected after market maker protection has been triggered
20116 Interval Length C Interval Length in seconds

MMProtection Limits Result/Reject (MR)

Important: manual admin action is necessary to activate MMP for an account. This message is sent by the server in reply to MMProtection Limits (MM) or MMProtection Reset (MZ)

Response

Tag Name Required Comments
20114 ProtectionRequestID Yes Identifier taken from corresponding MM or MZ message.
20117 ProtectionRequestResult Yes 'Y' -- applied or succeeded, 'N' -- rejected
58 Text No Text describes reject reason or equal to "success"

MMProtection Reset (MZ)

Important: manual admin action is necessary to activate MMP for an account. This message resets MMP after triggering.

Arguments

Tag Name Required Comments
20114 ProtectionRequestID Yes Unique identifier assigned by the requestor. Will be returned in responses.
15 Currency Yes BTC, ETH

Response

The server sends MMProtection Result (MR) message as a response.

Changes Log

Release 1.3.07

Release 1.3.06

Release 1.3.05

Release 1.3.04

Release 1.3.03

Release 1.3.02

Release 1.3.01

Release 1.3.00