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 currency pair |
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 |
getFee | GET /spot/fee | Query user trading fee rates |
getBatchSpotFee | GET /spot/batch_fee | Query a batch of user trading fee rates |
listSpotAccounts | GET /spot/accounts | List spot accounts |
listSpotAccountBook | GET /spot/account_book | Query account book |
createBatchOrders | POST /spot/batch_orders | Create a batch of 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 an order |
cancelOrders | DELETE /spot/orders | Cancel all `open` orders in specified currency pair |
cancelBatchOrders | POST /spot/cancel_batch_orders | Cancel a batch of orders with an ID list |
getOrder | GET /spot/orders/{order_id} | Get a single order |
cancelOrder | DELETE /spot/orders/{order_id} | Cancel a single order |
amendOrder | PATCH /spot/orders/{order_id} | Amend an order |
listMyTrades | GET /spot/my_trades | List personal trading history |
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 |
listSpotPriceTriggeredOrders | GET /spot/price_orders | Retrieve running auto order list |
createSpotPriceTriggeredOrder | POST /spot/price_orders | Create a price-triggered order |
cancelSpotPriceTriggeredOrderList | DELETE /spot/price_orders | Cancel all open orders |
getSpotPriceTriggeredOrder | GET /spot/price_orders/{order_id} | Get a price-triggered order |
cancelSpotPriceTriggeredOrder | DELETE /spot/price_orders/{order_id} | cancel a price-triggered order |
List<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>`.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
SpotApi apiInstance = new SpotApi(defaultClient);
try {
List<Currency> result = apiInstance.listCurrencies();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listCurrencies");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
Currency getCurrency(currency)
Get details of a specific currency
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
SpotApi apiInstance = new SpotApi(defaultClient);
String currency = "GT"; // String | Currency name
try {
Currency result = apiInstance.getCurrency(currency);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#getCurrency");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currency | String | Currency name |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
List<CurrencyPair> listCurrencyPairs()
List all currency pairs supported
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
SpotApi apiInstance = new SpotApi(defaultClient);
try {
List<CurrencyPair> result = apiInstance.listCurrencyPairs();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listCurrencyPairs");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | All currency pairs retrieved | - |
CurrencyPair getCurrencyPair(currencyPair)
Get details of a specifc currency pair
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
SpotApi apiInstance = new SpotApi(defaultClient);
String currencyPair = "ETH_BTC"; // String | Currency pair
try {
CurrencyPair result = apiInstance.getCurrencyPair(currencyPair);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#getCurrencyPair");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | String | Currency pair |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
List<Ticker> listTickers().currencyPair(currencyPair).timezone(timezone).execute();
Retrieve ticker information
Return only related data if `currency_pair` is specified; otherwise return all of them
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
SpotApi apiInstance = new SpotApi(defaultClient);
String currencyPair = "BTC_USDT"; // String | Currency pair
String timezone = "utc0"; // String | Timezone
try {
List<Ticker> result = apiInstance.listTickers()
.currencyPair(currencyPair)
.timezone(timezone)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listTickers");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | String | Currency pair | [optional] |
timezone | String | Timezone | [optional] [enum: utc0, utc8, all] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
OrderBook listOrderBook(currencyPair).interval(interval).limit(limit).withId(withId).execute();
Retrieve order book
Order book will be sorted by price from high to low on bids; low to high on asks
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
SpotApi apiInstance = new SpotApi(defaultClient);
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
Boolean withId = false; // Boolean | Return order book ID
try {
OrderBook result = apiInstance.listOrderBook(currencyPair)
.interval(interval)
.limit(limit)
.withId(withId)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
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] |
withId | Boolean | Return order book ID | [optional] [default to false] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
List<Trade> listTrades(currencyPair).limit(limit).lastId(lastId).reverse(reverse).from(from).to(to).page(page).execute();
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.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
SpotApi apiInstance = new SpotApi(defaultClient);
String currencyPair = "BTC_USDT"; // String | Currency pair
Integer limit = 100; // Integer | Maximum number of records to be returned in a single list. Default: 100, Minimum: 1, Maximum: 1000
String lastId = "12345"; // String | Specify list staring point using the `id` of last record in previous list-query results
Boolean 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.
Long from = 1627706330L; // Long | Start timestamp of the query
Long to = 1635329650L; // Long | Time range ending, default to current time
Integer page = 1; // Integer | Page number
try {
List<Trade> result = apiInstance.listTrades(currencyPair)
.limit(limit)
.lastId(lastId)
.reverse(reverse)
.from(from)
.to(to)
.page(page)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | String | Currency pair | |
limit | Integer | Maximum number of records to be returned in a single list. Default: 100, Minimum: 1, Maximum: 1000 | [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 | Long | Start timestamp of the query | [optional] |
to | Long | Time range ending, default to current time | [optional] |
page | Integer | Page number | [optional] [default to 1] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
List<List<String>> listCandlesticks(currencyPair).limit(limit).from(from).to(to).interval(interval).execute();
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
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
SpotApi apiInstance = new SpotApi(defaultClient);
String currencyPair = "BTC_USDT"; // String | Currency pair
Integer limit = 100; // Integer | Maximum recent data points to return. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected.
Long from = 1546905600L; // Long | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified
Long to = 1546935600L; // Long | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
String interval = "30m"; // String | Interval time between data points. Note that `30d` means 1 natual month, not 30 days
try {
List<List<String>> result = apiInstance.listCandlesticks(currencyPair)
.limit(limit)
.from(from)
.to(to)
.interval(interval)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listCandlesticks");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | String | Currency pair | |
limit | Integer | 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 | Long | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] |
to | Long | 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] [enum: 10s, 1m, 5m, 15m, 30m, 1h, 4h, 8h, 1d, 7d, 30d] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
TradeFee getFee().currencyPair(currencyPair).execute();
Query user trading fee rates
This API is deprecated in favour of new fee retrieving API `/wallet/fee`.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String currencyPair = "BTC_USDT"; // String | Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs
try {
TradeFee result = apiInstance.getFee()
.currencyPair(currencyPair)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#getFee");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | String | Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
Map<String, SpotFee> getBatchSpotFee(currencyPairs)
Query a batch of user trading fee rates
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String currencyPairs = "BTC_USDT,ETH_USDT"; // String | A request can only query up to 50 currency pairs
try {
Map<String, SpotFee> result = apiInstance.getBatchSpotFee(currencyPairs);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#getBatchSpotFee");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currencyPairs | String | A request can only query up to 50 currency pairs |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
List<SpotAccount> listSpotAccounts().currency(currency).execute();
List spot accounts
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String currency = "BTC"; // String | Retrieve data of the specified currency
try {
List<SpotAccount> result = apiInstance.listSpotAccounts()
.currency(currency)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listSpotAccounts");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currency | String | Retrieve data of the specified currency | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
List<SpotAccountBook> listSpotAccountBook().currency(currency).from(from).to(to).page(page).limit(limit).type(type).execute();
Query account book
Record time range cannot exceed 30 days
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String currency = "BTC"; // String | Retrieve data of the specified currency
Long from = 1627706330L; // Long | Start timestamp of the query
Long to = 1635329650L; // Long | Time range ending, default to current time
Integer page = 1; // Integer | Page number
Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
String type = "lend"; // String | Only retrieve changes of the specified type. All types will be returned if not specified.
try {
List<SpotAccountBook> result = apiInstance.listSpotAccountBook()
.currency(currency)
.from(from)
.to(to)
.page(page)
.limit(limit)
.type(type)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listSpotAccountBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currency | String | Retrieve data of the specified currency | [optional] |
from | Long | Start timestamp of the query | [optional] |
to | Long | Time range ending, default to current time | [optional] |
page | Integer | Page number | [optional] [default to 1] |
limit | Integer | Maximum number of records to be returned in a single list | [optional] [default to 100] |
type | String | Only retrieve changes of the specified type. All types will be returned if not specified. | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
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 10 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. `account` must be identical for all orders
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
List<Order> order = Arrays.asList(); // List<Order> |
try {
List<BatchOrder> result = apiInstance.createBatchOrders(order);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#createBatchOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
order | List<Order> |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Request is completed | - |
List<OpenOrders> listAllOpenOrders().page(page).limit(limit).account(account).execute();
List all open orders
List open orders in all currency pairs. Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned. Spot,portfolio and margin orders are returned by default. To list cross margin orders, `account` must be set to `cross_margin`
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
Integer page = 1; // Integer | Page number
Integer limit = 100; // Integer | Maximum number of records returned in one page in each currency pair
String account = "cross_margin"; // String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
try {
List<OpenOrders> result = apiInstance.listAllOpenOrders()
.page(page)
.limit(limit)
.account(account)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listAllOpenOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
page | Integer | Page number | [optional] [default to 1] |
limit | Integer | Maximum number of records returned in one page in each currency pair | [optional] [default to 100] |
account | String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
Order createCrossLiquidateOrder(liquidateOrder)
close position when cross-currency is disabled
Currently, only cross-margin accounts are supported to close position when cross currencies are disabled. Maximum buy quantity = (unpaid principal and interest - currency balance - the amount of the currency in the order book) / 0.998
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
LiquidateOrder liquidateOrder = new LiquidateOrder(); // LiquidateOrder |
try {
Order result = apiInstance.createCrossLiquidateOrder(liquidateOrder);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#createCrossLiquidateOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
liquidateOrder | LiquidateOrder |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
201 | order created | - |
List<Order> listOrders(currencyPair, status).page(page).limit(limit).account(account).from(from).to(to).side(side).execute();
List orders
Spot, portfolio and margin orders are returned by default. If cross margin orders are needed, `account` must be set to `cross_margin` When `status` is `open`, i.e., listing open orders, only pagination parameters `page` and `limit` are supported and `limit` cannot be larger than 100. Query by `side` and time range parameters `from` and `to` are not supported. When `status` is `finished`, i.e., listing finished orders, pagination parameters, time range parameters `from` and `to`, and `side` parameters are all supported. Time range parameters are handled as order finish time.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String currencyPair = "BTC_USDT"; // String | Retrieve results with specified currency pair. It is required for open orders, but optional for finished ones.
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 records to be returned. If `status` is `open`, maximum of `limit` is 100
String account = "cross_margin"; // String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
Long from = 1627706330L; // Long | Start timestamp of the query
Long to = 1635329650L; // Long | Time range ending, default to current time
String side = "sell"; // String | All bids or asks. Both included if not specified
try {
List<Order> result = apiInstance.listOrders(currencyPair, status)
.page(page)
.limit(limit)
.account(account)
.from(from)
.to(to)
.side(side)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | String | Retrieve results with specified currency pair. It is required for open orders, but optional for finished ones. | |
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 records to be returned. If `status` is `open`, maximum of `limit` is 100 | [optional] [default to 100] |
account | String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
from | Long | Start timestamp of the query | [optional] |
to | Long | Time range ending, default to current time | [optional] |
side | String | All bids or asks. Both included if not specified | [optional] [enum: buy, sell] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
Order createOrder(order)
Create an order
You can place orders with spot, portfolio, margin or cross margin account through setting the `account `field. It defaults to `spot`, which means spot account is used to place orders.if the user is in portfolio mode, it defaults to the portfolio account. When margin account is used, i.e., `account` is `margin`, `auto_borrow` field can be set to `true` to enable the server to borrow the amount lacked using `POST /margin/loans` when your account's balance is not enough. Whether margin orders' fill will be used to repay margin loans automatically is determined by the auto repayment setting in your margin account, which can be updated or queried using `/margin/auto_repay` API. When cross margin account is used, i.e., `account` is `cross_margin`, `auto_borrow` can also be enabled to achieve borrowing the insufficient amount automatically if cross account's balance is not enough. But it differs from margin account that automatic repayment is determined by order's `auto_repay` field and only current order's fill will be used to repay cross margin loans. Automatic repayment will be triggered when the order is finished, i.e., its status is either `cancelled` or `closed`. Order status An order waiting to be filled is `open`, and it stays `open` until it is filled totally. If fully filled, order is finished and its status turns to `closed`.If the order is cancelled before it is totally filled, whether or not partially filled, its status is `cancelled`. Iceberg order `iceberg` field can be used to set the amount shown. Set to `-1` to hide the order completely. Note that the hidden part's fee will be charged using taker's fee rate. Self Trade Prevention - Set `stp_act` to decide the strategy of self-trade prevention. For detailed usage, refer to the `stp_act` parameter in request body
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
Order order = new Order(); // Order |
try {
Order result = apiInstance.createOrder(order);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#createOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
order | Order |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
201 | Order created. | - |
List<Order> cancelOrders(currencyPair, side, account)
Cancel all `open` orders in specified currency pair
If `account` is not set, all open orders, including spot, portfolio, margin and cross margin ones, will be cancelled. You can set `account` to cancel only orders within the specified account
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String currencyPair = "BTC_USDT"; // String | Currency pair
String side = "sell"; // String | All bids or asks. Both included if not specified
String account = "spot"; // String | Specify account type - classic account:Default to all account types being included - portfolio margin account:`cross_margin` only
try {
List<Order> result = apiInstance.cancelOrders(currencyPair, side, account);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#cancelOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | String | Currency pair | |
side | String | All bids or asks. Both included if not specified | [optional] [enum: buy, sell] |
account | String | Specify account type - classic account:Default to all account types being included - portfolio margin account:`cross_margin` only | [optional] [enum: spot, margin, cross_margin] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Batch cancellation request accepted. Query order status by listing orders | - |
List<CancelOrderResult> cancelBatchOrders(cancelBatchOrder)
Cancel a batch of orders with an ID list
Multiple currency pairs can be specified, but maximum 20 orders are allowed per request
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
List<CancelBatchOrder> cancelBatchOrder = Arrays.asList(); // List<CancelBatchOrder> |
try {
List<CancelOrderResult> result = apiInstance.cancelBatchOrders(cancelBatchOrder);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#cancelBatchOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
cancelBatchOrder | List<CancelBatchOrder> |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Batch cancellation completed | - |
Order getOrder(orderId, currencyPair, account)
Get a single order
Spot, portfolio and margin orders are queried by default. If cross margin orders are needed or portfolio margin account are used, account must be set to cross_margin.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String orderId = "12345"; // String | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted.
String currencyPair = "BTC_USDT"; // String | Currency pair
String account = "cross_margin"; // String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
try {
Order result = apiInstance.getOrder(orderId, currencyPair, account);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#getOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
orderId | String | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. | |
currencyPair | String | Currency pair | |
account | String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Detail retrieved | - |
Order cancelOrder(orderId, currencyPair, account)
Cancel a single order
Spot,portfolio and margin orders are cancelled by default. If trying to cancel cross margin orders or portfolio margin account are used, account must be set to cross_margin
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String orderId = "12345"; // String | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted.
String currencyPair = "BTC_USDT"; // String | Currency pair
String account = "cross_margin"; // String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
try {
Order result = apiInstance.cancelOrder(orderId, currencyPair, account);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#cancelOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
orderId | String | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. | |
currencyPair | String | Currency pair | |
account | String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Order cancelled | - |
Order amendOrder(orderId, currencyPair, orderPatch, account)
Amend an order
By default, the orders of spot, portfolio and margin account are updated. If you need to modify orders of the `cross-margin` account, you must specify account as `cross_margin`. For portfolio margin account, only `cross_margin` account is supported. Currently, only supports modification of `price` or `amount` fields. Regarding rate limiting: modify order and create order sharing rate limiting rules. Regarding matching priority: Only reducing the quantity without modifying the priority of matching, altering the price or increasing the quantity will adjust the priority to the new price at the end Note: If the modified amount is less than the fill amount, the order will be cancelled.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String orderId = "12345"; // String | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted.
String currencyPair = "BTC_USDT"; // String | Currency pair
OrderPatch orderPatch = new OrderPatch(); // OrderPatch |
String account = "cross_margin"; // String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
try {
Order result = apiInstance.amendOrder(orderId, currencyPair, orderPatch, account);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#amendOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
orderId | String | Order ID returned, or user custom ID(i.e., `text` field). Operations based on custom ID can only be checked when the order is in orderbook. When the order is finished, it can be checked within 1 hour after the end of the order. After that, only order ID is accepted. | |
currencyPair | String | Currency pair | |
orderPatch | OrderPatch | ||
account | String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Updated | - |
List<Trade> listMyTrades().currencyPair(currencyPair).limit(limit).page(page).orderId(orderId).account(account).from(from).to(to).execute();
List personal trading history
Spot,portfolio and margin trades are queried by default. If cross margin trades are needed, `account` must be set to `cross_margin` You can also set `from` and(or) `to` to query by time range. If you don't specify `from` and/or `to` parameters, only the last 7 days of data will be retured. The range of `from` and `to` is not alloed to exceed 30 days. Time range parameters are handled as order finish time.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String currencyPair = "BTC_USDT"; // String | Retrieve results with specified currency pair
Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
Integer page = 1; // Integer | Page number
String orderId = "12345"; // String | Filter trades with specified order ID. `currency_pair` is also required if this field is present
String account = "cross_margin"; // String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only
Long from = 1627706330L; // Long | Start timestamp of the query
Long to = 1635329650L; // Long | Time range ending, default to current time
try {
List<Trade> result = apiInstance.listMyTrades()
.currencyPair(currencyPair)
.limit(limit)
.page(page)
.orderId(orderId)
.account(account)
.from(from)
.to(to)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listMyTrades");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
currencyPair | String | Retrieve results with specified currency pair | [optional] |
limit | Integer | Maximum number of records to be returned in a single list | [optional] [default to 100] |
page | Integer | 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] |
account | String | Specify operation account. Default to spot ,portfolio and margin account if not specified. Set to `cross_margin` to operate against margin account. Portfolio margin account must set to `cross_margin` only | [optional] |
from | Long | Start timestamp of the query | [optional] |
to | Long | Time range ending, default to current time | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
SystemTime getSystemTime()
Get server current time
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
SpotApi apiInstance = new SpotApi(defaultClient);
try {
SystemTime result = apiInstance.getSystemTime();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#getSystemTime");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successfully retrieved | - |
TriggerTime countdownCancelAllSpot(countdownCancelAllSpotTask)
Countdown cancel orders
When the timeout set by the user is reached, if there is no cancel or set a new countdown, the related pending orders will be automatically cancelled. This endpoint can be called repeatedly to set a new countdown or cancel the countdown. For example, call this endpoint at 30s intervals, each countdown`timeout` is set to 30s. If this endpoint is not called again within 30 seconds, all pending orders on the specified `market` will be automatically cancelled, if no `market` is specified, all market pending orders will be cancelled. If the `timeout` is set to 0 within 30 seconds, the countdown timer will expire and the cacnel function will be cancelled.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
CountdownCancelAllSpotTask countdownCancelAllSpotTask = new CountdownCancelAllSpotTask(); // CountdownCancelAllSpotTask |
try {
TriggerTime result = apiInstance.countdownCancelAllSpot(countdownCancelAllSpotTask);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#countdownCancelAllSpot");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
countdownCancelAllSpotTask | CountdownCancelAllSpotTask |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Set countdown successfully | - |
List<AmendOrderResult> amendBatchOrders(batchAmendItem)
Batch modification of orders
Default modification of orders for spot, portfolio, and margin accounts. To modify orders for a cross margin account, the `account` parameter must be specified as `cross_margin`. For portfolio margin accounts, the `account` parameter can only be specified as `cross_margin`. Currently, only modifications to price or quantity (choose one) are supported. When modifying unfinished orders, a maximum of 5 orders can be batch-modified in one request. The request parameters should be passed in an array format. During batch modification, if one order modification fails, the modification process will continue with the next order. After execution, the response will include corresponding failure information for the failed orders. The sequence of calling for batch order modification should be consistent with the order in the order list. The response content order for batch order modification will also be consistent with the order in the order list.
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
List<BatchAmendItem> batchAmendItem = Arrays.asList(); // List<BatchAmendItem> |
try {
List<AmendOrderResult> result = apiInstance.amendBatchOrders(batchAmendItem);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#amendBatchOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
batchAmendItem | List<BatchAmendItem> |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Order modification executed successfully | - |
List<SpotPriceTriggeredOrder> listSpotPriceTriggeredOrders(status).market(market).account(account).limit(limit).offset(offset).execute();
Retrieve running auto order list
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String status = "status_example"; // String | Only list the orders with this status
String market = "BTC_USDT"; // String | Currency pair
String account = "account_example"; // String | Trading account type. Portfolio margin account must set to `cross_margin`
Integer limit = 100; // Integer | Maximum number of records to be returned in a single list
Integer offset = 0; // Integer | List offset, starting from 0
try {
List<SpotPriceTriggeredOrder> result = apiInstance.listSpotPriceTriggeredOrders(status)
.market(market)
.account(account)
.limit(limit)
.offset(offset)
.execute();
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#listSpotPriceTriggeredOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
status | String | Only list the orders with this status | [enum: open, finished] |
market | String | Currency pair | [optional] |
account | String | Trading account type. Portfolio margin account must set to `cross_margin` | [optional] [enum: normal, margin, cross_margin] |
limit | Integer | Maximum number of records to be returned in a single list | [optional] [default to 100] |
offset | Integer | List offset, starting from 0 | [optional] [default to 0] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | List retrieved | - |
TriggerOrderResponse createSpotPriceTriggeredOrder(spotPriceTriggeredOrder)
Create a price-triggered order
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
SpotPriceTriggeredOrder spotPriceTriggeredOrder = new SpotPriceTriggeredOrder(); // SpotPriceTriggeredOrder |
try {
TriggerOrderResponse result = apiInstance.createSpotPriceTriggeredOrder(spotPriceTriggeredOrder);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#createSpotPriceTriggeredOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
spotPriceTriggeredOrder | SpotPriceTriggeredOrder |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
201 | Order created | - |
List<SpotPriceTriggeredOrder> cancelSpotPriceTriggeredOrderList(market, account)
Cancel all open orders
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String market = "BTC_USDT"; // String | Currency pair
String account = "account_example"; // String | Trading account type. Portfolio margin account must set to `cross_margin`
try {
List<SpotPriceTriggeredOrder> result = apiInstance.cancelSpotPriceTriggeredOrderList(market, account);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#cancelSpotPriceTriggeredOrderList");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
market | String | Currency pair | [optional] |
account | String | Trading account type. Portfolio margin account must set to `cross_margin` | [optional] [enum: normal, margin, cross_margin] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Batch cancellation request accepted. Query order status by listing orders | - |
SpotPriceTriggeredOrder getSpotPriceTriggeredOrder(orderId)
Get a price-triggered order
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String orderId = "orderId_example"; // String | Retrieve the data of the order with the specified ID
try {
SpotPriceTriggeredOrder result = apiInstance.getSpotPriceTriggeredOrder(orderId);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#getSpotPriceTriggeredOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
orderId | String | Retrieve the data of the order with the specified ID |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Auto order detail | - |
SpotPriceTriggeredOrder cancelSpotPriceTriggeredOrder(orderId)
cancel a price-triggered order
// Import classes:
import io.gate.gateapi.ApiClient;
import io.gate.gateapi.ApiException;
import io.gate.gateapi.Configuration;
import io.gate.gateapi.GateApiException;
import io.gate.gateapi.auth.*;
import io.gate.gateapi.models.*;
import io.gate.gateapi.api.SpotApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
// Configure APIv4 authorization: apiv4
defaultClient.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
SpotApi apiInstance = new SpotApi(defaultClient);
String orderId = "orderId_example"; // String | Retrieve the data of the order with the specified ID
try {
SpotPriceTriggeredOrder result = apiInstance.cancelSpotPriceTriggeredOrder(orderId);
System.out.println(result);
} catch (GateApiException e) {
System.err.println(String.format("Gate api exception, label: %s, message: %s", e.getErrorLabel(), e.getMessage()));
e.printStackTrace();
} catch (ApiException e) {
System.err.println("Exception when calling SpotApi#cancelSpotPriceTriggeredOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
orderId | String | Retrieve the data of the order with the specified ID |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Auto order detail | - |