Skip to content

Latest commit

 

History

History
437 lines (297 loc) · 12.3 KB

SpotApi.md

File metadata and controls

437 lines (297 loc) · 12.3 KB

GateApi.SpotApi

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

Method HTTP request Description
listCurrencies GET /spot/currencies List all currencies' details
getCurrency GET /spot/currencies/{currency} Get details of a specific currency
listCurrencyPairs GET /spot/currency_pairs List all currency pairs supported
getCurrencyPair GET /spot/currency_pairs/{currency_pair} Get details of a specifc order
listTickers GET /spot/tickers Retrieve ticker information
listOrderBook GET /spot/order_book Retrieve order book
listTrades GET /spot/trades Retrieve market trades
listCandlesticks GET /spot/candlesticks Market candlesticks
getSystemTime GET /spot/time Get server current time

listCurrencies

[Currency] listCurrencies()

List all currencies' details

Currency has two forms: 1. Only currency name, e.g., BTC, USDT 2. `<currency><chain>`, e.g., `HT_ETH` The latter one occurs when one currency has multiple chains. Currency detail contains a `chain` field whatever the form is. To retrieve all chains of one currency, you can use use all the details which has the name of the currency or name starting with `<currency>`.

Example

var GateApi = require('gate-api');

var apiInstance = new GateApi.SpotApi();
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.listCurrencies(callback);

Parameters

This endpoint does not need any parameter.

Return type

[Currency]

Authorization

No authorization required

HTTP request headers

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

getCurrency

Currency getCurrency(currency)

Get details of a specific currency

Example

var GateApi = require('gate-api');

var apiInstance = new GateApi.SpotApi();
var currency = "GT"; // String | Currency name
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.getCurrency(currency, callback);

Parameters

Name Type Description Notes
currency String Currency name

Return type

Currency

Authorization

No authorization required

HTTP request headers

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

listCurrencyPairs

[CurrencyPair] listCurrencyPairs()

List all currency pairs supported

Example

var GateApi = require('gate-api');

var apiInstance = new GateApi.SpotApi();
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.listCurrencyPairs(callback);

Parameters

This endpoint does not need any parameter.

Return type

[CurrencyPair]

Authorization

No authorization required

HTTP request headers

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

getCurrencyPair

CurrencyPair getCurrencyPair(currencyPair)

Get details of a specifc order

Example

var GateApi = require('gate-api');

var apiInstance = new GateApi.SpotApi();
var currencyPair = "ETH_BTC"; // String | Currency pair
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.getCurrencyPair(currencyPair, callback);

Parameters

Name Type Description Notes
currencyPair String Currency pair

Return type

CurrencyPair

Authorization

No authorization required

HTTP request headers

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

listTickers

[Ticker] listTickers(opts)

Retrieve ticker information

Return only related data if `currency_pair` is specified; otherwise return all of them

Example

var GateApi = require('gate-api');

var apiInstance = new GateApi.SpotApi();
var opts = {
  'currencyPair': "BTC_USDT", // String | Currency pair
  'timezone': "utc0" // String | Timezone
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.listTickers(opts, callback);

Parameters

Name Type Description Notes
currencyPair String Currency pair [optional]
timezone String Timezone [optional]

Return type

[Ticker]

Authorization

No authorization required

HTTP request headers

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

listOrderBook

OrderBook listOrderBook(currencyPair, opts)

Retrieve order book

Order book will be sorted by price from high to low on bids; low to high on asks

Example

var GateApi = require('gate-api');

var apiInstance = new GateApi.SpotApi();
var currencyPair = "BTC_USDT"; // String | Currency pair
var opts = {
  'interval': '0', // String | Order depth. 0 means no aggregation is applied. default to 0
  'limit': 10, // Number | Maximum number of order depth data in asks or bids
  'withId': false // Boolean | Return order book ID
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.listOrderBook(currencyPair, opts, callback);

Parameters

Name Type Description Notes
currencyPair String Currency pair
interval String Order depth. 0 means no aggregation is applied. default to 0 [optional] [default to '0']
limit Number Maximum number of order depth data in asks or bids [optional] [default to 10]
withId Boolean Return order book ID [optional] [default to false]

Return type

OrderBook

Authorization

No authorization required

HTTP request headers

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

listTrades

[Trade] listTrades(currencyPair, opts)

Retrieve market trades

You can use `from` and `to` to query by time range, or use `last_id` by scrolling page. The default behavior is by time range. Scrolling query using `last_id` is not recommended any more. If `last_id` is specified, time range query parameters will be ignored.

Example

var GateApi = require('gate-api');

var apiInstance = new GateApi.SpotApi();
var currencyPair = "BTC_USDT"; // String | Currency pair
var opts = {
  'limit': 100, // Number | Maximum number of records to be returned in a single list
  'lastId': "12345", // String | Specify list staring point using the `id` of last record in previous list-query results
  'reverse': false, // Boolean | Whether the id of records to be retrieved should be less than the last_id specified. Default to false.  When `last_id` is specified. Set `reverse` to `true` to trace back trading history; `false` to retrieve latest tradings.  No effect if `last_id` is not specified.
  'from': 1627706330, // Number | Start timestamp of the query
  'to': 1635329650, // Number | Time range ending, default to current time
  'page': 1 // Number | Page number
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.listTrades(currencyPair, opts, callback);

Parameters

Name Type Description Notes
currencyPair String Currency pair
limit Number Maximum number of records to be returned in a single list [optional] [default to 100]
lastId String Specify list staring point using the `id` of last record in previous list-query results [optional]
reverse Boolean Whether the id of records to be retrieved should be less than the last_id specified. Default to false. When `last_id` is specified. Set `reverse` to `true` to trace back trading history; `false` to retrieve latest tradings. No effect if `last_id` is not specified. [optional] [default to false]
from Number Start timestamp of the query [optional]
to Number Time range ending, default to current time [optional]
page Number Page number [optional] [default to 1]

Return type

[Trade]

Authorization

No authorization required

HTTP request headers

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

listCandlesticks

[[String]] listCandlesticks(currencyPair, opts)

Market candlesticks

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

Example

var GateApi = require('gate-api');

var apiInstance = new GateApi.SpotApi();
var currencyPair = "BTC_USDT"; // String | Currency pair
var opts = {
  'limit': 100, // Number | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
  'from': 1546905600, // Number | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
  'to': 1546935600, // Number | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
  'interval': '30m' // String | Interval time between data points. Note that `30d` means 1 natual month, not 30 days
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.listCandlesticks(currencyPair, opts, callback);

Parameters

Name Type Description Notes
currencyPair String Currency pair
limit Number Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. [optional] [default to 100]
from Number Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified [optional]
to Number End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time [optional]
interval String Interval time between data points. Note that `30d` means 1 natual month, not 30 days [optional] [default to '30m']

Return type

[[String]]

Authorization

No authorization required

HTTP request headers

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

getSystemTime

SystemTime getSystemTime()

Get server current time

Example

var GateApi = require('gate-api');

var apiInstance = new GateApi.SpotApi();
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
apiInstance.getSystemTime(callback);

Parameters

This endpoint does not need any parameter.

Return type

SystemTime

Authorization

No authorization required

HTTP request headers

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