1.0.2 • Published 6 years ago

deribit-api v1.0.2

Weekly downloads
17
License
MIT
Repository
github
Last release
6 years ago

API Client for Deribit API

Description

The Deribit API is available in this package.

Installation

npm install deribit-api

Example

var RestClient = require("deribit-api").RestClient;

var restClient = new RestClient();

restClient.getcurrencies().then((result) => {
  console.log("Currencies: ", result);
});

restClient.index((result) => {
  console.log("Index: ", result)
});

API - REST Client

new RestClient(key, secret, url)

Constructor creates new REST client.

Parameters

NameTypeDecription
keystringOptional, Access Key needed to access Private functions
secretstringOptional, Access Secret needed to access Private functions
urlstringOptional, server URL, default: https://www.deribit.com

Methods

  • getorderbook(instrument, callback) - Doc, public

    Retrieve the orderbook for a given instrument.

    Parameters

    NameTypeDecription
    instrumentstringRequired, instrument name
    callbackfunctionOptional, callback, if not provided method returns promise
  • index(callback) - Doc, public

    Get price index, BTC-USD rates.

    Parameters

    NameTypeDecription
    callbackfunctionOptional, callback, if not provided method returns promise
  • getcurrencies(callback) - Doc, public

    Get all supported currencies.

    Parameters

    NameTypeDecription
    callbackfunctionOptional, callback, if not provided method returns promise
  • getorderbook(instrument, callback) - Doc, public

    Retrieve the orderbook for a given instrument.

    Parameters

    NameTypeDecription
    instrumentstringRequired, instrument name
    callbackfunctionOptional, callback, if not provided method returns promise
  • getlasttrades(instrument, count, since, callback) - Doc, public

    Retrieve the latest trades that have occured for a specific instrument.

    Parameters

    NameTypeDecription
    instrumentstringRequired, instrument name
    countintegerOptional, count of trades returned (limitation: max. count is 100)
    sinceintegerOptional, “since” trade id, the server returns trades newer than that “since”
    callbackfunctionOptional, callback, if not provided method returns promise
  • getsummary(instrument, callback) - Doc, public

    Retrieve the summary info such as Open Interest, 24H Volume etc for a specific instrument.

    Parameters

    NameTypeDecription
    instrumentstringRequired, instrument name
    callbackfunctionOptional, callback, if not provided method returns promise
  • account(callback) - Doc, Private

    Get user account summary.

    Parameters

    NameTypeDecription
    callbackfunctionOptional, callback, if not provided method returns promise
  • buy(instrument, quantity, price, postOnly, label, callback) - Doc, private

    Place a buy order in an instrument.

    Parameters

    NameTypeDecription
    instrumentstringRequired, instrument name
    quantityintegerRequired, quantity, in contracts ($10 per contract for futures, ฿1 — for options)
    pricefloatRequired, USD for futures, BTC for options
    postOnlybooleanOptional, if true then the order will be POST ONLY
    labelstringOptional, user defined maximum 4-char label for the order
    callbackfunctionOptional, callback, if not provided method returns promise
  • sell(instrument, quantity, price, postOnly, label, callback) - Doc, private

    Place a sell order in an instrument.

    Parameters

    NameTypeDecription
    instrumentstringRequired, instrument name
    quantityintegerRequired, quantity, in contracts ($10 per contract for futures, ฿1 — for options)
    pricefloatRequired, USD for futures, BTC for options
    postOnlybooleanOptional, if true then the order will be POST ONLY
    labelstringOptional, user defined maximum 4-char label for the order
    callbackfunctionOptional, callback, if not provided method returns promise
  • edit(orderId, quantity, price, callback) - Doc

    Edit price and/or quantity of the own order. (Authorization is required).

    Parameters

    NameTypeDecription
    orderIdintegerRequired, ID of the order returned by "sell" or "buy" request
    quantityintegerRequired, quantity, in contracts ($10 per contract for futures, ฿1 — for options)
    pricefloatRequired, USD for futures, BTC for options
    callbackfunctionOptional, callback, if not provided method returns promise
  • cancel(orderId, callback) - Doc, private

    Cancell own order by id.

    Parameters

    NameTypeDecription
    orderIdintegerRequired, ID of the order returned by "sell" or "buy" request
    callbackfunctionOptional, callback, if not provided method returns promise
  • cancelall(type, callback) - Doc

    Cancel all own futures, or all options, or all.

    Parameters

    NameTypeDecription
    typestringOptional, type of instruments to cancel, allowed: "all", "futures", "options", default: "all"
    callbackfunctionOptional, callback, if not provided method returns promise
  • getopenorders(instrument, orderId, callback) - Doc, private

    Retrieve open orders.

    Parameters

    NameTypeDescription
    instrumentstringOptional, instrument name, use if want orders for specific instrument
    orderIdintegerOptional, order id
    callbackfunctionOptional, callback, if not provided method returns promise
  • positions(callback) - Doc, private

    Retreive positions.

    Parameters

    NameTypeDecription
    callbackfunctionOptional, callback, if not provided method returns promise
  • orderhistory(count, callback) - Doc, private

    Get history.

    Parameters

    NameTypeDescription
    countintegerOptional, number of requested records
    callbackfunctionOptional, callback, if not provided method returns promise
  • tradehistory(count, instrument, startTradeId, callback) - Doc, private

    Get private trade history of the account. (Authorization is required). The result is ordered by trade identifiers (trade id-s).

    Parameters

    NameTypeDescription
    countintegerOptional, number of results to fetch. Default: 20
    instrumentstringOptional, name of instrument, also aliases “all”, “futures”, “options” are allowed. Default: "all"
    startTradeIdintegerOptional, number of requested records
    callbackfunctionOptional, callback, if not provided method returns promise