Skip to content

Latest commit

 

History

History
1879 lines (1287 loc) · 76 KB

SpotApi.md

File metadata and controls

1879 lines (1287 loc) · 76 KB

SpotApi

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

Method HTTP request Description
listCurrencies GET /spot/currencies Query all currency information
getCurrency GET /spot/currencies/{currency} Query single currency information
listCurrencyPairs GET /spot/currency_pairs Query all supported currency pairs
getCurrencyPair GET /spot/currency_pairs/{currency_pair} Query single currency pair details
listTickers GET /spot/tickers Get currency pair ticker information
listOrderBook GET /spot/order_book Get market depth information
listSpotRpiOrderBook GET /spot/rpi_order_book Get the RPI order book
listTrades GET /spot/trades Query market transaction records
listCandlesticks GET /spot/candlesticks Market K-line chart
getFee GET /spot/fee Query account fee rates
getBatchSpotFee GET /spot/batch_fee Batch query account fee rates
listSpotAccounts GET /spot/accounts List spot trading accounts
listSpotAccountBook GET /spot/account_book Query spot account transaction history
createBatchOrders POST /spot/batch_orders Batch place orders
listAllOpenOrders GET /spot/open_orders List all open orders
createCrossLiquidateOrder POST /spot/cross_liquidate_orders Close position when cross-currency is disabled
listOrders GET /spot/orders List orders
createOrder POST /spot/orders Create order
cancelOrders DELETE /spot/orders Cancel `open` orders in bulk, optionally filtered by currency pair
cancelBatchOrders POST /spot/cancel_batch_orders Cancel batch orders by specified ID list
getOrder GET /spot/orders/{order_id} Query single order details
cancelOrder DELETE /spot/orders/{order_id} Cancel single order
amendOrder PATCH /spot/orders/{order_id} Amend single order
listMyTrades GET /spot/my_trades Query personal trading records
getSystemTime GET /spot/time Get server current time
countdownCancelAllSpot POST /spot/countdown_cancel_all Countdown cancel orders
amendBatchOrders POST /spot/amend_batch_orders Batch modification of orders
getSpotInsuranceHistory GET /spot/insurance_history Query spot insurance fund historical data
listSpotPriceTriggeredOrders GET /spot/price_orders Query running auto order list
createSpotPriceTriggeredOrder POST /spot/price_orders Create price-triggered order
cancelSpotPriceTriggeredOrderList DELETE /spot/price_orders Cancel all auto orders
getSpotPriceTriggeredOrder GET /spot/price_orders/{order_id} Query single auto order details
cancelSpotPriceTriggeredOrder DELETE /spot/price_orders/{order_id} Cancel single auto order
listSpotPovOrders GET /spot/pov_orders List Spot POV orders
createSpotPovOrder POST /spot/pov_orders Create a spot percentage-of-volume (POV) strategy order
cancelSpotPovOrders DELETE /spot/pov_orders Cancel Spot POV orders
getSpotPovOrder GET /spot/pov_orders/{order_id} Query Spot POV order details
cancelSpotPovOrder DELETE /spot/pov_orders/{order_id} Cancel a Spot POV order

listCurrencies

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

Query all currency information

When a currency is associated with multiple blockchains, use `chains` to view information about each chain, such as deposit and withdrawal status and chain identifiers.

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.SpotApi(client);
api.listCurrencies()
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

This endpoint does not need any parameter.

Return type

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

Authorization

No authorization required

HTTP request headers

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

getCurrency

Promise<{ response: http.IncomingMessage; body: Currency; }> getCurrency(currency)

Query single currency 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.SpotApi(client);
const currency = "GT"; // string | Currency name
api.getCurrency(currency)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currency string Currency name [default to undefined]

Return type

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

Authorization

No authorization required

HTTP request headers

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

listCurrencyPairs

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

Query all supported currency pairs

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.SpotApi(client);
api.listCurrencyPairs()
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

This endpoint does not need any parameter.

Return type

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

Authorization

No authorization required

HTTP request headers

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

getCurrencyPair

Promise<{ response: http.IncomingMessage; body: CurrencyPair; }> getCurrencyPair(currencyPair)

Query single currency pair 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.SpotApi(client);
const currencyPair = "ETH_BTC"; // string | Currency pair
api.getCurrencyPair(currencyPair)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Currency pair [default to undefined]

Return type

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

Authorization

No authorization required

HTTP request headers

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

listTickers

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

Get currency pair ticker information

If `currency_pair` is specified, only query that currency pair; otherwise return all 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.SpotApi(client);
const opts = {
  'currencyPair': "BTC_USDT", // string | Currency pair
  'timezone': "utc0" // 'utc0' | 'utc8' | 'all' | Timezone
};
api.listTickers(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Currency pair [optional] [default to undefined]
timezone Timezone Timezone [optional] [default to undefined]

Return type

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

Authorization

No authorization required

HTTP request headers

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

listOrderBook

Promise<{ response: http.IncomingMessage; body: OrderBook; }> listOrderBook(currencyPair, opts)

Get market depth information

Market depth buy orders are sorted by price from high to low, sell orders are reversed

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.SpotApi(client);
const currencyPair = "BTC_USDT"; // string | Currency pair
const opts = {
  'interval': '0', // string | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0
  'limit': 10, // number | Number of depth levels
  'withId': false // boolean | Return order book update ID
};
api.listOrderBook(currencyPair, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Currency pair [default to undefined]
interval string Price precision for merged depth. 0 means no merging. If not specified, defaults to 0 [optional] [default to '0']
limit number Number of depth levels [optional] [default to 10]
withId boolean Return order book update ID [optional] [default to undefined]

Return type

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

Authorization

No authorization required

HTTP request headers

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

listSpotRpiOrderBook

Promise<{ response: http.IncomingMessage; body: OrderBook; }> listSpotRpiOrderBook(currencyPair, opts)

Get the RPI order book

Get the RPI order book, with bids sorted by descending price and asks by ascending price.

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.SpotApi(client);
const currencyPair = "BTC_USDT"; // string | Currency pair
const opts = {
  'interval': '0', // string | Price precision for merged depth. 0 means no merging. If not specified, defaults to 0
  'limit': 10, // number | Number of depth levels
  'withId': false // boolean | Return order book update ID
};
api.listSpotRpiOrderBook(currencyPair, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Currency pair [default to undefined]
interval string Price precision for merged depth. 0 means no merging. If not specified, defaults to 0 [optional] [default to '0']
limit number Number of depth levels [optional] [default to 10]
withId boolean Return order book update ID [optional] [default to undefined]

Return type

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

Authorization

No authorization required

HTTP request headers

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

listTrades

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

Query market transaction records

Supports querying by time range using `from` and `to` parameters or pagination based on `last_id`. By default, queries the last 30 days. Pagination based on `last_id` is no longer recommended. If `last_id` is specified, the time range query parameters will be ignored. When using limit&page pagination to retrieve data, the maximum number of pages is 100,000, that is, limit * (page - 1) <= 100,000.

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.SpotApi(client);
const currencyPair = "BTC_USDT"; // string | Currency pair
const opts = {
  'limit': 100, // number | Maximum number of items returned in list. Default: 100, minimum: 1, maximum: 1000
  '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
  'reverse': true, // boolean | Whether to retrieve data less than `last_id`. Default returns records greater than `last_id`.  Set to `true` to trace back market trade records, `false` to get latest trades.  No effect when `last_id` is not set.
  'from': BigInt('1627706330'), // number | Start timestamp for the query
  'to': BigInt('1635329650'), // number | End timestamp for the query, defaults to current time if not specified
  'page': 1 // number | Page number
};
api.listTrades(currencyPair, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Currency pair [default to undefined]
limit number Maximum number of items returned in list. Default: 100, minimum: 1, maximum: 1000 [optional] [default to 100]
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]
reverse boolean Whether to retrieve data less than `last_id`. Default returns records greater than `last_id`. Set to `true` to trace back market trade records, `false` to get latest trades. No effect when `last_id` is not set. [optional] [default to undefined]
from number | bigint Start timestamp for the query [optional] [default to undefined]
to number | bigint End timestamp for the query, defaults to current time if not specified [optional] [default to undefined]
page number Page number [optional] [default to 1]

Return type

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

Authorization

No authorization required

HTTP request headers

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

listCandlesticks

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

Market K-line chart

K-line chart data returns a maximum of 1000 points per request. When specifying from, to, and interval, ensure the number of points is not excessive

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.SpotApi(client);
const currencyPair = "BTC_USDT"; // string | Currency pair
const opts = {
  '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.
  'from': BigInt('1546905600'), // number | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  'to': BigInt('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
  'interval': '30m' // '1s' | '10s' | '1m' | '5m' | '15m' | '30m' | '1h' | '4h' | '8h' | '1d' | '7d' | '30d' | Time interval between data points. Note that `30d` represents a calendar month, not aligned to 30 days
};
api.listCandlesticks(currencyPair, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Currency pair [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]
from number | bigint Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified [optional] [default to undefined]
to number | bigint 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]
interval Interval Time interval between data points. Note that `30d` represents a calendar month, not aligned to 30 days [optional] [default to '30m']

Return type

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

Authorization

No authorization required

HTTP request headers

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

getFee

Promise<{ response: http.IncomingMessage; body: SpotFee; }> getFee(opts)

Query account fee rates

This API is deprecated. The new fee query API is `/wallet/fee`

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.SpotApi(client);
const opts = {
  'currencyPair': "BTC_USDT" // string | Specify currency pair to get more accurate fee settings.  This field is optional. Usually fee settings are the same for all currency pairs.
};
api.getFee(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Specify currency pair to get more accurate fee settings. This field is optional. Usually fee settings are the same for all currency pairs. [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

getBatchSpotFee

Promise<{ response: http.IncomingMessage; body: { [key: string]: SpotFee; }; }> getBatchSpotFee(currencyPairs)

Batch query account 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.SpotApi(client);
const currencyPairs = "BTC_USDT,ETH_USDT"; // string | Maximum 50 currency pairs per request
api.getBatchSpotFee(currencyPairs)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPairs string Maximum 50 currency pairs per request [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

listSpotAccounts

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

List spot trading accounts

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.SpotApi(client);
const opts = {
  'currency': "BTC" // string | Query by specified currency name
};
api.listSpotAccounts(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currency string Query by specified currency name [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

listSpotAccountBook

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

Query spot account transaction history

Record query time range cannot exceed 30 days. When using limit&page pagination to retrieve data, the maximum number of pages is 100,000, that is, limit * (page - 1) <= 100,000.

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.SpotApi(client);
const opts = {
  'currency': "BTC", // string | Query by specified currency name
  'from': BigInt('1627706330'), // number | Start timestamp for the query
  'to': BigInt('1635329650'), // number | End timestamp for the query, defaults to current time if not specified
  'page': 1, // number | Page number
  'limit': 100, // number | Maximum number of records returned in a single list
  'type': "lend", // string | Query by specified account change type. If not specified, all change types will be included.
  'code': "code_example" // string | Specify account change code for query. If not specified, all change types are included. This parameter has higher priority than `type`
};
api.listSpotAccountBook(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currency string Query by specified currency name [optional] [default to undefined]
from number | bigint Start timestamp for the query [optional] [default to undefined]
to number | bigint End timestamp for the query, defaults to current time if not specified [optional] [default to undefined]
page number Page number [optional] [default to 1]
limit number Maximum number of records returned in a single list [optional] [default to 100]
type string Query by specified account change type. If not specified, all change types will be included. [optional] [default to undefined]
code string Specify account change code for query. If not specified, all change types are included. This parameter has higher priority than `type` [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

createBatchOrders

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

Batch place orders

Batch order requirements: 1. Custom order field `text` must be specified 2. Up to 4 currency pairs per request, with up to 10 orders per currency pair 3. Spot orders and margin orders cannot be mixed; all `account` fields in the same request must be identical

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.SpotApi(client);
const order = [new Order()]; // Array<Order> | 
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.createBatchOrders(order, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
order Array
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; }> BatchOrder

Authorization

apiv4

HTTP request headers

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

listAllOpenOrders

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

List all open orders

Query the current order list of all trading pairs. Please note that the paging parameter controls the number of pending orders in each trading pair. There is no paging control trading pairs. All trading pairs with pending orders will be returned.

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.SpotApi(client);
const opts = {
  'page': 1, // number | Page number
  'limit': 100, // number | Maximum number of records returned in one page in each currency pair
  'account': "spot" // string | Specify query account
};
api.listAllOpenOrders(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
page number Page number [optional] [default to 1]
limit number Maximum number of records returned in one page in each currency pair [optional] [default to 100]
account string Specify query account [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

createCrossLiquidateOrder

Promise<{ response: http.IncomingMessage; body: Order; }> createCrossLiquidateOrder(liquidateOrder)

Close position when cross-currency is disabled

Currently, only cross-margin accounts are supported to place buy orders for disabled currencies. Maximum buy quantity = (unpaid principal and interest - currency balance - the amount of the currency in pending orders) / 0.998

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.SpotApi(client);
const liquidateOrder = new LiquidateOrder(); // LiquidateOrder | 
api.createCrossLiquidateOrder(liquidateOrder)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
liquidateOrder LiquidateOrder

Return type

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

Authorization

apiv4

HTTP request headers

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

listOrders

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

List orders

Note that query results default to spot order lists for spot, unified account, and isolated margin accounts. When `status` is set to `open` (i.e., when querying pending order lists), only `page` and `limit` pagination controls are supported. `limit` can only be set to a maximum of 100. The `side` parameter and time range query parameters `from` and `to` are not supported. When `status` is set to `finished` (i.e., when querying historical orders), in addition to pagination queries, `from` and `to` time range queries are also supported. Additionally, the `side` parameter can be set to filter one-sided history. Time range filter parameters are processed according to the order end time.

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.SpotApi(client);
const currencyPair = "BTC_USDT"; // string | Query by specified currency pair. Required for open orders, optional for filled orders
const status = "open"; // string | List orders based on status  `open` - order is waiting to be filled `finished` - order has been filled or cancelled 
const opts = {
  'page': 1, // number | Page number
  'limit': 100, // number | Maximum number of records to be returned. If `status` is `open`, maximum of `limit` is 100
  'account': "spot", // string | Specify query account
  'from': BigInt('1627706330'), // number | Start timestamp for the query
  'to': BigInt('1635329650'), // number | End timestamp for the query, defaults to current time if not specified
  'side': "sell" // string | Specify all bids or all asks, both included if not specified
};
api.listOrders(currencyPair, status, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Query by specified currency pair. Required for open orders, optional for filled orders [default to undefined]
status string List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled [default to undefined]
page number Page number [optional] [default to 1]
limit number Maximum number of records to be returned. If `status` is `open`, maximum of `limit` is 100 [optional] [default to 100]
account string Specify query account [optional] [default to undefined]
from number | bigint Start timestamp for the query [optional] [default to undefined]
to number | bigint End timestamp for the query, defaults to current time if not specified [optional] [default to undefined]
side string Specify all bids or all asks, both included if not specified [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

createOrder

Promise<{ response: http.IncomingMessage; body: Order; }> createOrder(order, opts)

Create order

Supports placing orders from spot, margin, leveraged, and cross-margin accounts. Use the `account` field to select the account type. The default is `spot`, which places an order from the spot account. For a `unified` account, orders use the unified account by default. When trading with a margin account by setting `account` to `margin`, you can set `auto_borrow` to `true`. If the account balance is insufficient, the system automatically calls `POST /margin/uni/loans` to borrow the shortfall. Whether assets received from a filled margin order are automatically used to repay an isolated-margin loan depends on the automatic repayment setting of the user&#39;s isolated-margin account. Use `/margin/auto_repay` to query or update this account-level automatic repayment setting. When trading with a unified account by setting `account` to `unified`, `auto_borrow` can likewise be enabled to borrow any shortfall. Unlike an isolated-margin account, whether a unified-account order repays automatically depends on the order&#39;s `auto_repay` setting. This setting applies only to the current order, so only assets received when that order is filled are used to repay the cross-margin loan. Unified-account orders currently support enabling both `auto_borrow` and `auto_repay`. Automatic repayment is triggered when the order finishes, that is, when `status` becomes `cancelled` or `closed`. Order status A resting order remains `open` until its entire quantity is filled. Once fully filled, the order finishes and its status becomes `closed`. If the order is cancelled before being fully filled, its status becomes `cancelled` regardless of whether it was partially filled. Iceberg orders Use `iceberg` to set the displayed quantity of an iceberg order. Fully hidden orders are not supported. Note that fills against the hidden portion are charged at the taker fee rate. Self-trade prevention Set `stp_act` to select the self-trade prevention action. Unified market A unified market supports matching orders that use different quote currencies. Specify the actual quote currency through `trade_quote`. For example, the BTC_USD market can match orders quoted in USDC, RLUSD, and other supported quote currencies. Query `GET /spot/currency_pairs` for the quote currencies supported by each unified market.

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.SpotApi(client);
const order = new Order(); // Order | 
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.createOrder(order, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
order Order
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: Order; }> Order

Authorization

apiv4

HTTP request headers

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

cancelOrders

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

Cancel `open` orders in bulk, optionally filtered by currency pair

When the `account` parameter is not specified, all pending orders including spot, unified account, and isolated margin will be cancelled. When `currency_pair` is not specified, all trading pair pending orders will be cancelled. You can specify a particular account to cancel all pending orders under that 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.SpotApi(client);
const opts = {
  'currencyPair': "BTC_USDT", // string | Currency pair
  'side': "sell", // string | Specify all bids or all asks, both included if not specified
  'account': "spot", // string | Specify account type  Classic account: All are included if not specified Unified account: Specify `unified`
  'tradeQuote': "USDC", // string | In a **unified market** only, specifies the actual quote currency for cancellation; when omitted, all orders matching the other criteria are cancelled
  'actionMode': "ACK", // string | Processing Mode  When placing an order, different fields are returned based on the action_mode  - `ACK`: Asynchronous mode, returns only key order fields - `RESULT`: No clearing information - `FULL`: Full mode (default)
  '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.cancelOrders(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Currency pair [optional] [default to undefined]
side string Specify all bids or all asks, both included if not specified [optional] [default to undefined]
account string Specify account type Classic account: All are included if not specified Unified account: Specify `unified` [optional] [default to undefined]
tradeQuote string In a unified market only, specifies the actual quote currency for cancellation; when omitted, all orders matching the other criteria are cancelled [optional] [default to undefined]
actionMode string Processing Mode When placing an order, different fields are returned based on the action_mode - `ACK`: Asynchronous mode, returns only key order fields - `RESULT`: No clearing information - `FULL`: Full mode (default) [optional] [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: Array; }> OrderCancel

Authorization

apiv4

HTTP request headers

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

cancelBatchOrders

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

Cancel batch orders by specified ID list

Multiple currency pairs can be specified, but maximum 20 orders are allowed 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.SpotApi(client);
const cancelBatchOrder = [new CancelBatchOrder()]; // Array<CancelBatchOrder> | 
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.cancelBatchOrders(cancelBatchOrder, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
cancelBatchOrder Array
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; }> CancelOrderResult

Authorization

apiv4

HTTP request headers

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

getOrder

Promise<{ response: http.IncomingMessage; body: Order; }> getOrder(orderId, currencyPair, opts)

Query single order details

By default, queries orders for spot, unified account, and isolated margin accounts.

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.SpotApi(client);
const orderId = "12345"; // string | The order ID returned when the order was successfully created or the custom ID specified by the user\'s creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel)
const currencyPair = "BTC_USDT"; // string | Specify the trading pair to query. This field is required when querying pending order records. This field can be omitted when querying filled order records.
const opts = {
  'account': "spot" // string | Specify query account
};
api.getOrder(orderId, currencyPair, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderId string The order ID returned when the order was successfully created or the custom ID specified by the user&#39;s creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel) [default to undefined]
currencyPair string Specify the trading pair to query. This field is required when querying pending order records. This field can be omitted when querying filled order records. [default to undefined]
account string Specify query account [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

cancelOrder

Promise<{ response: http.IncomingMessage; body: Order; }> cancelOrder(orderId, currencyPair, opts)

Cancel single order

By default, orders for spot, unified accounts and leveraged accounts are revoked.

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.SpotApi(client);
const orderId = "12345"; // string | The order ID returned when the order was successfully created or the custom ID specified by the user\'s creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel)
const currencyPair = "BTC_USDT"; // string | Currency pair
const opts = {
  'account': "spot", // string | Specify query account
  'actionMode': "ACK", // string | Processing Mode  When placing an order, different fields are returned based on the action_mode  - `ACK`: Asynchronous mode, returns only key order fields - `RESULT`: No clearing information - `FULL`: Full mode (default)
  '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.cancelOrder(orderId, currencyPair, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderId string The order ID returned when the order was successfully created or the custom ID specified by the user&#39;s creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel) [default to undefined]
currencyPair string Currency pair [default to undefined]
account string Specify query account [optional] [default to undefined]
actionMode string Processing Mode When placing an order, different fields are returned based on the action_mode - `ACK`: Asynchronous mode, returns only key order fields - `RESULT`: No clearing information - `FULL`: Full mode (default) [optional] [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: Order; }> Order

Authorization

apiv4

HTTP request headers

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

amendOrder

Promise<{ response: http.IncomingMessage; body: Order; }> amendOrder(orderId, orderPatch, opts)

Amend single order

By default, amend orders for spot, unified, and isolated-margin accounts. Both the request body and query parameters support `currency_pair` and `account`; the request body has higher precedence. Provide `currency_pair` in either the request body or the query parameters, choosing one location. Amendments and order creation share rate limits. Reducing quantity alone preserves matching priority. Changing the price or increasing the quantity places the order at the end of the new price level. A new quantity below the filled quantity triggers 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.SpotApi(client);
const orderId = "12345"; // string | The order ID returned when the order was successfully created or the custom ID specified by the user\'s creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel)
const orderPatch = new OrderPatch(); // OrderPatch | 
const opts = {
  'currencyPair': "BTC_USDT", // string | Currency pair
  'account': "spot", // string | Specify query account
  '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.amendOrder(orderId, orderPatch, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderId string The order ID returned when the order was successfully created or the custom ID specified by the user&#39;s creation (i.e. the `text` field). Operations based on custom IDs can only be checked in pending orders. Only order ID can be used after the order is finished (transaction/cancel) [default to undefined]
orderPatch OrderPatch
currencyPair string Currency pair [optional] [default to undefined]
account string Specify query account [optional] [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: Order; }> Order

Authorization

apiv4

HTTP request headers

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

listMyTrades

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

Query personal trading records

By default query of transaction records for spot, unified account and warehouse-by-site leverage accounts. The history within a specified time range can be queried by specifying `from` or (and) `to`. - If no time parameters are specified, only data for the last 7 days can be obtained. - If only any parameter of `from` or `to` is specified, only 7-day data from the start (or end) of the specified time is returned. - The range not allowed to exceed 30 days. The parameters of the time range filter are processed according to the order end time. The maximum number of pages when searching data using limit&page paging function is 100,000, that is, limit * (page - 1) <= 100,000.

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.SpotApi(client);
const opts = {
  'currencyPair': "BTC_USDT", // string | Retrieve results with specified currency pair
  'limit': 100, // number | Maximum number of items returned in list. Default: 100, minimum: 1, maximum: 1000
  'page': 1, // number | Page number
  'orderId': "12345", // string | Filter trades with specified order ID. `currency_pair` is also required if this field is present
  'account': "spot", // string | The accountparameter has been deprecated. The interface supports querying all transaction records of the account.
  'from': BigInt('1627706330'), // number | Start timestamp for the query
  'to': BigInt('1635329650') // number | End timestamp for the query, defaults to current time if not specified
};
api.listMyTrades(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Retrieve results with specified currency pair [optional] [default to undefined]
limit number Maximum number of items returned in list. Default: 100, minimum: 1, maximum: 1000 [optional] [default to 100]
page number Page number [optional] [default to 1]
orderId string Filter trades with specified order ID. `currency_pair` is also required if this field is present [optional] [default to undefined]
account string The accountparameter has been deprecated. The interface supports querying all transaction records of the account. [optional] [default to undefined]
from number | bigint Start timestamp for the query [optional] [default to undefined]
to number | bigint End timestamp for the query, defaults to current time if not specified [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

getSystemTime

Promise<{ response: http.IncomingMessage; body: SystemTime; }> getSystemTime()

Get server current time

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.SpotApi(client);
api.getSystemTime()
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

This endpoint does not need any parameter.

Return type

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

Authorization

No authorization required

HTTP request headers

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

countdownCancelAllSpot

Promise<{ response: http.IncomingMessage; body: TriggerTime; }> countdownCancelAllSpot(countdownCancelAllSpotTask)

Countdown cancel orders

Spot order heartbeat detection. If there is no &quot;cancel existing countdown&quot; or &quot;set new countdown&quot; when the user-set `timeout` time is reached, the related `spot pending orders` will be automatically cancelled. This interface can be called repeatedly to set a new countdown or cancel the countdown. Usage example: Repeat this interface at 30s intervals, setting the countdown `timeout` to `30 (seconds)` each time. If this interface is not called again within 30 seconds, all open orders for the `currency_pair` you specified will be automatically cancelled. If no `currency_pair` is specified, open orders for all currency pairs are cancelled automatically. If the `timeout` is set to 0 within 30 seconds, the countdown timer will be terminated and the automatic order cancellation 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.SpotApi(client);
const countdownCancelAllSpotTask = new CountdownCancelAllSpotTask(); // CountdownCancelAllSpotTask | 
api.countdownCancelAllSpot(countdownCancelAllSpotTask)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
countdownCancelAllSpotTask CountdownCancelAllSpotTask

Return type

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

Authorization

apiv4

HTTP request headers

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

amendBatchOrders

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

Batch modification of orders

Modify orders in spot, unified account and isolated margin account by default. Modify uncompleted orders, up to 5 orders can be modified at a time. Request parameters should be passed in array format. If there are order modification failures during the batch modification process, the modification of the next order will continue to be executed, and the execution will return with the corresponding order failure information. The call order of batch modification orders is consistent with the order list order. The return content order of batch modification orders is consistent with the order list 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.SpotApi(client);
const batchAmendItem = [new BatchAmendItem()]; // Array<BatchAmendItem> | 
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.amendBatchOrders(batchAmendItem, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
batchAmendItem Array
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; }> BatchOrder

Authorization

apiv4

HTTP request headers

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

getSpotInsuranceHistory

Promise<{ response: http.IncomingMessage; body: Array; }> getSpotInsuranceHistory(business, currency, from, to, opts)

Query spot insurance fund historical data

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.SpotApi(client);
const business = "margin"; // string | Leverage business, margin - position by position; unified - unified account
const currency = "BTC"; // string | Currency
const from = BigInt('1547706332'); // number | Start timestamp in seconds
const to = BigInt('1547706332'); // number | End timestamp in seconds
const opts = {
  'page': 1, // number | Page number
  'limit': 30 // number | The maximum number of items returned in the list, the default value is 30
};
api.getSpotInsuranceHistory(business, currency, from, to, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
business string Leverage business, margin - position by position; unified - unified account [default to undefined]
currency string Currency [default to undefined]
from number | bigint Start timestamp in seconds [default to undefined]
to number | bigint End timestamp in seconds [default to undefined]
page number Page number [optional] [default to 1]
limit number The maximum number of items returned in the list, the default value is 30 [optional] [default to 30]

Return type

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

Authorization

No authorization required

HTTP request headers

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

listSpotPriceTriggeredOrders

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

Query running 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.SpotApi(client);
const status = "status_example"; // 'open' | 'finished' | Query order list based on status
const opts = {
  'market': "BTC_USDT", // string | Trading market
  'account': "account_example", // 'normal' | 'margin' | 'unified' | Trading account type. Unified account must be set to `unified`
  'limit': 100, // number | Maximum number of records returned in a single list
  'offset': 0 // number | List offset, starting from 0
};
api.listSpotPriceTriggeredOrders(status, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
status Status Query order list based on status [default to undefined]
market string Trading market [optional] [default to undefined]
account Account Trading account type. Unified account must be set to `unified` [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; }> SpotPriceTriggeredOrder

Authorization

apiv4

HTTP request headers

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

createSpotPriceTriggeredOrder

Promise<{ response: http.IncomingMessage; body: TriggerOrderResponse; }> createSpotPriceTriggeredOrder(spotPriceTriggeredOrder)

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.SpotApi(client);
const spotPriceTriggeredOrder = new SpotPriceTriggeredOrder(); // SpotPriceTriggeredOrder | 
api.createSpotPriceTriggeredOrder(spotPriceTriggeredOrder)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
spotPriceTriggeredOrder SpotPriceTriggeredOrder

Return type

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

Authorization

apiv4

HTTP request headers

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

cancelSpotPriceTriggeredOrderList

Promise<{ response: http.IncomingMessage; body: Array; }> cancelSpotPriceTriggeredOrderList(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.SpotApi(client);
const opts = {
  'market': "BTC_USDT", // string | Trading market
  'account': "account_example" // 'normal' | 'margin' | 'unified' | Trading account type. Unified account must be set to `unified`
};
api.cancelSpotPriceTriggeredOrderList(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
market string Trading market [optional] [default to undefined]
account Account Trading account type. Unified account must be set to `unified` [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

getSpotPriceTriggeredOrder

Promise<{ response: http.IncomingMessage; body: SpotPriceTriggeredOrder; }> getSpotPriceTriggeredOrder(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.SpotApi(client);
const orderId = "orderId_example"; // string | ID returned when order is successfully created
api.getSpotPriceTriggeredOrder(orderId)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderId string ID returned when order is successfully created [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

cancelSpotPriceTriggeredOrder

Promise<{ response: http.IncomingMessage; body: SpotPriceTriggeredOrder; }> cancelSpotPriceTriggeredOrder(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.SpotApi(client);
const orderId = "orderId_example"; // string | ID returned when order is successfully created
api.cancelSpotPriceTriggeredOrder(orderId)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderId string ID returned when order is successfully created [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

listSpotPovOrders

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

List Spot POV 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.SpotApi(client);
const status = 'open'; // string | Order status. Defaults to open  - open: Active orders - finished: Finished orders
const opts = {
  'currencyPair': "BTC_USDT", // string | Currency pair
  'side': "sell", // string | Specify all bids or all asks, both included if not specified
  'page': 1, // number | Page number, up to 100
  'limit': 100 // number | Maximum number of records returned in a single list
};
api.listSpotPovOrders(status, opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
status string Order status. Defaults to open - open: Active orders - finished: Finished orders [default to 'open']
currencyPair string Currency pair [optional] [default to undefined]
side string Specify all bids or all asks, both included if not specified [optional] [default to undefined]
page number Page number, up to 100 [optional] [default to 1]
limit number Maximum number of records returned in a single list [optional] [default to 100]

Return type

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

Authorization

apiv4

HTTP request headers

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

createSpotPovOrder

Promise<{ response: http.IncomingMessage; body: SpotPovOrder; }> createSpotPovOrder(spotPovOrderCreator)

Create a spot percentage-of-volume (POV) strategy order

participation_rate specifies the target participation rate, and ttl specifies the validity period. The response contains the order id, which can be used with GET /spot/pov_orders/{order_id} to query 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.SpotApi(client);
const spotPovOrderCreator = new SpotPovOrderCreator(); // SpotPovOrderCreator | 
api.createSpotPovOrder(spotPovOrderCreator)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
spotPovOrderCreator SpotPovOrderCreator

Return type

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

Authorization

apiv4

HTTP request headers

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

cancelSpotPovOrders

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

Cancel Spot POV 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.SpotApi(client);
const opts = {
  'currencyPair': "BTC_USDT" // string | Currency pair
};
api.cancelSpotPovOrders(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
currencyPair string Currency pair [optional] [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

getSpotPovOrder

Promise<{ response: http.IncomingMessage; body: SpotPovOrder; }> getSpotPovOrder(orderId)

Query Spot POV 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.SpotApi(client);
const orderId = "12345"; // string | The order ID returned after successful creation, or the custom ID specified by the user in the `text` field.
api.getSpotPovOrder(orderId)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderId string The order ID returned after successful creation, or the custom ID specified by the user in the `text` field. [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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

cancelSpotPovOrder

Promise<{ response: http.IncomingMessage; body: SpotPovOrder; }> cancelSpotPovOrder(orderId)

Cancel a Spot POV 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.SpotApi(client);
const orderId = "12345"; // string | The order ID returned after successful creation, or the custom ID specified by the user in the `text` field.
api.cancelSpotPovOrder(orderId)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
orderId string The order ID returned after successful creation, or the custom ID specified by the user in the `text` field. [default to undefined]

Return type

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

Authorization

apiv4

HTTP request headers

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