Skip to content

Latest commit

 

History

History
778 lines (560 loc) · 21.5 KB

File metadata and controls

778 lines (560 loc) · 21.5 KB

SpotApi

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

Method HTTP request Description
cancelBatchOrders POST /spot/cancel_batch_orders Cancel a batch of orders with an ID list
cancelOrder DELETE /spot/orders/{order_id} Cancel a single order
cancelOrders DELETE /spot/orders Cancel all `open` orders in specified currency pair
createBatchOrders POST /spot/batch_orders Create a batch of orders
createOrder POST /spot/orders Create an order
getCurrencyPair GET /spot/currency_pairs/{currency_pair} Get detail of one single order
getOrder GET /spot/orders/{order_id} Get a single order
listCandlesticks GET /spot/candlesticks Market candlesticks
listCurrencyPairs GET /spot/currency_pairs List all currency pairs supported
listMyTrades GET /spot/my_trades List personal trading history
listOrderBook GET /spot/order_book Retrieve order book
listOrders GET /spot/orders List orders
listSpotAccounts GET /spot/accounts List spot accounts
listTickers GET /spot/tickers Retrieve ticker information
listTrades GET /spot/trades Retrieve market trades

cancelBatchOrders

List<CancelOrderResult> cancelBatchOrders(cancelOrder)

Cancel a batch of orders with an ID list

Multiple currency pairs can be specified, but maximum 20 orders are allowed per request

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

ApiClient client = new ApiClient("YOUR_API_KEY", "YOUR_API_SECRET");
// uncomment the next line if testing the API with other host
// apiClient.setBasePath("https://some-other-host");
SpotApi apiInstance = new SpotApi(client);
List<CancelOrder> cancelOrder = new ArrayList<>(); // List<CancelOrder> | 
try {
    List<CancelOrderResult> result = apiInstance.cancelBatchOrders(cancelOrder);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#cancelBatchOrders");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
cancelOrder List<CancelOrder>

Return type

List<CancelOrderResult>

Authorization

Authentication with API key and secret is required

HTTP request headers

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

cancelOrder

Order cancelOrder(orderId, currencyPair)

Cancel a single order

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

ApiClient client = new ApiClient("YOUR_API_KEY", "YOUR_API_SECRET");
// uncomment the next line if testing the API with other host
// apiClient.setBasePath("https://some-other-host");
SpotApi apiInstance = new SpotApi(client);
String orderId = "12345"; // String | ID returned on order successfully being created
String currencyPair = "BTC_USDT"; // String | Currency pair
try {
    Order result = apiInstance.cancelOrder(orderId, currencyPair);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#cancelOrder");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
orderId String ID returned on order successfully being created
currencyPair String Currency pair

Return type

Order

Authorization

Authentication with API key and secret is required

HTTP request headers

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

cancelOrders

List<Order> cancelOrders(currencyPair, side, account)

Cancel all `open` orders in specified currency pair

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

ApiClient client = new ApiClient("YOUR_API_KEY", "YOUR_API_SECRET");
// uncomment the next line if testing the API with other host
// apiClient.setBasePath("https://some-other-host");
SpotApi apiInstance = new SpotApi(client);
String currencyPair = "BTC_USDT"; // String | Currency pair
String side = "sell"; // String | All bids or asks. Both included in not specified
String account = "spot"; // String | Specify account type. Default to all account types being included
try {
    List<Order> result = apiInstance.cancelOrders(currencyPair, side, account);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#cancelOrders");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
currencyPair String Currency pair
side String All bids or asks. Both included in not specified [optional] [enum: buy, sell]
account String Specify account type. Default to all account types being included [optional] [enum: spot, margin]

Return type

List<Order>

Authorization

Authentication with API key and secret is required

HTTP request headers

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

createBatchOrders

List<BatchOrder> createBatchOrders(order)

Create a batch of orders

Batch orders requirements: 1. custom order field `text` is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, e.g. `account` must be identical for all orders

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

ApiClient client = new ApiClient("YOUR_API_KEY", "YOUR_API_SECRET");
// uncomment the next line if testing the API with other host
// apiClient.setBasePath("https://some-other-host");
SpotApi apiInstance = new SpotApi(client);
List<Order> order = new ArrayList<>(); // List<Order> | 
try {
    List<BatchOrder> result = apiInstance.createBatchOrders(order);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#createBatchOrders");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
order List<Order>

Return type

List<BatchOrder>

Authorization

Authentication with API key and secret is required

HTTP request headers

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

createOrder

Order createOrder(order)

Create an order

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

ApiClient client = new ApiClient("YOUR_API_KEY", "YOUR_API_SECRET");
// uncomment the next line if testing the API with other host
// apiClient.setBasePath("https://some-other-host");
SpotApi apiInstance = new SpotApi(client);
Order order = new Order(); // Order | 
try {
    Order result = apiInstance.createOrder(order);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#createOrder");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
order Order

Return type

Order

Authorization

Authentication with API key and secret is required

HTTP request headers

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

getCurrencyPair

CurrencyPair getCurrencyPair(currencyPair)

Get detail of one single order

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

SpotApi apiInstance = new SpotApi();
String currencyPair = "ETH_BTC"; // String | Currency pair
try {
    CurrencyPair result = apiInstance.getCurrencyPair(currencyPair);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#getCurrencyPair");
    e.printStackTrace();
}

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

getOrder

Order getOrder(orderId, currencyPair)

Get a single order

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

ApiClient client = new ApiClient("YOUR_API_KEY", "YOUR_API_SECRET");
// uncomment the next line if testing the API with other host
// apiClient.setBasePath("https://some-other-host");
SpotApi apiInstance = new SpotApi(client);
String orderId = "12345"; // String | ID returned on order successfully being created
String currencyPair = "BTC_USDT"; // String | Currency pair
try {
    Order result = apiInstance.getOrder(orderId, currencyPair);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#getOrder");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
orderId String ID returned on order successfully being created
currencyPair String Currency pair

Return type

Order

Authorization

Authentication with API key and secret is required

HTTP request headers

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

listCandlesticks

List<List<String>> listCandlesticks(currencyPair, limit, interval)

Market candlesticks

Candlestick data will start from (current time - limit * interval), end at current time

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

SpotApi apiInstance = new SpotApi();
String currencyPair = "BTC_USDT"; // String | Currency pair
Integer limit = 100; // Integer | Maximum number of record returned in one list
String interval = "30m"; // String | Interval time between data points
try {
    List<List<String>> result = apiInstance.listCandlesticks(currencyPair, limit, interval);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#listCandlesticks");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
currencyPair String Currency pair
limit Integer Maximum number of record returned in one list [optional] [default to 100]
interval String Interval time between data points [optional] [default to 30m] [enum: 10s, 1m, 5m, 15m, 30m, 1h, 4h, 8h, 1d, 7d]

Return type

List<List<String>>

Authorization

No authorization required

HTTP request headers

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

listCurrencyPairs

List<CurrencyPair> listCurrencyPairs()

List all currency pairs supported

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

SpotApi apiInstance = new SpotApi();
try {
    List<CurrencyPair> result = apiInstance.listCurrencyPairs();
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#listCurrencyPairs");
    e.printStackTrace();
}

Parameters

This endpoint does not need any parameter.

Return type

List<CurrencyPair>

Authorization

No authorization required

HTTP request headers

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

listMyTrades

List<Trade> listMyTrades(currencyPair, limit, page, orderId)

List personal trading history

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

ApiClient client = new ApiClient("YOUR_API_KEY", "YOUR_API_SECRET");
// uncomment the next line if testing the API with other host
// apiClient.setBasePath("https://some-other-host");
SpotApi apiInstance = new SpotApi(client);
String currencyPair = "BTC_USDT"; // String | Currency pair
Integer limit = 100; // Integer | Maximum number of record returned in one list
Integer page = 1; // Integer | Page number
String orderId = "12345"; // String | List all trades of specified order
try {
    List<Trade> result = apiInstance.listMyTrades(currencyPair, limit, page, orderId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#listMyTrades");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
currencyPair String Currency pair
limit Integer Maximum number of record returned in one list [optional] [default to 100]
page Integer Page number [optional] [default to 1]
orderId String List all trades of specified order [optional]

Return type

List<Trade>

Authorization

Authentication with API key and secret is required

HTTP request headers

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

listOrderBook

OrderBook listOrderBook(currencyPair, interval, limit)

Retrieve order book

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

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

SpotApi apiInstance = new SpotApi();
String currencyPair = "BTC_USDT"; // String | Currency pair
String interval = "\"0\""; // String | Order depth. 0 means no aggregation is applied. default to 0
Integer limit = 10; // Integer | Maximum number of order depth data in asks or bids
try {
    OrderBook result = apiInstance.listOrderBook(currencyPair, interval, limit);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#listOrderBook");
    e.printStackTrace();
}

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 Integer Maximum number of order depth data in asks or bids [optional] [default to 10]

Return type

OrderBook

Authorization

No authorization required

HTTP request headers

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

listOrders

List<Order> listOrders(currencyPair, status, page, limit)

List orders

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

ApiClient client = new ApiClient("YOUR_API_KEY", "YOUR_API_SECRET");
// uncomment the next line if testing the API with other host
// apiClient.setBasePath("https://some-other-host");
SpotApi apiInstance = new SpotApi(client);
String currencyPair = "BTC_USDT"; // String | Currency pair
String status = "open"; // String | List orders based on status  `open` - order is waiting to be filled `finished` - order has been filled or cancelled 
Integer page = 1; // Integer | Page number
Integer limit = 100; // Integer | Maximum number of record returned in one list
try {
    List<Order> result = apiInstance.listOrders(currencyPair, status, page, limit);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#listOrders");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
currencyPair String Currency pair
status String List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled [enum: open, finished]
page Integer Page number [optional] [default to 1]
limit Integer Maximum number of record returned in one list [optional] [default to 100]

Return type

List<Order>

Authorization

Authentication with API key and secret is required

HTTP request headers

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

listSpotAccounts

List<SpotAccount> listSpotAccounts(currency)

List spot accounts

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

ApiClient client = new ApiClient("YOUR_API_KEY", "YOUR_API_SECRET");
// uncomment the next line if testing the API with other host
// apiClient.setBasePath("https://some-other-host");
SpotApi apiInstance = new SpotApi(client);
String currency = "BTC"; // String | Retrieved specified currency related data
try {
    List<SpotAccount> result = apiInstance.listSpotAccounts(currency);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#listSpotAccounts");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
currency String Retrieved specified currency related data [optional]

Return type

List<SpotAccount>

Authorization

Authentication with API key and secret is required

HTTP request headers

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

listTickers

List<Ticker> listTickers(currencyPair)

Retrieve ticker information

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

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

SpotApi apiInstance = new SpotApi();
String currencyPair = "BTC_USDT"; // String | Currency pair
try {
    List<Ticker> result = apiInstance.listTickers(currencyPair);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#listTickers");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
currencyPair String Currency pair [optional]

Return type

List<Ticker>

Authorization

No authorization required

HTTP request headers

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

listTrades

List<Trade> listTrades(currencyPair, limit, lastId)

Retrieve market trades

Example

import io.gate.gateapi.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;

import java.io.File;
import java.util.*;

SpotApi apiInstance = new SpotApi();
String currencyPair = "BTC_USDT"; // String | Currency pair
Integer limit = 100; // Integer | Maximum number of record returned in one list
String lastId = "12345"; // String | Specify list staring point using the `id` of last record in previous list-query results
try {
    List<Trade> result = apiInstance.listTrades(currencyPair, limit, lastId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling SpotApi#listTrades");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
currencyPair String Currency pair
limit Integer Maximum number of record returned in one list [optional] [default to 100]
lastId String Specify list staring point using the `id` of last record in previous list-query results [optional]

Return type

List<Trade>

Authorization

No authorization required

HTTP request headers

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