Skip to content

Latest commit

 

History

History
2211 lines (1535 loc) · 83.4 KB

FuturesApi.md

File metadata and controls

2211 lines (1535 loc) · 83.4 KB

FuturesApi

All URIs are relative to https://api.gateio.ws/api/v4

Method HTTP request Description
listFuturesContracts GET /futures/{settle}/contracts List all futures contracts
getFuturesContract GET /futures/{settle}/contracts/{contract} Get a single contract
listFuturesOrderBook GET /futures/{settle}/order_book Futures order book
listFuturesTrades GET /futures/{settle}/trades Futures trading history
listFuturesCandlesticks GET /futures/{settle}/candlesticks Get futures candlesticks
listFuturesPremiumIndex GET /futures/{settle}/premium_index Premium Index K-Line
listFuturesTickers GET /futures/{settle}/tickers List futures tickers
listFuturesFundingRateHistory GET /futures/{settle}/funding_rate Funding rate history
listFuturesInsuranceLedger GET /futures/{settle}/insurance Futures insurance balance history
listContractStats GET /futures/{settle}/contract_stats Futures stats
getIndexConstituents GET /futures/{settle}/index_constituents/{index} Get index constituents
listLiquidatedOrders GET /futures/{settle}/liq_orders Retrieve liquidation history
listFuturesAccounts GET /futures/{settle}/accounts Query futures account
listFuturesAccountBook GET /futures/{settle}/account_book Query account book
listPositions GET /futures/{settle}/positions List all positions of a user
getPosition GET /futures/{settle}/positions/{contract} Get single position
updatePositionMargin POST /futures/{settle}/positions/{contract}/margin Update position margin
updatePositionLeverage POST /futures/{settle}/positions/{contract}/leverage Update position leverage
updatePositionRiskLimit POST /futures/{settle}/positions/{contract}/risk_limit Update position risk limit
setDualMode POST /futures/{settle}/dual_mode Enable or disable dual mode
getDualModePosition GET /futures/{settle}/dual_comp/positions/{contract} Retrieve position detail in dual mode
updateDualModePositionMargin POST /futures/{settle}/dual_comp/positions/{contract}/margin Update position margin in dual mode
updateDualModePositionLeverage POST /futures/{settle}/dual_comp/positions/{contract}/leverage Update position leverage in dual mode
updateDualModePositionRiskLimit POST /futures/{settle}/dual_comp/positions/{contract}/risk_limit Update position risk limit in dual mode
listFuturesOrders GET /futures/{settle}/orders List futures orders
createFuturesOrder POST /futures/{settle}/orders Create a futures order
cancelFuturesOrders DELETE /futures/{settle}/orders Cancel all `open` orders matched
getOrdersWithTimeRange GET /futures/{settle}/orders_timerange List Futures Orders By Time Range
createBatchFuturesOrder POST /futures/{settle}/batch_orders Create a batch of futures orders
getFuturesOrder GET /futures/{settle}/orders/{order_id} Get a single order
amendFuturesOrder PUT /futures/{settle}/orders/{order_id} Amend an order
cancelFuturesOrder DELETE /futures/{settle}/orders/{order_id} Cancel a single order
getMyTrades GET /futures/{settle}/my_trades List personal trading history
getMyTradesWithTimeRange GET /futures/{settle}/my_trades_timerange List personal trading history by time range
listPositionClose GET /futures/{settle}/position_close List position close history
listLiquidates GET /futures/{settle}/liquidates List liquidation history
listAutoDeleverages GET /futures/{settle}/auto_deleverages List Auto-Deleveraging History
countdownCancelAllFutures POST /futures/{settle}/countdown_cancel_all Countdown cancel orders
getFuturesFee GET /futures/{settle}/fee Query user trading fee rates
listPriceTriggeredOrders GET /futures/{settle}/price_orders List all auto orders
createPriceTriggeredOrder POST /futures/{settle}/price_orders Create a price-triggered order
cancelPriceTriggeredOrderList DELETE /futures/{settle}/price_orders Cancel all open orders
getPriceTriggeredOrder GET /futures/{settle}/price_orders/{order_id} Get a price-triggered order
cancelPriceTriggeredOrder DELETE /futures/{settle}/price_orders/{order_id} cancel a price-triggered order

listFuturesContracts

Promise<{ response: http.IncomingMessage; body: Array; }> listFuturesContracts(settle)

List all futures contracts

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
api.listFuturesContracts(settle)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> Contract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getFuturesContract

Promise<{ response: http.IncomingMessage; body: Contract; }> getFuturesContract(settle, contract)

Get a single contract

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
api.getFuturesContract(settle, contract)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Contract; }> Contract

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesOrderBook

Promise<{ response: http.IncomingMessage; body: FuturesOrderBook; }> listFuturesOrderBook(settle, contract, opts)

Futures order book

Bids will be sorted by price from high to low, while asks sorted reversely

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'interval': '0', // '0' | '0.1' | '0.01' | Order depth. 0 means no aggregation is applied. default to 0
  'limit': 10, // number | Maximum number of order depth data in asks or bids
  'withId': false // boolean | Whether the order book update ID will be returned. This ID increases by 1 on every order book update
};
api.listFuturesOrderBook(settle, contract, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
interval Interval Order depth. 0 means no aggregation is applied. default to 0 [optional] [default to '0']
limit number Maximum number of order depth data in asks or bids [optional] [default to 10]
withId boolean Whether the order book update ID will be returned. This ID increases by 1 on every order book update [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: FuturesOrderBook; }> FuturesOrderBook

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesTrades

Promise<{ response: http.IncomingMessage; body: Array; }> listFuturesTrades(settle, contract, opts)

Futures trading history

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'lastId': "12345", // string | Specify the starting point for this list based on a previously retrieved id  This parameter is deprecated. Use `from` and `to` instead to limit time range
  'from': 1546905600, // number | Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. 
  'to': 1546935600 // number | Specify end time in Unix seconds, default to current time
};
api.listFuturesTrades(settle, contract, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
lastId string Specify the starting point for this list based on a previously retrieved id This parameter is deprecated. Use `from` and `to` instead to limit time range [optional] [default to undefined]
from number Specify starting time in Unix seconds. If not specified, `to` and `limit` will be used to limit response items. If items between `from` and `to` are more than `limit`, only `limit` number will be returned. [optional] [default to undefined]
to number Specify end time in Unix seconds, default to current time [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesTrade

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesCandlesticks

Promise<{ response: http.IncomingMessage; body: Array; }> listFuturesCandlesticks(settle, contract, opts)

Get futures candlesticks

Return specified contract candlesticks. If prefix `contract` with `mark_`, the contract&#39;s mark price candlesticks are returned; if prefix with `index_`, index price candlesticks will be returned. Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying `from`, `to` and `interval`

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'from': 1546905600, // number | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  'to': 1546935600, // number | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
  'limit': 100, // number | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
  'interval': '5m' // '10s' | '30s' | '1m' | '5m' | '15m' | '30m' | '1h' | '2h' | '4h' | '6h' | '8h' | '12h' | '1d' | '7d' | '1w' | '30d' | Interval time between data points. Note that `1w` means natual week(Mon-Sun), while `7d` means every 7d since unix 0.  Note that 30d means 1 natual month, not 30 days
};
api.listFuturesCandlesticks(settle, contract, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
from number Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified [optional] [default to undefined]
to number End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time [optional] [default to undefined]
limit number Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. [optional] [default to 100]
interval Interval Interval time between data points. Note that `1w` means natual week(Mon-Sun), while `7d` means every 7d since unix 0. Note that 30d means 1 natual month, not 30 days [optional] [default to '5m']

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesCandlestick

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesPremiumIndex

Promise<{ response: http.IncomingMessage; body: Array; }> listFuturesPremiumIndex(settle, contract, opts)

Premium Index K-Line

Maximum of 1000 points can be returned in a query. Be sure not to exceed the limit when specifying from, to and interval

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'from': 1546905600, // number | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  'to': 1546935600, // number | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
  'limit': 100, // number | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
  'interval': '5m' // '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '6h' | '8h' | '1d' | '7d' | '30d' | Interval time between data points
};
api.listFuturesPremiumIndex(settle, contract, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
from number Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified [optional] [default to undefined]
to number End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time [optional] [default to undefined]
limit number Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. [optional] [default to 100]
interval Interval Interval time between data points [optional] [default to '5m']

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesPremiumIndex

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesTickers

Promise<{ response: http.IncomingMessage; body: Array; }> listFuturesTickers(settle, opts)

List futures tickers

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT" // string | Futures contract, return related data only if specified
};
api.listFuturesTickers(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesTicker

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesFundingRateHistory

Promise<{ response: http.IncomingMessage; body: Array; }> listFuturesFundingRateHistory(settle, contract, opts)

Funding rate history

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'limit': 100 // number | Maximum number of records to be returned in a single list
};
api.listFuturesFundingRateHistory(settle, contract, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FundingRateRecord

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesInsuranceLedger

Promise<{ response: http.IncomingMessage; body: Array; }> listFuturesInsuranceLedger(settle, opts)

Futures insurance balance history

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'limit': 100 // number | Maximum number of records to be returned in a single list
};
api.listFuturesInsuranceLedger(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]

Return type

Promise<{ response: AxiosResponse; body: Array; }> InsuranceRecord

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listContractStats

Promise<{ response: http.IncomingMessage; body: Array; }> listContractStats(settle, contract, opts)

Futures stats

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'from': 1604561000, // number | Start timestamp
  'interval': '5m', // '5m' | '15m' | '30m' | '1h' | '4h' | '1d' | 
  'limit': 30 // number | 
};
api.listContractStats(settle, contract, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
from number Start timestamp [optional] [default to undefined]
interval Interval [optional] [default to '5m']
limit number [optional] [default to 30]

Return type

Promise<{ response: AxiosResponse; body: Array; }> ContractStat

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getIndexConstituents

Promise<{ response: http.IncomingMessage; body: FuturesIndexConstituents; }> getIndexConstituents(settle, index)

Get index constituents

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const index = "BTC_USDT"; // string | Index name
api.getIndexConstituents(settle, index)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
index string Index name [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: FuturesIndexConstituents; }> FuturesIndexConstituents

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listLiquidatedOrders

Promise<{ response: http.IncomingMessage; body: Array; }> listLiquidatedOrders(settle, opts)

Retrieve liquidation history

Interval between `from` and `to` cannot exceeds 3600. Some private fields will not be returned in public endpoints. Refer to field description for detail.

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'from': 1547706332, // number | Start timestamp
  'to': 1547706332, // number | End timestamp
  'limit': 100 // number | Maximum number of records to be returned in a single list
};
api.listLiquidatedOrders(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
from number Start timestamp [optional] [default to undefined]
to number End timestamp [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesLiqOrder

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesAccounts

Promise<{ response: http.IncomingMessage; body: FuturesAccount; }> listFuturesAccounts(settle)

Query futures account

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
api.listFuturesAccounts(settle)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: FuturesAccount; }> FuturesAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesAccountBook

Promise<{ response: http.IncomingMessage; body: Array; }> listFuturesAccountBook(settle, opts)

Query account book

If the `contract` field is provided, it can only filter records that include this field after 2023-10-30.

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'from': 1547706332, // number | Start timestamp
  'to': 1547706332, // number | End timestamp
  'type': "dnw" // 'dnw' | 'pnl' | 'fee' | 'refr' | 'fund' | 'point_dnw' | 'point_fee' | 'point_refr' | Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate
};
api.listFuturesAccountBook(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
from number Start timestamp [optional] [default to undefined]
to number End timestamp [optional] [default to undefined]
type Type Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesAccountBook

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listPositions

Promise<{ response: http.IncomingMessage; body: Array; }> listPositions(settle, opts)

List all positions of a user

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'holding': true // boolean | Return only real positions - true, return all - false.
};
api.listPositions(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
holding boolean Return only real positions - true, return all - false. [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> Position

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getPosition

Promise<{ response: http.IncomingMessage; body: Position; }> getPosition(settle, contract)

Get single position

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
api.getPosition(settle, contract)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Position; }> Position

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

updatePositionMargin

Promise<{ response: http.IncomingMessage; body: Position; }> updatePositionMargin(settle, contract, change)

Update position margin

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const change = "0.01"; // string | Margin change. Use positive number to increase margin, negative number otherwise.
api.updatePositionMargin(settle, contract, change)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
change string Margin change. Use positive number to increase margin, negative number otherwise. [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Position; }> Position

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

updatePositionLeverage

Promise<{ response: http.IncomingMessage; body: Position; }> updatePositionLeverage(settle, contract, leverage, opts)

Update position leverage

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const leverage = "10"; // string | New position leverage
const opts = {
  'crossLeverageLimit': "10" // string | Cross margin leverage(valid only when `leverage` is 0)
};
api.updatePositionLeverage(settle, contract, leverage, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
leverage string New position leverage [default to undefined]
crossLeverageLimit string Cross margin leverage(valid only when `leverage` is 0) [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Position; }> Position

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

updatePositionRiskLimit

Promise<{ response: http.IncomingMessage; body: Position; }> updatePositionRiskLimit(settle, contract, riskLimit)

Update position risk limit

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const riskLimit = "10"; // string | New position risk limit
api.updatePositionRiskLimit(settle, contract, riskLimit)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
riskLimit string New position risk limit [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Position; }> Position

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

setDualMode

Promise<{ response: http.IncomingMessage; body: FuturesAccount; }> setDualMode(settle, dualMode)

Enable or disable dual mode

Before setting dual mode, make sure all positions are closed and no orders are open

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const dualMode = true; // boolean | Whether to enable dual mode
api.setDualMode(settle, dualMode)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
dualMode boolean Whether to enable dual mode [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: FuturesAccount; }> FuturesAccount

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getDualModePosition

Promise<{ response: http.IncomingMessage; body: Array; }> getDualModePosition(settle, contract)

Retrieve position detail in dual mode

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
api.getDualModePosition(settle, contract)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> Position

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

updateDualModePositionMargin

Promise<{ response: http.IncomingMessage; body: Array; }> updateDualModePositionMargin(settle, contract, change, dualSide)

Update position margin in dual mode

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const change = "0.01"; // string | Margin change. Use positive number to increase margin, negative number otherwise.
const dualSide = "dual_long"; // 'dual_long' | 'dual_short' | Long or short position
api.updateDualModePositionMargin(settle, contract, change, dualSide)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
change string Margin change. Use positive number to increase margin, negative number otherwise. [default to undefined]
dualSide DualSide Long or short position [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> Position

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

updateDualModePositionLeverage

Promise<{ response: http.IncomingMessage; body: Array; }> updateDualModePositionLeverage(settle, contract, leverage, opts)

Update position leverage in dual mode

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const leverage = "10"; // string | New position leverage
const opts = {
  'crossLeverageLimit': "10" // string | Cross margin leverage(valid only when `leverage` is 0)
};
api.updateDualModePositionLeverage(settle, contract, leverage, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
leverage string New position leverage [default to undefined]
crossLeverageLimit string Cross margin leverage(valid only when `leverage` is 0) [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> Position

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

updateDualModePositionRiskLimit

Promise<{ response: http.IncomingMessage; body: Array; }> updateDualModePositionRiskLimit(settle, contract, riskLimit)

Update position risk limit in dual mode

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const riskLimit = "10"; // string | New position risk limit
api.updateDualModePositionRiskLimit(settle, contract, riskLimit)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
riskLimit string New position risk limit [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> Position

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listFuturesOrders

Promise<{ response: http.IncomingMessage; body: Array; }> listFuturesOrders(settle, status, opts)

List futures orders

  • Zero-fill order cannot be retrieved for 10 minutes after cancellation - Historical orders, by default, only data within the past 6 months is supported. If you need to query data for a longer period, please use `GET /futures/{settle}/orders_timerange`.

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const status = "open"; // 'open' | 'finished' | Only list the orders with this status
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'lastId': "12345" // string | Specify list staring point using the `id` of last record in previous list-query results
};
api.listFuturesOrders(settle, status, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
status Status Only list the orders with this status [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
lastId string Specify list staring point using the `id` of last record in previous list-query results [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

createFuturesOrder

Promise<{ response: http.IncomingMessage; body: FuturesOrder; }> createFuturesOrder(settle, futuresOrder)

Create a futures order

  • Creating futures orders requires `size`, which is number of contracts instead of currency amount. You can use `quanto_multiplier` in contract detail response to know how much currency 1 size contract represents - Zero-filled order cannot be retrieved 10 minutes after order cancellation. You will get a 404 not found for such orders - Set `reduce_only` to `true` can keep the position from changing side when reducing position size - In single position mode, to close a position, you need to set `size` to 0 and `close` to `true` - In dual position mode, to close one side position, you need to set `auto_size` side, `reduce_only` to true and `size` to 0 - Set `stp_act` to decide the strategy of self-trade prevention. For detailed usage, refer to the `stp_act` parameter in request body

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const futuresOrder = new FuturesOrder(); // FuturesOrder | 
api.createFuturesOrder(settle, futuresOrder)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
futuresOrder FuturesOrder

Return type

Promise<{ response: AxiosResponse; body: FuturesOrder; }> FuturesOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

cancelFuturesOrders

Promise<{ response: http.IncomingMessage; body: Array; }> cancelFuturesOrders(settle, contract, opts)

Cancel all `open` orders matched

Zero-filled order cannot be retrieved 10 minutes after order cancellation

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'side': "ask" // 'ask' | 'bid' | All bids or asks. Both included if not specified
};
api.cancelFuturesOrders(settle, contract, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]
side Side All bids or asks. Both included if not specified [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getOrdersWithTimeRange

Promise<{ response: http.IncomingMessage; body: Array; }> getOrdersWithTimeRange(settle, opts)

List Futures Orders By Time Range

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'from': 1547706332, // number | Start timestamp
  'to': 1547706332, // number | End timestamp
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'offset': 0 // number | List offset, starting from 0
};
api.getOrdersWithTimeRange(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
from number Start timestamp [optional] [default to undefined]
to number End timestamp [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

createBatchFuturesOrder

Promise<{ response: http.IncomingMessage; body: Array; }> createBatchFuturesOrder(settle, futuresOrder)

Create a batch of futures orders

  • Up to 10 orders per request - If any of the order&#39;s parameters are missing or in the wrong format, all of them will not be executed, and a http status 400 error will be returned directly - If the parameters are checked and passed, all are executed. Even if there is a business logic error in the middle (such as insufficient funds), it will not affect other execution orders - The returned result is in array format, and the order corresponds to the orders in the request body - In the returned result, the `succeeded` field of type bool indicates whether the execution was successful or not - If the execution is successful, the normal order content is included; if the execution fails, the `label` field is included to indicate the cause of the error - In the rate limiting, each order is counted individually

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const futuresOrder = [new FuturesOrder()]; // Array<FuturesOrder> | 
api.createBatchFuturesOrder(settle, futuresOrder)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
futuresOrder Array<FuturesOrder>

Return type

Promise<{ response: AxiosResponse; body: Array; }> BatchFuturesOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

getFuturesOrder

Promise<{ response: http.IncomingMessage; body: FuturesOrder; }> getFuturesOrder(settle, orderId)

Get a single order

  • Zero-fill order cannot be retrieved for 10 minutes after cancellation - Historical orders, by default, only data within the past 6 months is supported.

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const orderId = "12345"; // string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook.  When the order is finished, it can be checked within 60 seconds after the end of the order.  After that, only order ID is accepted.
api.getFuturesOrder(settle, orderId)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
orderId string Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 60 seconds after the end of the order. After that, only order ID is accepted. [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: FuturesOrder; }> FuturesOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

amendFuturesOrder

Promise<{ response: http.IncomingMessage; body: FuturesOrder; }> amendFuturesOrder(settle, orderId, futuresOrderAmendment)

Amend an order

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const orderId = "12345"; // string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook.  When the order is finished, it can be checked within 60 seconds after the end of the order.  After that, only order ID is accepted.
const futuresOrderAmendment = new FuturesOrderAmendment(); // FuturesOrderAmendment | 
api.amendFuturesOrder(settle, orderId, futuresOrderAmendment)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
orderId string Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 60 seconds after the end of the order. After that, only order ID is accepted. [default to undefined]
futuresOrderAmendment FuturesOrderAmendment

Return type

Promise<{ response: AxiosResponse; body: FuturesOrder; }> FuturesOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

cancelFuturesOrder

Promise<{ response: http.IncomingMessage; body: FuturesOrder; }> cancelFuturesOrder(settle, orderId)

Cancel a single order

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const orderId = "12345"; // string | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook.  When the order is finished, it can be checked within 60 seconds after the end of the order.  After that, only order ID is accepted.
api.cancelFuturesOrder(settle, orderId)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
orderId string Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 60 seconds after the end of the order. After that, only order ID is accepted. [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: FuturesOrder; }> FuturesOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getMyTrades

Promise<{ response: http.IncomingMessage; body: Array; }> getMyTrades(settle, opts)

List personal trading history

By default, only data within the past 6 months is supported. If you need to query data for a longer period, please use `GET /futures/{settle}/my_trades_timerange`.

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'order': 12345, // number | Futures order ID, return related data only if specified
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'lastId': "12345" // string | Specify the starting point for this list based on a previously retrieved id  This parameter is deprecated. If you need to iterate through and retrieve more records, we recommend using \'GET /futures/{settle}/my_trades_timerange\'.
};
api.getMyTrades(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
order number Futures order ID, return related data only if specified [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
lastId string Specify the starting point for this list based on a previously retrieved id This parameter is deprecated. If you need to iterate through and retrieve more records, we recommend using &#39;GET /futures/{settle}/my_trades_timerange&#39;. [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> MyFuturesTrade

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getMyTradesWithTimeRange

Promise<{ response: http.IncomingMessage; body: Array; }> getMyTradesWithTimeRange(settle, opts)

List personal trading history by time range

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'from': 1547706332, // number | Start timestamp
  'to': 1547706332, // number | End timestamp
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'role': "maker" // string | Query role, maker or taker.
};
api.getMyTradesWithTimeRange(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
from number Start timestamp [optional] [default to undefined]
to number End timestamp [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
role string Query role, maker or taker. [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> MyFuturesTradeTimeRange

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listPositionClose

Promise<{ response: http.IncomingMessage; body: Array; }> listPositionClose(settle, opts)

List position close history

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'from': 1547706332, // number | Start timestamp
  'to': 1547706332, // number | End timestamp
  'side': "short", // string | Query side.  long or shot
  'pnl': "profit" // string | Query profit or loss
};
api.listPositionClose(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
from number Start timestamp [optional] [default to undefined]
to number End timestamp [optional] [default to undefined]
side string Query side. long or shot [optional] [default to undefined]
pnl string Query profit or loss [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> PositionClose

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listLiquidates

Promise<{ response: http.IncomingMessage; body: Array; }> listLiquidates(settle, opts)

List liquidation history

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'at': 0 // number | Specify a liquidation timestamp
};
api.listLiquidates(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
at number Specify a liquidation timestamp [optional] [default to 0]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesLiquidate

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listAutoDeleverages

Promise<{ response: http.IncomingMessage; body: Array; }> listAutoDeleverages(settle, opts)

List Auto-Deleveraging History

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'at': 0 // number | Specify an auto-deleveraging timestamp
};
api.listAutoDeleverages(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
at number Specify an auto-deleveraging timestamp [optional] [default to 0]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesAutoDeleverage

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

countdownCancelAllFutures

Promise<{ response: http.IncomingMessage; body: TriggerTime; }> countdownCancelAllFutures(settle, countdownCancelAllFuturesTask)

Countdown cancel orders

When the timeout set by the user is reached, if there is no cancel or set a new countdown, the related pending orders will be automatically cancelled. This endpoint can be called repeatedly to set a new countdown or cancel the countdown. For example, call this endpoint at 30s intervals, each countdown`timeout` is set to 30s. If this endpoint is not called again within 30 seconds, all pending orders on the specified `market` will be automatically cancelled, if no `market` is specified, all market pending orders will be cancelled. If the `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the cacnel function will be cancelled.

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const countdownCancelAllFuturesTask = new CountdownCancelAllFuturesTask(); // CountdownCancelAllFuturesTask | 
api.countdownCancelAllFutures(settle, countdownCancelAllFuturesTask)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
countdownCancelAllFuturesTask CountdownCancelAllFuturesTask

Return type

Promise<{ response: AxiosResponse; body: TriggerTime; }> TriggerTime

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

getFuturesFee

Promise<{ response: http.IncomingMessage; body: { [key: string]: FuturesFee; }; }> getFuturesFee(settle, opts)

Query user trading fee rates

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const opts = {
  'contract': "BTC_USDT" // string | Futures contract, return related data only if specified
};
api.getFuturesFee(settle, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: { [key: string]: FuturesFee; }; }> FuturesFee

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

listPriceTriggeredOrders

Promise<{ response: http.IncomingMessage; body: Array; }> listPriceTriggeredOrders(settle, status, opts)

List all auto orders

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const status = "status_example"; // 'open' | 'finished' | Only list the orders with this status
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records to be returned in a single list
  'offset': 0 // number | List offset, starting from 0
};
api.listPriceTriggeredOrders(settle, status, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
status Status Only list the orders with this status [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
limit number Maximum number of records to be returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesPriceTriggeredOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

createPriceTriggeredOrder

Promise<{ response: http.IncomingMessage; body: TriggerOrderResponse; }> createPriceTriggeredOrder(settle, futuresPriceTriggeredOrder)

Create a price-triggered order

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const futuresPriceTriggeredOrder = new FuturesPriceTriggeredOrder(); // FuturesPriceTriggeredOrder | 
api.createPriceTriggeredOrder(settle, futuresPriceTriggeredOrder)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
futuresPriceTriggeredOrder FuturesPriceTriggeredOrder

Return type

Promise<{ response: AxiosResponse; body: TriggerOrderResponse; }> TriggerOrderResponse

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

cancelPriceTriggeredOrderList

Promise<{ response: http.IncomingMessage; body: Array; }> cancelPriceTriggeredOrderList(settle, contract)

Cancel all open orders

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
api.cancelPriceTriggeredOrderList(settle, contract)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
contract string Futures contract [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: Array; }> FuturesPriceTriggeredOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

getPriceTriggeredOrder

Promise<{ response: http.IncomingMessage; body: FuturesPriceTriggeredOrder; }> getPriceTriggeredOrder(settle, orderId)

Get a price-triggered order

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const orderId = "orderId_example"; // string | Retrieve the data of the order with the specified ID
api.getPriceTriggeredOrder(settle, orderId)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
orderId string Retrieve the data of the order with the specified ID [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: FuturesPriceTriggeredOrder; }> FuturesPriceTriggeredOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

cancelPriceTriggeredOrder

Promise<{ response: http.IncomingMessage; body: FuturesPriceTriggeredOrder; }> cancelPriceTriggeredOrder(settle, orderId)

cancel a price-triggered order

Example

const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");

const api = new GateApi.FuturesApi(client);
const settle = "usdt"; // 'btc' | 'usdt' | 'usd' | Settle currency
const orderId = "orderId_example"; // string | Retrieve the data of the order with the specified ID
api.cancelPriceTriggeredOrder(settle, orderId)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
settle Settle Settle currency [default to undefined]
orderId string Retrieve the data of the order with the specified ID [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: FuturesPriceTriggeredOrder; }> FuturesPriceTriggeredOrder

Authorization

apiv4

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json