Skip to content

Latest commit

 

History

History
2561 lines (1791 loc) · 104 KB

File metadata and controls

2561 lines (1791 loc) · 104 KB

FuturesApi

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

Method HTTP request Description
listFuturesContracts GET /futures/{settle}/contracts Query all futures contracts
getFuturesContract GET /futures/{settle}/contracts/{contract} Query single contract information
listFuturesOrderBook GET /futures/{settle}/order_book Query futures market depth information
listFuturesTrades GET /futures/{settle}/trades Futures market transaction records
listFuturesCandlesticks GET /futures/{settle}/candlesticks Futures market K-line chart
listFuturesPremiumIndex GET /futures/{settle}/premium_index Premium Index K-line chart
listFuturesTickers GET /futures/{settle}/tickers Get all futures trading statistics
listFuturesFundingRateHistory GET /futures/{settle}/funding_rate Futures market historical funding rate
listFuturesInsuranceLedger GET /futures/{settle}/insurance Futures market insurance fund history
listContractStats GET /futures/{settle}/contract_stats Futures statistics
getIndexConstituents GET /futures/{settle}/index_constituents/{index} Query index constituents
listLiquidatedOrders GET /futures/{settle}/liq_orders Query liquidation order history
listFuturesRiskLimitTiers GET /futures/{settle}/risk_limit_tiers Query risk limit tiers
listFuturesAccounts GET /futures/{settle}/accounts Get futures account
listFuturesAccountBook GET /futures/{settle}/account_book Query futures account change history
listPositions GET /futures/{settle}/positions Get user position list
getPosition GET /futures/{settle}/positions/{contract} Get single position information
updatePositionMargin POST /futures/{settle}/positions/{contract}/margin Update position margin
updatePositionLeverage POST /futures/{settle}/positions/{contract}/leverage Update position leverage
updatePositionCrossMode POST /futures/{settle}/positions/cross_mode Switch Position Margin Mode
updateDualCompPositionCrossMode POST /futures/{settle}/dual_comp/positions/cross_mode Switch Between Cross and Isolated Margin Modes Under Hedge Mode
updatePositionRiskLimit POST /futures/{settle}/positions/{contract}/risk_limit Update position risk limit
setDualMode POST /futures/{settle}/dual_mode Set position mode
getDualModePosition GET /futures/{settle}/dual_comp/positions/{contract} Get position information 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 Query futures order list
createFuturesOrder POST /futures/{settle}/orders Place futures order
cancelFuturesOrders DELETE /futures/{settle}/orders Cancel all orders with 'open' status
getOrdersWithTimeRange GET /futures/{settle}/orders_timerange Query futures order list by time range
createBatchFuturesOrder POST /futures/{settle}/batch_orders Place batch futures orders
getFuturesOrder GET /futures/{settle}/orders/{order_id} Query single order details
amendFuturesOrder PUT /futures/{settle}/orders/{order_id} Amend single order
cancelFuturesOrder DELETE /futures/{settle}/orders/{order_id} Cancel single order
getMyTrades GET /futures/{settle}/my_trades Query personal trading records
getMyTradesWithTimeRange GET /futures/{settle}/my_trades_timerange Query personal trading records by time range
listPositionClose GET /futures/{settle}/position_close Query position close history
listLiquidates GET /futures/{settle}/liquidates Query liquidation history
listAutoDeleverages GET /futures/{settle}/auto_deleverages Query ADL auto-deleveraging order information
countdownCancelAllFutures POST /futures/{settle}/countdown_cancel_all Countdown cancel orders
getFuturesFee GET /futures/{settle}/fee Query futures market trading fee rates
cancelBatchFutureOrders POST /futures/{settle}/batch_cancel_orders Cancel batch orders by specified ID list
amendBatchFutureOrders POST /futures/{settle}/batch_amend_orders Batch modify orders by specified IDs
getFuturesRiskLimitTable GET /futures/{settle}/risk_limit_table Query risk limit table by table_id
listPriceTriggeredOrders GET /futures/{settle}/price_orders Query auto order list
createPriceTriggeredOrder POST /futures/{settle}/price_orders Create price-triggered order
cancelPriceTriggeredOrderList DELETE /futures/{settle}/price_orders Cancel all auto orders
getPriceTriggeredOrder GET /futures/{settle}/price_orders/{order_id} Query single auto order details
cancelPriceTriggeredOrder DELETE /futures/{settle}/price_orders/{order_id} Cancel single auto order

listFuturesContracts

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

Query 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' | Settle currency
const opts = {
  'limit': 100, // number | Maximum number of records returned in a single list
  'offset': 0 // number | List offset, starting from 0
};
api.listFuturesContracts(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 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; }> 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)

Query single contract information

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' | 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)

Query futures market depth information

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' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'interval': '0', // string | Price precision for depth aggregation, 0 means no aggregation, defaults to 0 if not specified
  'limit': 10, // number | Number of depth levels
  'withId': false // boolean | Whether to return depth update ID. This ID increments by 1 each time depth changes
};
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 string Price precision for depth aggregation, 0 means no aggregation, defaults to 0 if not specified [optional] [default to '0']
limit number Number of depth levels [optional] [default to 10]
withId boolean Whether to return depth update ID. This ID increments by 1 each time depth changes [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 market transaction records

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' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'limit': 100, // number | Maximum number of records 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 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)

Futures market K-line chart

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' | 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 | Specify the end time of the K-line chart, defaults to current time if not specified, note that the time format is Unix timestamp with second precision
  'limit': 100, // number | Maximum number of recent data points to return. `limit` conflicts with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
  'interval': '5m', // '10s' | '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '8h' | '1d' | '7d' | Interval time between data points. Note that `1w` means natural week(Mon-Sun), while `7d` means every 7d since unix 0. 30d represents a natural month, not 30 days
  'timezone': 'utc0' // string | Time zone: all/utc0/utc8, default utc0
};
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 Specify the end time of the K-line chart, defaults to current time if not specified, note that the time format is Unix timestamp with second precision [optional] [default to undefined]
limit number Maximum number of recent data points to return. `limit` conflicts 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 natural week(Mon-Sun), while `7d` means every 7d since unix 0. 30d represents a natural month, not 30 days [optional] [default to '5m']
timezone string Time zone: all/utc0/utc8, default utc0 [optional] [default to 'utc0']

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 chart

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' | 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 | Specify the end time of the K-line chart, defaults to current time if not specified, note that the time format is Unix timestamp with second precision
  'limit': 100, // number | Maximum number of recent data points to return. `limit` conflicts with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
  'interval': '5m' // '10s' | '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '8h' | '1d' | '7d' | Time interval 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 Specify the end time of the K-line chart, defaults to current time if not specified, note that the time format is Unix timestamp with second precision [optional] [default to undefined]
limit number Maximum number of recent data points to return. `limit` conflicts with `from` and `to`. If either `from` or `to` is specified, request will be rejected. [optional] [default to 100]
interval Interval Time interval 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)

Get all futures trading statistics

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' | 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)

Futures market historical funding rate

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' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'limit': 100, // number | Maximum number of records returned in a single list
  'from': 1547706332, // number | Start timestamp  Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)
  'to': 1547706332 // number | Termination Timestamp  Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp
};
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 returned in a single list [optional] [default to 100]
from number Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit) [optional] [default to undefined]
to number Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp [optional] [default to undefined]

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 market insurance fund 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' | Settle currency
const opts = {
  'limit': 100 // number | Maximum number of records 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 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 statistics

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' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'from': 1604561000, // number | Start timestamp
  'interval': '5m', // string | 
  '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 string [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)

Query 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' | 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)

Query liquidation order history

The time interval between from and to is maximum 3600. Some private fields are not returned by public interfaces, refer to field descriptions for details

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' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'from': 1547706332, // number | Start timestamp  Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)
  'to': 1547706332, // number | Termination Timestamp  Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp
  'limit': 100 // number | Maximum number of records 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 Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit) [optional] [default to undefined]
to number Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp [optional] [default to undefined]
limit number Maximum number of records 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

listFuturesRiskLimitTiers

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

Query risk limit tiers

When the &#39;contract&#39; parameter is not passed, the default is to query the risk limits for the top 100 markets. &#39;Limit&#39; and &#39;offset&#39; correspond to pagination queries at the market level, not to the length of the returned array. This only takes effect when the contract parameter is empty.

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' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records returned in a single list
  'offset': 0 // number | List offset, starting from 0
};
api.listFuturesRiskLimitTiers(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 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; }> FuturesLimitRiskTiers

Authorization

No authorization required

HTTP request headers

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

listFuturesAccounts

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

Get 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' | 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 futures account change history

If the contract field is passed, only records containing this field after 2023-10-30 can be filtered.

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' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'from': 1547706332, // number | Start timestamp  Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)
  'to': 1547706332, // number | Termination Timestamp  Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp
  'type': "dnw" // string | Change types:  - dnw: Deposit and withdrawal - pnl: Profit and loss from position reduction - fee: Trading fees - refr: Referrer rebates - fund: Funding fees - point_dnw: Point card deposit and withdrawal - point_fee: Point card trading fees - point_refr: Point card referrer rebates - bonus_offset: Trial fund deduction
};
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 returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
from number Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit) [optional] [default to undefined]
to number Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp [optional] [default to undefined]
type string Change types: - dnw: Deposit and withdrawal - pnl: Profit and loss from position reduction - fee: Trading fees - refr: Referrer rebates - fund: Funding fees - point_dnw: Point card deposit and withdrawal - point_fee: Point card trading fees - point_refr: Point card referrer rebates - bonus_offset: Trial fund deduction [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)

Get user position list

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' | Settle currency
const opts = {
  'holding': true, // boolean | Return only real positions - true, return all - false
  'limit': 100, // number | Maximum number of records returned in a single list
  'offset': 0 // number | List offset, starting from 0
};
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]
limit number Maximum number of records 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; }> 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 information

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' | 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' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const change = "0.01"; // string | Margin change amount, positive number increases, negative number decreases
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 amount, positive number increases, negative number decreases [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' | 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)
  'pid': 1 // number | Product ID
};
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]
pid number Product ID [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

updatePositionCrossMode

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

Switch Position Margin 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' | Settle currency
const futuresPositionCrossMode = new FuturesPositionCrossMode(); // FuturesPositionCrossMode | 
api.updatePositionCrossMode(settle, futuresPositionCrossMode)
   .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]
futuresPositionCrossMode FuturesPositionCrossMode

Return type

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

Authorization

apiv4

HTTP request headers

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

updateDualCompPositionCrossMode

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

Switch Between Cross and Isolated Margin Modes Under Hedge 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' | Settle currency
const inlineObject = new InlineObject(); // InlineObject | 
api.updateDualCompPositionCrossMode(settle, inlineObject)
   .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]
inlineObject InlineObject

Return type

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

Authorization

apiv4

HTTP request headers

  • Content-Type: application/json
  • 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' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const riskLimit = "1000000"; // string | New risk limit value
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 risk limit value [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)

Set position mode

The prerequisite for changing mode is that all positions have no holdings and no pending 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' | 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)

Get position information 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' | 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' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const change = "0.01"; // string | Margin change amount, positive number increases, negative number decreases
const dualSide = "dual_long"; // string | 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 amount, positive number increases, negative number decreases [default to undefined]
dualSide string 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' | 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' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const riskLimit = "1000000"; // string | New risk limit value
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 risk limit value [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)

Query futures order list

  • 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' | Settle currency
const status = "open"; // string | Query order list based on status
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'lastId': "12345" // string | Use the ID of the last record in the previous list as the starting point for the next list  Operations based on custom IDs can only be checked when orders are pending. After orders are completed (filled/cancelled), they can be checked within 1 hour after completion. After expiration, only order IDs can be used
};
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 string Query order list based on status [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
limit number Maximum number of records returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
lastId string Use the ID of the last record in the previous list as the starting point for the next list Operations based on custom IDs can only be checked when orders are pending. After orders are completed (filled/cancelled), they can be checked within 1 hour after completion. After expiration, only order IDs can be used [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, opts)

Place futures order

  • When placing an order, the number of contracts is specified `size`, not the number of coins. The number of coins corresponding to each contract is returned in the contract details interface `quanto_multiplier` - 0 The order that was completed cannot be obtained after 10 minutes of withdrawal, and the order will be mentioned that the order does not exist - Setting `reduce_only` to `true` can prevent the position from being penetrated when reducing the position - In single-position mode, if you need to close the position, you need to set `size` to 0 and `close` to `true` - In dual warehouse mode, - Reduce position: reduce_only=true, size is a positive number that indicates short position, negative number that indicates long position - Add number that indicates adding long positions, and negative numbers indicate adding short positions - Close position: size=0, set the direction of closing position according to auto_size, and set `reduce_only` to true at the same time - reduce_only: Make sure to only perform position reduction operations to prevent increased positions - Set `stp_act` to determine the use of a strategy that restricts user transactions. For detailed usage, refer to the body parameter `stp_act`

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' | Settle currency
const futuresOrder = new FuturesOrder(); // FuturesOrder | 
const opts = {
  'xGateExptime': "1689560679123" // string | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected
};
api.createFuturesOrder(settle, futuresOrder, 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]
futuresOrder FuturesOrder
xGateExptime string Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected [optional] [default to undefined]

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 orders with &#39;open&#39; status

Zero-fill orders 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' | Settle currency
const contract = "BTC_USDT"; // string | Futures contract
const opts = {
  'xGateExptime': "1689560679123", // string | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected
  'side': "ask", // string | Specify all buy orders or all sell orders, both are included if not specified. Set to bid to cancel all buy orders, set to ask to cancel all sell orders
  'excludeReduceOnly': false, // boolean | Whether to exclude reduce-only orders
  'text': "cancel by user" // string | Remark for order cancellation
};
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]
xGateExptime string Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected [optional] [default to undefined]
side string Specify all buy orders or all sell orders, both are included if not specified. Set to bid to cancel all buy orders, set to ask to cancel all sell orders [optional] [default to undefined]
excludeReduceOnly boolean Whether to exclude reduce-only orders [optional] [default to undefined]
text string Remark for order cancellation [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)

Query futures order list 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' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'from': 1547706332, // number | Start timestamp  Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)
  'to': 1547706332, // number | Termination Timestamp  Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp
  'limit': 100, // number | Maximum number of records 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 Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit) [optional] [default to undefined]
to number Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp [optional] [default to undefined]
limit number Maximum number of records 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, opts)

Place batch 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' | Settle currency
const futuresOrder = [new FuturesOrder()]; // Array<FuturesOrder> | 
const opts = {
  'xGateExptime': "1689560679123" // string | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected
};
api.createBatchFuturesOrder(settle, futuresOrder, 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]
futuresOrder Array<FuturesOrder>
xGateExptime string Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected [optional] [default to undefined]

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)

Query single order details

  • 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' | 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. 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. 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, opts)

Amend 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' | 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. 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 | 
const opts = {
  'xGateExptime': "1689560679123" // string | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected
};
api.amendFuturesOrder(settle, orderId, futuresOrderAmendment, 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]
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. 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
xGateExptime string Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected [optional] [default to undefined]

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, opts)

Cancel 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' | 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. finished, it can be checked within 60 seconds after the end of the order. After that, only order ID is accepted.
const opts = {
  'xGateExptime': "1689560679123" // string | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected
};
api.cancelFuturesOrder(settle, orderId, 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]
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. finished, it can be checked within 60 seconds after the end of the order. After that, only order ID is accepted. [default to undefined]
xGateExptime string Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected [optional] [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)

Query personal trading records

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' | 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 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 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)

Query personal trading records 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' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'from': 1547706332, // number | Start timestamp  Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)
  'to': 1547706332, // number | Termination Timestamp  Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp
  'limit': 100, // number | Maximum number of records 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 Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit) [optional] [default to undefined]
to number Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp [optional] [default to undefined]
limit number Maximum number of records 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)

Query 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' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'from': 1547706332, // number | Start timestamp  Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)
  'to': 1547706332, // number | Termination Timestamp  Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix 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 returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
from number Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit) [optional] [default to undefined]
to number Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix 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)

Query 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' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'from': 1547706332, // number | Start timestamp  Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)
  'to': 1547706332, // number | Termination Timestamp  Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp
  'at': 0 // number | Specify 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 returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
from number Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit) [optional] [default to undefined]
to number Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp [optional] [default to undefined]
at number Specify 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)

Query ADL auto-deleveraging order information

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' | Settle currency
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records returned in a single list
  'offset': 0, // number | List offset, starting from 0
  'from': 1547706332, // number | Start timestamp  Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit)
  'to': 1547706332, // number | Termination Timestamp  Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp
  'at': 0 // number | Specify 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 returned in a single list [optional] [default to 100]
offset number List offset, starting from 0 [optional] [default to 0]
from number Start timestamp Specify start time, time format is Unix timestamp. If not specified, it defaults to (the data start time of the time range actually returned by to and limit) [optional] [default to undefined]
to number Termination Timestamp Specify the end time. If not specified, it defaults to the current time, and the time format is a Unix timestamp [optional] [default to undefined]
at number Specify 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

Heartbeat detection for contract orders: When the user-set `timeout` time is reached, if neither the existing countdown is canceled nor a new countdown is set, the relevant contract orders will be automatically canceled. This API can be called repeatedly to or cancel the countdown. Usage example: Repeatedly call this API at 30-second intervals, setting the `timeout` to 30 (seconds) each time. If this API is not called again within 30 seconds, all open orders on your specified `market` will be automatically canceled. If the `timeout` is set to 0 within 30 seconds, the countdown timer will terminate, and the automatic order cancellation function will be disabled.

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' | 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 futures market 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' | 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

cancelBatchFutureOrders

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

Cancel batch orders by specified ID list

Multiple different order IDs can be specified, maximum 20 records per request

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' | Settle currency
const requestBody = undefined; // Array<string> | 
const opts = {
  'xGateExptime': "1689560679123" // string | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected
};
api.cancelBatchFutureOrders(settle, requestBody, 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]
requestBody Array<string>
xGateExptime string Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

amendBatchFutureOrders

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

Batch modify orders by specified IDs

Multiple different order IDs can be specified, maximum 10 orders per request

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' | Settle currency
const batchAmendOrderReq = [new BatchAmendOrderReq()]; // Array<BatchAmendOrderReq> | 
const opts = {
  'xGateExptime': "1689560679123" // string | Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected
};
api.amendBatchFutureOrders(settle, batchAmendOrderReq, 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]
batchAmendOrderReq Array<BatchAmendOrderReq>
xGateExptime string Specify the expiration time (milliseconds); if the GATE receives the request time greater than the expiration time, the request will be rejected [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

getFuturesRiskLimitTable

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

Query risk limit table by table_id

Just pass table_id

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' | Settle currency
const tableId = "CYBER_USDT_20241122"; // string | Risk limit table ID
api.getFuturesRiskLimitTable(settle, tableId)
   .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]
tableId string Risk limit table ID [default to undefined]

Return type

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

Authorization

No authorization required

HTTP request headers

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

listPriceTriggeredOrders

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

Query auto order list

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' | Settle currency
const status = "status_example"; // 'open' | 'finished' | Query order list based on status
const opts = {
  'contract': "BTC_USDT", // string | Futures contract, return related data only if specified
  'limit': 100, // number | Maximum number of records 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 Query order list based on status [default to undefined]
contract string Futures contract, return related data only if specified [optional] [default to undefined]
limit number Maximum number of records 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 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' | 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, opts)

Cancel 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' | Settle currency
const opts = {
  'contract': "BTC_USDT" // string | Futures contract, return related data only if specified
};
api.cancelPriceTriggeredOrderList(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; }> FuturesPriceTriggeredOrder

Authorization

apiv4

HTTP request headers

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

getPriceTriggeredOrder

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

Query single auto order details

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' | Settle currency
const orderId = "orderId_example"; // string | ID returned when order is successfully created
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 ID returned when order is successfully created [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 single auto 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' | Settle currency
const orderId = "orderId_example"; // string | ID returned when order is successfully created
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 ID returned when order is successfully created [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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