API

1. Introduction

Deribit API is divided in public and private parts (also FIX is available). Users are required to apply for API authentication to be able to use the private API. Please go to Account > API tab > Access tab, enable REST & WebSocket API access, save and use your Access Key and Access Secret for further authorization of API request as described below. Example of API can be accessed via API Console (the API Console tab, next after Access tab). Important Note: Do not reveal to anybody your ’Access Secret’, it is as important as your password. 

With the API Console (Account > API tab > API Console tab), you can use and test the REST API and WEBSOCKETS API.

Our Github page: https://github.com/deribit
Recent changes (UTF8): api-release-changes.txt

The result of REST/WebSocket request and WebSocket notification are marked with a field "testnet" (true/false) to distinguish production webserver (www.deribit.com, real BTC) and test/sandbox web server (test.deribit.com, testnet Dericoins) as to the api response/event.

COD (Cancel on Disconnect): If you want to have all your orders cancelled after any downtime of our system (restarts, crashes, new deploys) API traders can activate "COD"(cancel on disconnect) by checking a checkbox on the API page in the Account menu. If checked, all orders in your account will be cancelled during any downtime of our system, and, if using websockets, if a websocket channel closes for whatever reason, all orders will be cancelled too (for during a crash of trader system).

2. Naming

Deribit tradeable assets or instruments use following system of naming:

KindExamplesTemplateComments
FutureBTC-25MAR16, BTC-5AUG16
BTC-DMMMYY
Template DMMMYY – is expiration date, D stands for day, MMM – month (3 first letters in English), YY stands for year
Option
BTC-25MAR16-420-C, BTC-5AUG16-580-P
BTC-DMMMYY-STRIKE-K
Template STRIKE is option strike-price in USD. Template K is option kind: C for CALL options or P for PUT options.
Option/FutureBTC-THISWEEK, BTC-NEXTWEEK, BTC-THISWEEK-580-C, BTC-NEXTWEEK-590-P (date aliases THISWEEK, NEXTWEEK
Expiration date aliases: THISWEEK, NEXTWEEK
Expiration date instead of the explicit DMMMYY date. Note that subscribe API will not resubscribe after expiration of the expired instrument subscribed via aliases, i.e., the aliases are interpreted at the moment of the api call.

3. Timing

Successfull call of API returns JSON object with msIn and msOut fields:
msIn – server input time in milliseconds (when server has received the API call)
msOut – server output time in milliseconds
Notification messages have msOut only.

3b. Rate Limits

Standard rate limit is 200 requests per second, with bursts to 300 requests per second if having built up request credits (having done less than 200 requests per second in previous seconds). 

4. REST API

REST API consists of a public part and private part.
Private API requests must be signed. The signature is placed in the custom header ’x-deribit-sig’. The ’x-deribit-sig’ header is constructed as follows:

  • Use millisecond UTC timestamp to generate Nonce = ms timestamp UTC
  • Combine the Nonce, Access Key, Access Secret, URI Path (the path part of URI of the specific request, see below) and all request parameters (paramX – name of the X-th parameter, valueX – value of the X-th parameter) in a single string using token ’&’ as follows:
    the string is ’_=Nonce&_ackey=Access Key&_acsec=Access Secret&_action=URIPath&param1=value1&param2=value2….&paramN=valueN’, if API request has no parameters the string is just ’_=Nonce&_ackey=Access Key&_acsec=Access Secret&_action=URI Path’
    if the X-th value (corresponding to the valueX) is of array type, for instance [’a’, ’b’, ’c’], the entries should be concatenated in a single string, i.e., the resulting valueX = ’abc’
    the parameters (param1, param2, …) must be sorted alphabetically according to the parameters’ name
    do not reveal the string to anybody as it contains your Access Secret.
  • Create sha256 hash from the obtained string
  • The resulting sha256-hash is then encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line
  • Join the AccessKey, Nonce and obtained Base64(Hash) in a single string using ’.’ token, i.e., the result is ’x-deribit-sig’ header equal to AccessKey.Nonce.Base64(Hash)
Javascript code example:

tstamp = 1452237485895;
data = '_=1452237485895&_ackey=API-KEY'+
'&_acsec=API-SECRET'+
'&_action=/api/v1/private/buy'+
'&instrument=BTC-15JAN16&price=500&quantity=1';
signature = 'API-KEY.1452237485895.UQdq3sUA+76YY5ufdzUosVcOti+5ymoODm8eaNCNUCw=';

jQuery.ajax({
type: method,
url: uri,
data: params,
headers: [{'x-deribit-sig': signature}],
success: function (data) {
...
},
dataType: ’json’
});
API Console
A working sample of java script code is available online via Deribit API console (go to Account > API tab > API Console tab).

Note for Python coders
Python coders should not use hashlib.sha256(data).hexdigest() as it hex-encodes the digest, hashlib.sha256(data).digest() must be used instead. The example:
def deribit_signature(nonce, uri, params, access_key, access_secret)
sign = '_=%s&_ackey=%s&_acsec=%s&_action=%s' % (nonce, access_key, access_secret, uri)
for key in sorted(params.keys()):
sign += '&' + key + '=' + "".join(params[key])
print sign
return '%s.%s.%s' % (access_key, nonce, base64.b64encode(hashlib.sha256(sign).digest()))

5. Public API

5.1 Test

Test request returns api build number.
URI: https://www.deribit.com/api/v1/public/test
URI Path: /api/v1/public/test
Parameters: none
Method: GET
Result is JSON object:
{
"success": true, // false or true
"testnet": false, // false for production server, true for test server
"message": "public API test", // empty or text message
"apiBuild": "1.2.17" // api build version, refer api-release-changes.txt above
}

5.2 Getinstruments

Get the open and available trading instruments.
URI: https://www.deribit.com/api/v1/public/getinstruments
URI Path: /api/v1/public/getinstruments
Parameters: expired=true for returning all expired instruments. Else all currently traded instruments will be returned.
Method: GET
Result is JSON object:
{"success": true,  // false or true
"message": "", // empty or text message
"result": [{
"kind": "option", // future or option
"baseCurrency": "BTC", // currently BTC only
"currency": "USD", // currently USD only
"minTradeSize": 0.01, // minimum size
"instrumentName": "BTC-30JAN15-450-P", // instrument name
"isActive": true, // true or false
"settlement": "month",
"created": "2014-12-09 11:34:24 GMT", // GMT date time
"expiration": "2015-01-30 15:00:00 GMT" // GMT date time
"pricePrecision": 4 // specifies the number of decimal places for instrument prices,
// usually 4 decimal places for options, 2 -- for futures
}, ...]}

5.3 Index

Get price index, BTC-USD rates.
URI: https://www.deribit.com/api/v1/public/index
URI Path: /api/v1/public/index
Parameters: none
Method: GET
Result is JSON object:
{
"success": true, // false or true
"message": "", // empty or text message
"result": {
"btc": 780.59 // float, BTC-USD exchange rates
}
}

5.4 Getcurrencies

Get all supported currencies.
URI: https://www.deribit.com/api/v1/public/getcurrencies
URI Path: /api/v1/public/getcurrencies
Parameters: none
Method: GET
Result is JSON object:
{"success": true, // true or false
"message": "", // empty or text message
"result": [{
"currency": "BTC", // currently BTC only
"currencyLong": "Bitcoin", // currently Bitcoin
"minConfirmation": 2, // minimum confirmation for deposit
"txFee": 0.0001, // transaction fee in BTC
"isActive": true, // true or false
"coinType": "BITCOIN", // currently BITCOIN only
"baseAddress": null
}]}

5.5 Getorderbook

Retrieve the orderbook for a given instrument.
URI: https://www.deribit.com/api/v1/public/getorderbook
URI Path: /api/v1/public/getorderbook
Parameters: instrument – string [optional], instrument name, example “BTC-19DEC14”, see getinstruments
Method: GET
Result is JSON object:
{
"success": true, // true or false
"message": "", // empty or text message
"result": {
"bids": [ // buy orders
{
"quantity": 2, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": 416.02, // float USD for futures, BTC for options
"cm": 2 // cumulative quantity, with better orders, "quantity" is less or equal to the "cm"
}
],
"asks": [
{
"quantity": 1,
"price": 420.02,
"cm": 1
},
{
"quantity": 2,
"price": 421.02,
"cum": 3
}
],
"last": 418.75, // last, BTC
"low": 414.75, // 24H low
"high": 420.75, // 24H high
"slip": 0 // reserved, system purpose, usually 0
}
}

5.6 Getlasttrades

Retrieve the latest trades that have occured for a specific instrument.
URI: https://www.deribit.com/api/v1/public/getlasttrades
URI Path: /api/v1/public/getlasttrades
Parameters:
        instrument – string [optional], instrument name, example “BTC-19DEC14” .
        since – integer [optional], “since” trade id, the server returns trades newer than that “since”.
        count – integer [optional], count of trades returned (limitation: max. count is 100000, default 100)
trade id.
Method: GET
Result is JSON object:
{
"success": true, // true or false
"message": "", // empty or text message
"result": [ // list of trades
{
"tradeId": 1, // trade id
"instrument": "BTC-22JAN16", // name of the instrument
"timeStamp": 1418148659276, // timestamp in milliseconds, e.g., javascript Date object — new Date(1418148659276)
"quantity": 2, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": 418.02, // float, USD for futures, BTC for options
"direction": "sell", // "buy", "sell" (direction of taker's order)
"indexPrice": 420.04,
"tickDirection": 0, // Direction of the "tick".
// Valid values: 0 = Plus Tick; 1 = Zero-Plus Tick;
// 2 = Minus Tick; 3 = Zero-Minus Tick
}
]
}

5.7 Getsummary

Retrieve the summary info such as Open Interest, 24H Volume etc for a specific instrument.
URI: https://www.deribit.com/api/v1/public/getsummary
URI Path: /api/v1/public/getsummary
Parameters: instrument – string [optional], instrument name, example “BTC-19DEC14”.
Method: GET
Result is JSON object:
	{
"success": true, // true or false
"message": "",
"result": { // summary
"instrumentName": "BTC-19DEC14",
"openInterest": 2.009614922,
"high": 418.02,
"low": 418.02,
"volume": 4,
"last": 418.02,
"bidPrice": 416.02, // float, USD for futures, BTC for options
"askPrice": 420.02, // float, USD for futures, BTC for options
"midPrice": 418.02, // float, USD for futures, BTC for options
"created": "2015-10-15 12:47:10 GMT" // GMT date time
}
}

5.8 Stats

Get some statistics.
URI: https://www.deribit.com/api/v1/public/stats
URI Path: /api/v1/public/stats
Parameters: none
Method: GET
Result is JSON object:
{
"success": true,
"testnet": false,
"message": "",
"result": {
"btc_usd": // BTC - USD stats
{
"futuresVolume": 324.0, // in BTC, futures 24h volume
"putsVolume": 100.24, // in BTC, options-puts 24h volume
"callsVolume": 130.23 // in BTC, options-calls 24h volume
},
"created": "2017-06-16 12:10:57 GMT"
},
"msIn": 1497615057294,
"msOut": 1497615057294
}

5.9 Getannouncements

Get announcements from last 30 days.
URI: https://www.deribit.com/api/v1/public/getannouncements
URI Path: /api/v1/public/getannouncements
Parameters: none
Method: GET
Result is JSON object:
{
"success": true, // true or false
"message": "", // empty
"result": [ // list of objects:
{
"date": 1499940765000, // timestamp, announcement publication date
"title": "New Announcement", // string, announcement title
"body": "Announcement string" // announcement body, html
}
]
}

6. Private API

6.1 Account

Get user account summary (authorization is required).
URI: https://www.deribit.com/api/v1/private/account
URI Path: /api/v1/private/account
Parameters:
ext – optional parameter, if ext=true then the return has email, nick and tfa=true/false fields
Method: GET
Result is JSON object:
{
"success": true, // true or false
"result": {
"equity": 1108,48703769 // float, in BTC
"maintenanceMargin": 9.58764239, // float, in BTC
"initialMargin": 52.71196337, // float, in BTC
"availableFunds": 1055.77507431, // float, in BTC
"balance": 1103.15356175, // float, in BTC
"depositAddress": "mgMPN6owFMGPrwJ4LPZw9mp5kCqcD22hfP" // BTC deposit address
"SUPL": 0.01813573, // float, in BTC, Session Unrealized Profit and Loss
"SRPL": 0, // float, in BTC, Session Realized Profit and Loss
"PNL": 1.26766995, // float, in BTC, Profit and Loss
"optionsPNL": 1.26766995, // float, in BTC, options PnL,
"optionsSUPL": 0.01813573, // float, in BTC, options Session Unrealized PnL,
"optionsSRPL": 0, // float, in BTC, options Session Realized PnL,
"optionsD": 8.1467, // options summary delta
"optionsG": -0.0007, // options summary gamma
"optionsV": -50.332, // options summary vega
"optionsTh": 6.6506, // options summary theta
"futuresPNL": 0, // futures PnL
"futuresSUPL": 0, // futures Session Unrealized PnL
"futuresSRPL": 0 //futures Session Realized PnL
// if ext=true
"nick": "User1", // user nickname
"email": "user1111@yahoo.com", // email
"tfa": false // status of 2FA/TFA, true if on otherwise false
}
}

6.2 Buy

Place a buy order in an instrument (authorization is required).
URI: https://www.deribit.com/api/v1/private/buy
URI Path: /api/v1/private/buy
Parameters: shown as JQuery data for POST
{
"instrument": "BTC-19DEC14-C", // name
"quantity": 1, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"type": "limit", // "limit", "market" or for futures only: "stop_limit"
"stopPx": "1000" // needed for stop_limit order, defines stop price
"post_only": true, // optional parameter, if true then order will be post only
"price": "0.02", // float, without "adv" parameter - USD for futures, BTC for options,
// for advanced orders: if "adv"="usd" USD, if "adv"="implv" - implied volatility in %
"label": "1" // optional parameter, user defined maximum 32-char label for the order
"max_show": "0" // optional parameter, if "0" then the order will be hidden
// defines visible amount of the order in the order book
"post_only": true, // optional parameter, if true then the order will be POST ONLY
// (adjusted to always enter the order book as a maker order without
// immediate matching with lower fee or rebate, see the docs for more details)
"adv": "usd" // optional parameter, can be "implv", "usd", or absent (advanced order type)
}
- In case of “adv”=”implv”, field “price” must be a value of Implied Volatility (in percentages), e.g., “price”=100, means implied volatility of 100%
- In case of “adv”=”usd”, field “price” must be the option price value in USD
- It is not allowed to combine “adv”=”implv”,”usd” parameter with “post_only”=true
- “adv” parameter is not applicable to futures, ignored


Method: POST
Result is JSON object:
{
"success": true, // true or false
"result": {
"order": {
"orderId": 889, // id of created order if success = true
"instrument": "BTC-22JAN16", // instrument name of the order
"direction": "buy", // direction, buy
"price": 417, // price, float, USD for futures, BTC for options
"quantity": 1, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"label": "", // user defined label (up to 32 characters)
"filledQuantity": 0, // filled quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"avgPrice": 0, // average fill price of the order
"commission": 0, // commission in btc
"created": 1453398857489, // creation timestamp
"lastUpdate": 1453398857489, // timestamp of the last order state update "state": "open" // order state
"postOnly": false // true for post-only orders only
"adv": false, // advanced type (false, or "usd" or "implv")
// for advanced orders could be:
"implv": 250 // implied volatility in %, if "adv"="implv"
"usd": 50 // usd price, if "adv"="usd"
},
"trades": [] // the list of immediate trades if them have happened
},
"message": "" // empty or text message, e.g. error message
}

6.3 Sell

Place a buy order in an instrument (authorization is required).
URI: https://www.deribit.com/api/v1/private/sell
URI Path: /api/v1/private/sell
Parameters: shown as JQuery data for POST
{
"instrument": "BTC-29JAN16-450-C", // name
"quantity": "1", // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": "0.2" // float, USD for futures, BTC for options
"label": "1" // optional parameter, user defined label for the order
// (up to 32 characters)
"post_only": true, // optional parameter, if true then the order will be POST ONLY
// (adjusted to always enter the order book as a maker order without
// immediate matching with lower fee or rebate)
"max_show": "0" // optional parameter, if 0 then the order will be hidden
// defines visible amount of the order in the order book
"adv": "usd" // optional parameter, can be "implv", "usd", or absent (advanced order type)
}
- In case of "adv"="implv", field "price" must be a value of Implied Volatility (in percentages), e.g., "price"=100, means implied volatility of 100%
- In case of "adv"="usd", field “price” must be the option price value in USD
- It is not allowed to combine "adv"="implv","usd" parameter with “post_only”=true
- "adv" parameter is not applicable to futures, ignored

Method: POST
Result is JSON object:
{
"success": true,
"result": {
"order": {
"orderId": 894, // id of created order if success = true
"instrument": "BTC-29JAN16-450-C", //instrument name of the order
"direction": "sell", // direction, sell
"price": 0.2, // price, float, USD for futures, BTC for options
"quantity": 10, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"label": "", // user defined label (up to 32 characters)
"filledQuantity": 1, //filled quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"avgPrice": 0, // average fill price of the order
"commission": 0, // commision in btc
"created": 1453399515235, // creation timestamp
"lastUpdate": 1453399515235, // timestamp of the last order state update
"state": "open",
"postOnly": false, // true for post-only orders only
"adv": false // advanced type (false, or "usd" or "implv")
// for advanced orders could be:
"implv": 250 // implied volatility in %, if "adv"="implv"
"usd": 50 // usd price, if "adv"="usd"
},
"trades": [ // list of immediate trades, if they have happened
{
"quantity": 1, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": 415 // price, float, USD for futures, BTC for options
}
]
},
"message": ""
}

6.4 Edit

Edit price and/or quantity of the own order. (Authorization is required).
URI: https://www.deribit.com/api/v1/private/edit
URI Path: /api/v1/private/edit
Paramerts: shown as JQuery data for POST
{
"orderId": "994", // ID of the order returned by "sell" or "buy" request
"quantity": "1", // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": "415" // float, USD for futures, BTC for options
"post_only": true, // optional field, if it is present the POST-ONLY property is set correspondingly
// -- explicitly, otherwise it stays unchanged
"adv": "usd" // optional parameter, can be "implv", "usd", or absent (advanced order type)
}
- In case of "adv"="implv", field "price" must be a value of Implied Volatility (in percentages), e.g., “price”=100, means implied volatility of 100%
- In case of "adv"="usd", field "price" must be the option price value in USD
- It is not allowed to combine "adv"="implv","usd” parameter with "post_only"=true
- "adv" parameter is not applicable to futures, ignored
- API edit limitation – it is not allowed to change "adv" from "implv" to "usd" and vice versa via "edit" (as well as from empty "adv" to "implv" or "usd" and vice versa) – if necessary to do that, just cancel it and add the new order.

Method: POST
Result is JSON object:
{
"success": true,
"result": {
"order": {
"orderId": 894, // id of created order if success = true
"instrument": "BTC-29JAN16-450-C", //instrument name of the order
"direction": "sell", // direction, sell
"price": 0.2, // price, float, USD for futures, BTC for options
"quantity": 10, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"label": "", // user defined label (up to 32 characters)
"filledQuantity": 1, //filled quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"avgPrice": 0, // average fill price of the order
"commission": 0, // commision in btc
"created": 1453399515235, // creation timestamp
"lastUpdate": 1453399515235, // timestamp of the last order state update
"state": "open",
"postOnly": false, // true for post-only orders only
"adv": false // advanced type (false, or "usd" or "implv")

// for advanced orders could be:
"implv": 250 // implied volatility in %, if "adv"="implv"
"usd": 50 // usd price, if "adv"="usd"
},
"trades": [ // list of immediate trades, if they have happened
{
"quantity": 1, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": 415 // price, float, USD for futures, BTC for options
}
]
},
"message": ""
}

6.5 Cancel

Cancell own order by id (authorization is required).
URI: https://www.deribit.com/api/v1/private/cancel
URI Path: /api/v1/private/cancel
Parameters: shown as JQuery data for POST
{
"orderId": "5"
}
Method: POST
Result is JSON object:
{
"success": true, // true or false
"message": "", // empty or text message, e.g. error message
"order": { // state of the order
"orderId": 5258039, // order Id
"instrument": "BTC-26MAY17", // name of the instrument
"direction": "sell", // order direction "buy" or "sell"
"price": 1860, // requested price
"label": "", // label set by the owner, up to 32 chars
"quantity": 10, // requested quantity
"filledQuantity": 3, // filled quantity
"avgPrice": 1860, // average fill price of the order
"commission": -0.000001613, // in BTC units
"created": 1494491899308, // creation timestamp
"lastUpdate": 1494491988754, // timestamp of the last order state changev // (before this cancelorder)
"state": "cancelled", // order state
"postOnly": false // true for post-only orders only
},
"result": null
}

6.6 Cancelall

Cancell all own futures, or all options, or all own orders (authorization is required).
URI: https://www.deribit.com/api/v1/private/cancelall
URI Path: /api/v1/private/cancelall
Parameters: shown as JQuery data for POST
{
"type": "all" // "all", "futures", "options"
}
Method: POST
Result is JSON object:
{
"success": true, // true or false
"message": "cancel all", // text message, e.g. error message
}

6.7 Getopenorders

Retrieve open orders (authorization is required).
URI: https://www.deribit.com/api/v1/private/getopenorders
URI Path: /api/v1/private/getopenorders
Parameters: instrument – string [optional], instrument name, example "BTC-29DEC17".
Parameters: shown as JQuery data for POST
{
"success": true, // true or false
"message": "", // empty or text message, e.g. error message
"result": [ // list of open orders
{
"orderId": 5258039, // ID of the order
"instrument": "BTC-26MAY17", // instrument name
"direction": "sell", // order direction, "buy" or "sell"
"price": 1860, // float, USD for futures, BTC for options
"label": "", // label set by the owner, up to 32 chars
"quantity": 10, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"filledQuantity": 3, // filled quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"avgPrice": 1860, // average fill price of the order
"commission": -0.000001613, // in BTC units
"created": 1494491899308, // creation timestamp
"lastUpdate": 1494491988754, // timestamp of the last order state change
// (before this cancelorder of course)
"state": "open", // open, cancelled, etc
"postOnly": false // true for post-only orders only
}
]
}

6.8 Positions

Retrieve positions (authorization is required).
URI: https://www.deribit.com/api/v1/private/positions
URI Path: /api/v1/private/positions
Parameters: none
Method: GET
Result is JSON object:
{
"success": true, // true or false
"result": [ //list of position objects
{ //example future position
"instrument": "BTC-22JAN16", // name of the instrument
"size": 1, // position size, in contracts ($10 per contract for futures, ฿1 — for options)
"averagePrice": 384.289999987, // average price for the position in BTC
"direction": "buy",
"sizeBtc": 0.025844001, // position size in BTC for futures
"floatingPl": 0.000178014,
"realizedPl": -0.00060691,
"markPrice": 386.937, // mark price
"indexPrice": 379.35, // index price
"maintenanceMargin": 0.00245518, // maintenance margin in BTC
"initialMargin": 0.00439348, // initial margin in BTC
"openOrderMargin": 0.184398603
},
{ //example option position
"instrument": "BTC-22JAN16-360-C",
"size": -0.2,
"averagePrice": 0.2, // average price for the position in BTC
"averageUsdPrice": 78.62, // average price in USD for options
"direction": "sell",
"quantity": -1,
"floatingPl": 0.144582976,
"floatingUsdPl": 57.597551946,
"realizedPl": 0,
"markPrice": 0.05541702431231484,
"indexPrice": 379.35,
"maintenanceMargin": 0.1,
"initialMargin": 0.2,
"openOrderMargin": 0
}, .....
]
}

6.9 Orderhistory

Get history. (Authorization is required).
URI: https://www.deribit.com/api/v1/private/orderhistory
URI Path: /api/v1/private/orderhistory
Parameters:
"offset" — optional, integer, offset (for pagination), from which the "count" is counting
"instrument" — optional, filtering parameter can be "future""option" or valid instrument name
Method: GET
Result is JSON object:
{
"success": true,
"result": [ // list of orders from history, filled quantity > 0
{
"orderId": 5258039, // ID of the order
"instrument": "BTC-26MAY17", // name of the instrument
"direction": "sell", // direction of the order, "buy" or "sell"
"price": 1860, // float, USD for futures, BTC for options
"quantity": 10, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"filledQuantity": 3, // filled quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"avgPrice": 1860, // average fill price of the order
"state": "cancelled", // state of the order "open", "cancelled", "filled"
"created": 1494491899308, // creation timestamp
"tstamp": 1494492913288, // timestamp of the last order state change
"commission": -0.000001613, // in ฿
"modified": 1494492913289, // timestamp of the last db write operation,
// e.g. trade that doesn't change order status
"postOnly": false, // true for post-only orders only
"label" : "", // order label, if present,
"adv": false // advanced type (false, or "usd" or "implv")
} ....
]
}

6.10 Orderstate

Get order state by order id. (Authorization is required)
URI: https://www.deribit.com/api/v1/private/orderstate
URI Path: /api/v1/private/orderstate
Parameters:
"orderId": 362878 // order identifier

Method: GET
Result is JSON object:
{
"success": true, // true or false
"result": {
"orderId": 54435915, // order identifier
"instrument": "BTC-30JUN17-2000-C", // instrument
"direction": "buy", // "buy" or "sell"
"price": 0.0581, // price of the order
"quantity": 5,
"filledQuantity": 0,
"avgPrice": 0, // average price
"commission": 0, // commission in BTC
"created": 1495184819641, // creation timestamp
"lastUpdate": 1495186129205, // last change timestamp
"state": "open", // order state
"postOnly": false, // true or false
"adv": false // advanced type (false, or "usd" or "implv")
// for advanced orders could be:
"implv": 250 // implied volatility in %, if "adv"="implv"
"usd": 50 // usd price, if "adv"="usd"
},
"msIn": 1495186147445,
"msOut": 1495186147445
}

6.11 Tradehistory

Get private trade history of the account (authorization is required). The result is ordered by trade identifiers (trade id-s).
URI: https://www.deribit.com/api/v1/private/tradehistory
URI Path: /api/v1/private/tradehistory
Parameters:
instrument – string [mandatory], name of instrumentm, example “BTC-19DEC14”, also aliases “all”, “futures”, “options” are allowed.
count – integer[optional], number of results to fetch, example 50, default 20
startTradeId – integer[optional], startTradeId is used for pagination of requests, example – 3328. With this paraneter, it is possible to fetch all trades page by page. The request will return “count” trades with trade id-s less than “startTradeId”.
Method: GET
Result is JSON object:
{
"success": true,
"result": [ // list of account trades
{
"tradeId": 28436, // trade id
"instrument": "BTC-31MAR17",// instrument name
"timeStamp": 1487876771886, // Unix timestamp
"quantity": 4, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": 1133.93, // float, USD for futures, BTC for options
"side": "sell", // side of the account order (it describes what the account does, "sell" or "buy")
"orderId": 5349283, // account order id (the user order)
"liquidity": "T", // "T" - taker, "M" - maker
"fee": 0, // fee (comission for the trade, as for the account, if negative - rebate)
"feeCurrency": "BTC", // fee-comission currency
"tickDirection": 3, // Direction of the "tick". Valid values:
// 0 = Plus Tick; 1 = Zero-Plus Tick; 2 = Minus Tick; 3 = Zero-Minus Tick
"matchingId": 5349289, // matching order ID
"indexPrice": 1164.29 // index price
},
....
]
}

6.12 Newannouncements

Get new announcements for the logged user. After request, those announcements are marked as read.
URI: https://www.deribit.com/api/v1/private/newannouncements
URI Path: /api/v1/private/newannouncements
Result as JSON object:
{
"success": true, // true or false
"message": "", // empty
"result": [ //list of objects:
{
"date": 1499945664000, // timestamp, announcement publication date
"title": "New Announcement", // string, announcement title
"body": "<2>Announcement" // string, announcement body, html
}
]
}

7. WebSockets API

WebSocket API include all REST API and in addition subscriptions for notifications.
WebSocket address is wss://www.deribit.com/ws/api/v1/
and test WebSocket server address is wss://test.deribit.com/ws/api/v1/

The same as the REST API, the WebSocket API is available for testing via Deribit API Console (go to Account > API tab > API Console tab).
Deribit provides heartbeat verification process. Client sends:  {"action": "/api/v1/public/ping"}, the server returns heartbeats {"result":"pong"} to indicate connection between the clients and the server. If the client stops receiving the heartbeats, then it needs to reconnect with the server. We advise to ping to our server at least every 30 seconds.

Each WebSocket request has the following structure (private WS API request uses ’sig’ property as a replacement of ’x-deribit-sig’ header for the REST API):
{
"id": 201, // id, developer identifies the response by the request id (the response has the same id with the corresponding
request)
"action": URI Path, // request URI Path
"arguments": {key: value}, // same arguments as for the REST API
"sig": signature // request signature if it is necessary (private API), same as for the REST API
}
WebSocket response is a WebSocket message, example of handling:
// ws is the JavaScript WebSocket object
ws.onmessage = function (e) {
if (e.data.length > 0) {
// get JSON object of the API response
var obj = JSON.parse(e.data);
// use obj
...
}
};
List of WebSocket API corresponding to the REST API and they URI:

getinstruments – action, URI Path /api/v1/public/getinstruments
getcurrencies – action, URI Path /api/v1/public/getcurrencies
getorderbook – action, URI Path /api/v1/public/getorderbook
getlasttrades – action, URI Path /api/v1/public/getlasttrades
getsummary – action, URI Path /api/v1/public/getsummary
account – action, URI Path /api/v1/private/account
buy – action, URI Path /api/v1/private/buy
sell – action, URI Path /api/v1/private/sell
edit – action, URI Path /api/v1/private/edit
cancel – action, URI Path /api/v1/private/cancel
cancelall – action, URI Path /api/v1/private/cancelall
getopenorders – action, URI Path /api/v1/private/getopenorders
positions- action, URI Path /api/v1/private/positions
orderhistory – action, URI Path /api/v1/private/orderhistory

7.1 Subscribe

WebSocket API to subscribe to notifications.
action, URI Path: /api/v1/private/subscribe
Parameters:
{
"id": 5533, // id, developer identifies the response by the sent id
"action": "/api/v1/private/subscribe",
"arguments": {
"instrument": ["BTC-19DEC14"], // instrument filter if applicable, i.e., list of instrument names,
// see getinstruments REST API
// also filters ["all"], ["futures"], ["options"] are allowed
// ["all"] = no filter, all instruments, except "index"
// ["futures"] = notification for futures
// ["options"] = notification for options
// ["index"] = DRB price index notification
"event": ["order_book", "trade", "user_order"] // events to be reported, possible events:
// "order_book" -- order book change
// "trade" -- trade notification
// "announcements" -- announcements (list of new announcements titles is send)
// "user_order" -- change of user orders (openning, cancelling, filling)
// "my_trade" -- filtered trade notification, only trades of the
// subscribed user are reported with trade direction "buy"/"sell" from the
// subscribed user point of view ("I sell ...", "I buy ..."), see below.
// Note, for "index" - events are ignored and can be [],
},
"sig": "...." // required !
}
Response message is JSON object:
{
"id": 5533, // equal to the request id
"success": true, // true or false
"message": "subscribed", // subscribed or not
"result": null
}
WebSocket notification message:
{
"notifications": [
// list of notifications (notification objects)
.....
]
}

7.2 Notification Objects

Following notification objects are possible:

trade_event
with list of the trades. JSON object:
{
"success": true, // false of true
"message": "trade_event", // event type
"result": [ // list of trades (for trade event)
{
"tradeId": 3, // trade id
"timeStamp": 1418152290669, // Unix timestamp
"instrument": "BTC-22JAN16", // name of instrument
"quantity": 61, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": 415, // float, USD for futures, BTC for options
"state": "closed", // order state
"direction": "buy", // direction of the taker's order
"orderId": 10, // order id (the taker's order)
"matchingId": 6, // id of matching order (the maker's order)
"makerComm": 0.0001,
"takerComm": 0.0005,
"indexPrice": 420.69, // index price
"label":"", // user defined label for the order from side
// of the subscribed user (up to 4 chars)
"me": "t", // "t" - if the subscriber is taker, "m" - the subscriber is maker, "" - empty string
// if the trade is between other users (trade without subsriber's participation)
// can be used to quickly detect subscriber's trades between other user trades
"tickDirection": 0 // Direction of the "tick".
// Valid values: 0 = Plus Tick;
//1 = Zero-Plus Tick; 2 = Minus Tick; 3 = Zero-Minus Tick
}
]
}
my_trade_event
with list of the filtered trades – only subscriber’s trades are reported. JSON object:
{
"success": true, // false of true
"message": "my_trade_event", // event type
"result": [ // list of trades (for trade event)
{
"tradeId": 3, // trade id
"timeStamp": 1418152290669, // Unix timestamp
"instrument": "BTC-22JAN16", // name of instrument
"quantity": 61, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": 415, // float, USD for futures, BTC for options
"state": "closed", // order state
"direction": "buy", // direction of the subscriber's order (it describes what the subscriber does - sells or buys)
"orderId": 10, // order id (the taker's order)
"matchingId": 6, // id of matching order (the maker's order)
"liquidity": "T", // T for taker, M for maker
"indexPrice": 420.69, // index price
"label":"", // user defined label for the order from side
// of the subscribed user (up to 4 chars)
"tickDirection": 0, // Direction of the "tick".
// Valid values: 0 = Plus Tick;
//1 = Zero-Plus Tick; 2 = Minus Tick;
// 3 = Zero-Minus Tick
]
}
order_book_event
It notifies about a change of order book for certain instrument. JSON object:
{
"success": true,
"message": "order_book_event",
"result": {
"instrument": "BTC-9OCT15",
"bids": [
{
"quantity": 10, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"price": 418.19, // float, USD for futures, BTC for options
"cm": 10 // cumulative quantity, in contracts ($10 per contract for futures, ฿1 — for options)
}
...// next best bids
],
"asks": [
{
"quantity": 10,
"price": 422.21,
"cm": 20
}
...// next best asks
],
"last": 418.19,
"low": 415.18,
"high": 420.26
}
}
user_order_event
It notifies about a change of user’s orders. This event is triggered for all changes of the user orders, it doesn’t depend on “instrument” parameter at subscription. JSON object:
{   "success": true,
"message": "user_orders_event",
"result": [
{ "id": 1031, // order identifier (for compatibility with older api version)
"orderId": 1031, // order identifier
"instrument": "BTC-22JAN16", // instrument name
"direction": "sell", // direction of the order "buy" or "sell"
"price": 426, // price, units depend on the asset type
"quantity": 10, // quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"filledQuantity": 0, // filled quantity, in contracts ($10 per contract for futures, ฿1 — for options)
"state": "open", // order state "open", "cancelled", "filled"
"avgPrice": 0, // average price
"label": "", // order label if present
"created": 1453454229858, // creation Unix timestamp
"modified": 1453454229858 // Unix timestamp of the last change
}
]
}
announcements
It notifies with titles of new announcements. JSON object:
{
"notifications": [
{
"success": true,
"testnet": false,
"message": "announcements",
"result": [ // list of new announcements titles
"Welcome to Deribit!"
]
}
]
}
default event for "index"
It notifies about price index value.  JSON object:
{
"success": true,
"message": "index",
"result": {
"btc": 1134.73, // current index price
"edp": 1135.75 // estimated delivery price,
// the estimation of the price used for settlement
// and delivery of contracts, calculated as the time
// weighted average of the Deribit index
// over the last half hour before expiration. It is equal
// to current price index most of time except last 30 min
// before expiration.
}
}

7.3 Unsubscribe

Unsubscribe from all notifications without closing the websocket connection. Currently there is no selectors.
action, URI Path: /api/v1/private/unsubscribe
Paramerts: none
	{
"id": 1798, // id, developer identifies the response by the sent id
"action": "/api/v1/private/unsubscribe",
"sig": "...." // required
}
Response message is JSON object:
{
"id": 1798, // equal to the request id
"success": true,
"message": "unsubscribed",
"result": null
}

8. FIX API


Deribit FIX API is a subset of FIX version 4.4. 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. Write down your ’Access Key’ and ’Access Secret. ’Access Secret’ is the user’s secret key provided by Deribit. Important Note: Do not reveal to anybody your ’Access Secret’, it is important as your password.

FIX SERVER ADDRESS
Socket host = www.deribit.com, socket port = 9880
Socket host = test.deribit.com, socket port = 9881

Message Header
Each request message includes:
TagNameRequiredComments
49SenderCompIDYesSenderCompID user defined client name
 56TargetCompIDYesTargetCompID constant value: DERIBITSERVER

8.1 Logon (A)

LOGON(A) is 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 should send a LOGOUT(5) message with an appropriate reason.

Request Parameters
TagNameRequiredComments
108HeartBtIntYesUsed to declare the timeout interval in seconds for generating heartbeats(same value used by both sides).
96RawDataYesNonce, which is base64 encoded data of 32 random bytes, example “3pM14pgJOYBATBDaCmE+0YvdPExppg5bJXAZtxakwDQ=”
553UsernameYesAPI authenticated ’Access Key’
554PasswordYesbase64 encoded data of SHA256 hash of concatenation the Nonce and ’Access Secret’ string, SHA256(Nonce ++ AccessSecret)

8.2 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 behavior.

Request Parameters
TagNameRequiredComments
58textNoFree format text string specifying the logout reason.

8.3 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 Message (1). If there is still no response, the session should be considered lost and corrective action should be initiated.
Request Parameters
TagNameRequiredComments
112TestReqIdNoRequired when the heartbeat is the result of a TestRequest (1) message

8.4 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 original TestReqID.
Request Parameters
TagNameRequiredComments
112TestReqIdYesMirrors the original request ID.

8.5 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.
Request Parameters
TagNameRequiredComments
7BeginSeqNoYes
16EndSeqNoYes

8.6 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.
Request Parameters
TagNameRequiredComments
45RefSeqNumYesMsgSeqNum of the rejected message
372RefMsgTypeNoThe MsgType<35> of the FIX message being referenced
373SessionRejectReasonNoCode to identity reason for rejection.
58TextNoText string explaining the reason for rejection

8.7 Security List Request (x)

The SecurityListRequest (x) message is used to return a list of securities (instruments) from the Deribit.
Request Parameters
TagNameRequiredComments
320SecurityReqIdYes
559SecurityListRequestTypeYes0 or 4 – in any case list of instruments is returned

8.8 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).
Request Parameters
TagNameRequiredComments
320SecurityReqIdYes
322SecurityResponseIDYesIdentifier for the Security List (x) message
146NoRelatedSymNSpecifies the number of repeating instruments specified
=>55SymbolNCommon, “human understood” representation of the security, e.g., BTC-28JUL17, see instrument naming convention
=>107SecurityDescNFree form security description.
=>167SecurityTypeN‘FUT’ or ‘OPT’
=>201PutOrCallNUsed to express option right, 0 – call, 1 – put.
=>202StrikePriceNStrike price
=>947StrikeCurrencyNStrike Currency
=>15CurrencyNCurrency of option
=>2576InstrumentPricePrecisionNnumber of decimal places for instrument prices (ususally 4 for options, 2 for futures)
=>225IssueDateNDate instrument was issued.
=>541MaturityDateNExpiration date, YYYYMMDD
=>1079MaturityTimeNExpiration time
=>562MinTradeVolNThe minimum trading volume for a security
=>63SettlTypeNIndicates order settlement period. E.g., “M1” – month, “W1” – week, “W2” – 2 weeks etc
=>120SettlCurrencyNCurrency code of settlement denomination.
=>479CommCurrencyNSpecifies currency to be use for Commission.

8.9 Market Data Request (v)

Market Data Request (V) is used by the trading platform to request market data in the snapshot or the incremental form. Deribit uses his message for order book requests and its change notification.
Request Parameters
TagNameRequiredComments
55SymbolYesInstrument symbol
262MdReqIdYesUnique ID assigned to this request.
263SubscriptionRequestTypeYes0 = Snapshot, 1 = Snapshot + Subscribe, 2 = Unsubscribe
264MarketDepthNoDefault 20
100007DeribitTradeAmountNoAmount of trades returned in the snapshot response to request for snapshot of recent trades, default – 20, maximum – 100000
100008DeribitSinceTimestampNoUTC Timestamp in milliseconds (integer number of milliseconds), if specified, the response returns the trades happened since that DeribitSinceTimestamp, applicable to the request for recent trades snapshot
Group MDEntryTypes
267NoMdEntryTypesNoNumber of entry types in the request.
=>269MDEntryTypeYes0 = Bid (Bid side of the order book), 1 = Offer (Ask side of the order book), 2 = Trade (Info about recent trades)

8.10 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
Request Parameters
TagNameRequiredComments
58TextNoFree format text string
262MDReqIDYesID of the original request
281MDReqRejReasonYes

8.11 Market Data Snapshot/Full Refresh (w)

Market Data Snapshot/Full Refresh (W) is used as the response to a Market Data Request (V) message.
Request Parameters
TagNameRequiredComments
55SymbolYesInstrument symbol
262MDReqIDNoID of the original request, if it is applicable
268< NoMDEntries >YesRepeating group . Specifies the number of entries in the group.
=>270MDEntryPxNoPrice of an entry
=>271MDEntrySizeNoSize of an entry
=>269MDEntryTypeNo0 = 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)
=>272MDEntryDateNoUTCTimestamp string (up to ms), e.g., timestamp for trade
=>100009DeribitTradeIdNoId of the trade, in case of the request for trades
=>54SideNoSide of trade (1 = Buy, 2 = Sell)
=>37OrderIdNoFor trade – order id
=>198SecondaryOrderIdNoFor trade – matching order id
=>39OrdStatusNoFor trade – order status (0 = New, 1 = Partially filled, 2 = Filled, 4 = Canceled)
=>100010DeribitLabelNoUser defined 4-char label of the order, in case of the request for trades

8.11 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
Request Parameters
TagNameRequiredComments
55SymbolYesInstrument symbol
262MDReqIDNoID of the original “subscribe” request
268NoMDEntriesYesNumber of entries following
=>279MDUpdateActionYes0 = New, 1 = Change, 2 = Delete
=>269MDEntryTypeNo0 = 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)
=>270MDEntryPxNoPrice of an entry (For trade that is the price of the trade, i.e., the order was executed at this price. Must not be confused with Index Price TAG 44 see below)
=>271MDEntrySizeNoSize of an entry
=>272MDEntryDateNoUTCTimestamp string (up to ms), e.g., timestamp for trade
=>100009DeribitTradeIdNoId of the trade, in case of the request for trades
=>54SideNoSide of trade (1 = Buy, 2 = Sell)
=>37OrderIdNoFor trade – order id
=>198SecondaryOrderIdNoFor trade – matching order id
=>39OrdStatusNoFor trade – order status (0 = New, 1 = Partially filled, 2 = Filled, 4 = Canceled)
=>100010DeribitLabelNoUser defined 4-char label of the order, in case of the request for trades
=>44Index PriceNoFor trades, this is the index price at the trade moment (Deribit index).

8.12 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.
Request Parameters
TagNameRequiredComments
11ClOrdIDYesUnique identifier for the order as assigned by the client
54SideYes1 = Buy, 2 = Sell
38OrderQtyYesOrder quantity
44PriceYesPrice
55SymbolYesInstrument symbol, e.g., “BTC-1JAN16”

8.13 Execution Report (8)

Upon receiving a new order, the exchange responds with the Execution Report (8) message communicating whether the order was accepted or rejected.
Request Parameters
TagNameRequiredComments
11ClOrdIDYesDeribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41OrigClOrdIdYesThe original value assigned by the client in the New Order Single (D) message
39OrdStatusYes0 = New, 8 = Rejected
54SideYes1 = Buy, 2 = Sell
60TransactTimeYesTime the transaction represented by this Execution Report occurred. Fix timestamp.
151LeavesQtyYesOrder quantity open for further execution (LeavesQty = OrderQty – CumQty )
14CumQtyYesTotal executed quantity or 0.0
38OrderQtyYesOrder quantity
40OrdTypeYes2 = Limit, Limit orders only
44PriceYesPrice
103OrdRejReasonYes
58TextNoFree format text string, usually exceptions
207SecurityExchangeNo“Deribit”
55SymbolYesInstrument symbol
6AvgPxNoAverage execution price or 0.0 if not executed yet or rejected

8.13 Order Cancel Request (F)

ORDER CANCEL REQUEST (F) 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-s, Deribit doesn’t store client identifiers.
Request Parameters
TagNameRequiredComments
11ClOrdIDYesOrder identifier
41OrigClOrdIdYesOrder identifier assigned by Deribit

8.14 Order Cancel Request (9)

ORDER CANCEL REJECT (9) is issued by the exchange upon receipt of Order Cancel Request (F) message which cannot be executed.
Request Parameters
TagNameRequiredComments
52SendingTimeYes
11ClOrdIDYesOrder identifier
41OrigClOrdIdYesOrder identifier assigned by Deribit
39OrdStatusNoIf it is applicable
58TextNoText string explaining the reason for rejection

8.15 Execution Report (8)

The following Execution Report (8) is sent by the exchange upon successfully processing a cancel request.
Request Parameters
TagNameRequiredComments
52SendingTimeYes
11ClOrdIDYesDeribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41OrigClOrdIdYesThe original value assigned by the client in the New Order Single (D) message
39OrdStatusYes0 = New, 1 = Partial, 4 = Canceled, 8 = Rejected
58TextYesText string describing the result

8.16 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.
Request Parameters
TagNameRequiredComments
584MassStatusReqIDYesClient-assigned unique ID of this request or OrderId if MassStatusReqType = 1
585MassStatusReqTypeYesSpecifies the scope of the mass status request. 1 = status of a specified order(Tag584 is OrderId), 7 = Status for all orders

Execution Report (8)
When the client requests the status of current orders, the exchange should reply with a series of special Execution Reports (8), one for every active order.
Request parameters
TagNameRequiredComments
11ClOrdIDYesDeribit replaces this field with the own value assigned by the server (it is not the client id from New Order Single)
41OrigClOrdIdYesFor Order Mass Status Request(AF), OrigClOrdId is equal to the ClOrdID, i.e., order identifier assigned by Deribit
39OrdStatusYes0 = New, 1 = Partial, 2 = Filled, 3 = Done, 4 = Canceled, 8 = Rejected
54SideYes1 = Buy, 2 = Sell
60TransactTimeYesTime the transaction represented by this Execution Report occurred. Fix timestamp.
38OrderQtyYesOrder quantity
40OrdTypeYes2 = Limit, Limit orders only
44PriceYesPrice
103OrdRejReasonYes
58TextNoFree format text string, usually exceptions
207SecurityExchangeNo“Deribit”
55SymbolYesInstrument symbol
6AvgPxNoAverage execution price, filled.

8.17 Request For Positions (AN)

Request For Positions (AN) is used by the owner of a position to request a Position Report.
Request Parameters
TagNameRequiredComments
710PosReqIDYesUnique identifier for the Request for Positions (AN) as assigned by the submitter.
724PosReqTypeYes0 = Positions (currently)

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.

Request Parameters
TagNameRequiredComments
721PosMaintRptIDYesUnique identifier for this position report
710PosReqIDNoUnique identifier for the Request for Positions associated with this report.
724PosReqTypeNo0 = Positions (currently)
728PosReqResultNo0 = success, 1 = unsupported request for positions
702NoPositionsNo\strikeout off\uuline off\uwave offNumber of position entries following
=>704LongQtyNoQty for long position (0 for short position)
=>705ShortQtyNoQty for short position (0 for long position)
=>55SymbolNoInstrument symbol
=>883UnderlyingEndPriceNoMark price (reference price)
=>54SideNo1 = Buy, 2 = Sell
=>730SettlPriceNoAverage price
=>96RawDataNoAdditional info, semi-colon separated: maintenance margin;initial margin;floating P/L

8.18 User Request (BE)

USER REQUEST used to request a report on a user’s status and user account info.
Request Parameters
TagNameRequiredComments
923UserRequestIDYesThe request ID
924UserRequestTypeYesShoulr be equal to 4 (Request individual user status), only UserRequestType=4 supported for now
553UsernameYesAPI authenticated ’Access Key’, user can request only own info, should be the same as for previous LOGON(A)

8.19 User Response (BF)

USER RESPONSE(BF) is used to respond to a USER REQUEST (BE) message, it reports the status of the user and user’s account info.
Request Parameters
TagNameRequiredComments
923UserRequestIDYesThe request ID
553UsernameYesUser’s API ’Access Key’
926UserStatusN1 = logged in, current implementation accepts USER REQUEST-s only from logged in users
100001DeribitUserEquityNEquity of the user
100002DeribitUserBalanceNBalance of the user
100003DeribitUserInitialMarginNInitial margin of the user
100004DeribitUserMaintenanceMarginNMaintenance margin of the user
100005DeribitUnrealizedPlNUnrealized P/L of the user
100006DeribitRealizedPlNRealized P/L of the user