All URIs are relative to https://api.gateio.ws/api/v4
| Method | HTTP request | Description |
|---|---|---|
| queryStockUserAssets | GET /stock/users/assets | Query user assets |
| setStockMarginFeature | PUT /stock/users/margin-feature | Set margin financing availability |
| queryStockSymbols | GET /stock/symbols | Query symbol list |
| queryStockSymbolDetail | GET /stock/symbols/detail | Query symbol details |
| queryStockOrderBook | GET /stock/market/{symbol}/orderbook | Query market order book |
| queryStockOrderList | GET /stock/orders | Query open order list |
| createStockOrder | POST /stock/orders | Create order |
| deleteAllStockOrders | DELETE /stock/orders | Cancel all open orders |
| queryStockOrderHistory | GET /stock/orders/history | Query historical order list |
| queryStockOrderDeals | GET /stock/orders/deals | Query order trade records |
| updateStockOrder | PUT /stock/orders/{order_id} | Modify order |
| deleteStockOrder | DELETE /stock/orders/{order_id} | Cancel order |
| queryStockPositions | GET /stock/positions | Query current position list |
| closeStockPosition | POST /stock/positions/close | Close position |
| queryStockTransactions | GET /stock/transactions | Query transaction records |
| createStockTransaction | POST /stock/transactions | Fund transfer |
| queryStockBalanceRecords | GET /stock/users/balance-records | Query user balance records |
| queryStockExchanges | GET /stock/exchanges | Query supported exchanges |
| queryStockFeeRate | GET /stock/fee-rate | Query fee rates for Japanese and Korean stocks |
UserAssetResp2 queryStockUserAssets().pnlCalcType(pnlCalcType).pnlCalcPrice(pnlCalcPrice).execute();
Query user assets
Rate limit: 5 qps.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
Integer pnlCalcType = 1; // Integer | PnL calculation cost type. Defaults to average cost price when omitted (1 = average cost price, 2 = diluted cost price)
Integer pnlCalcPrice = 1; // Integer | PnL calculation price type. Defaults to intraday price when omitted (1 = intraday price, 2 = latest extended-hours price)
try {
UserAssetResp2 result = apiInstance.queryStockUserAssets()
.pnlCalcType(pnlCalcType)
.pnlCalcPrice(pnlCalcPrice)
.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 StockApi#queryStockUserAssets");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| pnlCalcType | Integer | PnL calculation cost type. Defaults to average cost price when omitted (1 = average cost price, 2 = diluted cost price) | [optional] [enum: 1, 2] |
| pnlCalcPrice | Integer | PnL calculation price type. Defaults to intraday price when omitted (1 = intraday price, 2 = latest extended-hours price) | [optional] [enum: 1, 2] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
SetMarginFeature setStockMarginFeature(tradFiSpotSetMarginFeatureRequest)
Set margin financing availability
Rate limit: 5 requests per second. Enable or disable margin financing for the user.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
TradFiSpotSetMarginFeatureRequest tradFiSpotSetMarginFeatureRequest = new TradFiSpotSetMarginFeatureRequest(); // TradFiSpotSetMarginFeatureRequest |
try {
SetMarginFeature result = apiInstance.setStockMarginFeature(tradFiSpotSetMarginFeatureRequest);
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 StockApi#setStockMarginFeature");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiSpotSetMarginFeatureRequest | TradFiSpotSetMarginFeatureRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
Symbols2 queryStockSymbols().symbols(symbols).exchange(exchange).withDescI18n(withDescI18n).page(page).pageSize(pageSize).execute();
Query symbol list
Rate limit: 5 qps.
// 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.StockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockApi apiInstance = new StockApi(defaultClient);
String symbols = "AAPL,TSLA"; // String | Symbol list, multiple separated by commas
String exchange = "us"; // String | Trading market code. - us: US stocks. - hk: Hong Kong stocks. - kr: South Korean stocks. - jp: Japanese stocks.
Boolean withDescI18n = true; // Boolean | Whether to return multilingual symbol description
Integer page = 1; // Integer | Page number, defaults to 1
Integer pageSize = 100; // Integer | Page size, defaults to 10, max 500; server caps at 500
try {
Symbols2 result = apiInstance.queryStockSymbols()
.symbols(symbols)
.exchange(exchange)
.withDescI18n(withDescI18n)
.page(page)
.pageSize(pageSize)
.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 StockApi#queryStockSymbols");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbols | String | Symbol list, multiple separated by commas | [optional] |
| exchange | String | Trading market code. - us: US stocks. - hk: Hong Kong stocks. - kr: South Korean stocks. - jp: Japanese stocks. | [optional] [enum: us, hk, kr, jp] |
| withDescI18n | Boolean | Whether to return multilingual symbol description | [optional] |
| page | Integer | Page number, defaults to 1 | [optional] |
| pageSize | Integer | Page size, defaults to 10, max 500; server caps at 500 | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
SymbolDetail queryStockSymbolDetail().symbols(symbols).exchange(exchange).page(page).pageSize(pageSize).execute();
Query symbol details
Rate limit: 5 qps.
// 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.StockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockApi apiInstance = new StockApi(defaultClient);
String symbols = "AAPL,TSLA"; // String | Symbol list, multiple separated by commas
String exchange = "us"; // String | Exchange. - us: US stocks. - hk: Hong Kong stocks. - kr: Korean stocks. - jp: Japanese stocks.
Integer page = 1; // Integer | Page number, defaults to 1
Integer pageSize = 100; // Integer | Page size, defaults to 10, max 500; server caps at 500
try {
SymbolDetail result = apiInstance.queryStockSymbolDetail()
.symbols(symbols)
.exchange(exchange)
.page(page)
.pageSize(pageSize)
.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 StockApi#queryStockSymbolDetail");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbols | String | Symbol list, multiple separated by commas | [optional] |
| exchange | String | Exchange. - us: US stocks. - hk: Hong Kong stocks. - kr: Korean stocks. - jp: Japanese stocks. | [optional] [enum: us, hk, kr, jp] |
| page | Integer | Page number, defaults to 1 | [optional] |
| pageSize | Integer | Page size, defaults to 10, max 500; server caps at 500 | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
OrderBook2 queryStockOrderBook(symbol)
Query market order book
Rate limit: 5 qps.
// 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.StockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockApi apiInstance = new StockApi(defaultClient);
String symbol = "AAPL"; // String | Symbol
try {
OrderBook2 result = apiInstance.queryStockOrderBook(symbol);
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 StockApi#queryStockOrderBook");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbol | String | Symbol |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
OrderList2 queryStockOrderList().symbol(symbol).execute();
Query open order list
Rate limit: 5 qps.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
String symbol = "AAPL"; // String | Symbol
try {
OrderList2 result = apiInstance.queryStockOrderList()
.symbol(symbol)
.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 StockApi#queryStockOrderList");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbol | String | Symbol | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
CreateOrder2 createStockOrder(tradFiSpotOrderRequest)
Create order
Rate limit: 5 qps.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
TradFiSpotOrderRequest tradFiSpotOrderRequest = new TradFiSpotOrderRequest(); // TradFiSpotOrderRequest |
try {
CreateOrder2 result = apiInstance.createStockOrder(tradFiSpotOrderRequest);
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 StockApi#createStockOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiSpotOrderRequest | TradFiSpotOrderRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Order placed successfully | - |
| 400 | Request failed | - |
DeleteOrder deleteAllStockOrders()
Cancel all open orders
Rate limit: 5 qps.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
try {
DeleteOrder result = apiInstance.deleteAllStockOrders();
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 StockApi#deleteAllStockOrders");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
OrderHistoryList2 queryStockOrderHistory().symbol(symbol).orderIds(orderIds).beginTime(beginTime).endTime(endTime).side(side).page(page).pageSize(pageSize).execute();
Query historical order list
Rate limit: 5 qps.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
String symbol = "AAPL"; // String | Symbol
String orderIds = "123456,123457"; // String | Order ID list, multiple separated by commas; max 20, each must be a positive integer
Integer beginTime = 1769378400; // Integer | Start time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months.
Integer endTime = 1769464800; // Integer | End time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months.
Integer side = 2; // Integer | Side (1=sell, 2=buy)
Integer page = 1; // Integer | Page number, defaults to 1
Integer pageSize = 100; // Integer | Page size, defaults to 10, max 500; server caps at 500
try {
OrderHistoryList2 result = apiInstance.queryStockOrderHistory()
.symbol(symbol)
.orderIds(orderIds)
.beginTime(beginTime)
.endTime(endTime)
.side(side)
.page(page)
.pageSize(pageSize)
.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 StockApi#queryStockOrderHistory");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| symbol | String | Symbol | [optional] |
| orderIds | String | Order ID list, multiple separated by commas; max 20, each must be a positive integer | [optional] |
| beginTime | Integer | Start time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. | [optional] |
| endTime | Integer | End time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. | [optional] |
| side | Integer | Side (1=sell, 2=buy) | [optional] [enum: 1, 2] |
| page | Integer | Page number, defaults to 1 | [optional] |
| pageSize | Integer | Page size, defaults to 10, max 500; server caps at 500 | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
OrderDealList queryStockOrderDeals(orderId).page(page).pageSize(pageSize).execute();
Query order trade records
Rate limit: 5 requests per second. Query the current user's trade records by order ID. `price`, `value`, and `fee` are denominated in the instrument trading currency (for example, USD for US stocks, HKD for Hong Kong stocks, JPY for Japanese stocks, and KRW for Korean stocks). `role` returns `maker` or `taker`.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
Long orderId = 123456L; // Long | Order ID
Integer page = 1; // Integer | Page number, defaults to 1
Integer pageSize = 20; // Integer | Records per page. Defaults to 10, maximum 100. The server caps values greater than 100 at 100.
try {
OrderDealList result = apiInstance.queryStockOrderDeals(orderId)
.page(page)
.pageSize(pageSize)
.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 StockApi#queryStockOrderDeals");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | Long | Order ID | |
| page | Integer | Page number, defaults to 1 | [optional] |
| pageSize | Integer | Records per page. Defaults to 10, maximum 100. The server caps values greater than 100 at 100. | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
UpdateOrder2 updateStockOrder(orderId, tradFiSpotOrderUpdateRequest)
Modify order
Rate limit: 5 qps.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
Long orderId = 123456L; // Long | Order ID
TradFiSpotOrderUpdateRequest tradFiSpotOrderUpdateRequest = new TradFiSpotOrderUpdateRequest(); // TradFiSpotOrderUpdateRequest |
try {
UpdateOrder2 result = apiInstance.updateStockOrder(orderId, tradFiSpotOrderUpdateRequest);
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 StockApi#updateStockOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | Long | Order ID | |
| tradFiSpotOrderUpdateRequest | TradFiSpotOrderUpdateRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
DeleteOrder deleteStockOrder(orderId)
Cancel order
Rate limit: 5 qps.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
Long orderId = 123456L; // Long | Order ID
try {
DeleteOrder result = apiInstance.deleteStockOrder(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 StockApi#deleteStockOrder");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| orderId | Long | Order ID |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
PositionList2 queryStockPositions().pnlCalcType(pnlCalcType).pnlCalcPrice(pnlCalcPrice).symbol(symbol).exchange(exchange).execute();
Query current position list
Rate limit: 5 qps.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
Integer pnlCalcType = 1; // Integer | PnL calculation cost type. Defaults to average cost price when omitted (1 = average cost price, 2 = diluted cost price)
Integer pnlCalcPrice = 1; // Integer | PnL calculation price type. Defaults to intraday price when omitted (1 = intraday price, 2 = latest extended-hours price)
String symbol = "AAPL"; // String | Symbol
String exchange = "us"; // String | Exchange. - us: US stocks. - hk: Hong Kong stocks. - kr: Korean stocks. - jp: Japanese stocks.
try {
PositionList2 result = apiInstance.queryStockPositions()
.pnlCalcType(pnlCalcType)
.pnlCalcPrice(pnlCalcPrice)
.symbol(symbol)
.exchange(exchange)
.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 StockApi#queryStockPositions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| pnlCalcType | Integer | PnL calculation cost type. Defaults to average cost price when omitted (1 = average cost price, 2 = diluted cost price) | [optional] [enum: 1, 2] |
| pnlCalcPrice | Integer | PnL calculation price type. Defaults to intraday price when omitted (1 = intraday price, 2 = latest extended-hours price) | [optional] [enum: 1, 2] |
| symbol | String | Symbol | [optional] |
| exchange | String | Exchange. - us: US stocks. - hk: Hong Kong stocks. - kr: Korean stocks. - jp: Japanese stocks. | [optional] [enum: us, hk, kr, jp] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
ClosePosition closeStockPosition(tradFiSpotClosePositionRequest)
Close position
Rate limit: 5 qps.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
TradFiSpotClosePositionRequest tradFiSpotClosePositionRequest = new TradFiSpotClosePositionRequest(); // TradFiSpotClosePositionRequest |
try {
ClosePosition result = apiInstance.closeStockPosition(tradFiSpotClosePositionRequest);
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 StockApi#closeStockPosition");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiSpotClosePositionRequest | TradFiSpotClosePositionRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
TransactionList2 queryStockTransactions().beginTime(beginTime).endTime(endTime).refId(refId).type(type).page(page).pageSize(pageSize).execute();
Query transaction records
Rate limit: 5 qps. Query stock account transaction records, including fund transfers, trades, fees, dividends, rewards, and stock transfers.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
Long beginTime = 1769378400L; // Long | Start time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months.
Long endTime = 1769464800L; // Long | End time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months.
String refId = "transfer-202607070001"; // String | Business idempotent ID. When ref_id is provided, the server queries by ref_id, ignoring other parameters such as begin_time, end_time, type, page, page_size
String type = "deposit"; // String | 流水类型。 - deposit: 资金转入,从现货账户转入到股票账户。 - withdraw: 资金转出,从股票账户转出到现货账户。 - fee: 交易手续费。 - dividend: 分红派息。 - sell: 卖出股票入账。 - buy: 买入股票出账。 - award: 空投奖励。 - stock_transfer_in: 股票转入。 - stock_transfer_out: 股票转出。
Integer page = 1; // Integer | Page number, defaults to 1
Integer pageSize = 100; // Integer | Page size, defaults to 10, max 500; server caps at 500
try {
TransactionList2 result = apiInstance.queryStockTransactions()
.beginTime(beginTime)
.endTime(endTime)
.refId(refId)
.type(type)
.page(page)
.pageSize(pageSize)
.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 StockApi#queryStockTransactions");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| beginTime | Long | Start time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. | [optional] |
| endTime | Long | End time (Unix timestamp, seconds). When both begin_time and end_time are provided, end_time must be >= begin_time, query range must not exceed 3 months. | [optional] |
| refId | String | Business idempotent ID. When ref_id is provided, the server queries by ref_id, ignoring other parameters such as begin_time, end_time, type, page, page_size | [optional] |
| type | String | 流水类型。 - deposit: 资金转入,从现货账户转入到股票账户。 - withdraw: 资金转出,从股票账户转出到现货账户。 - fee: 交易手续费。 - dividend: 分红派息。 - sell: 卖出股票入账。 - buy: 买入股票出账。 - award: 空投奖励。 - stock_transfer_in: 股票转入。 - stock_transfer_out: 股票转出。 | [optional] [enum: deposit, withdraw, fee, dividend, sell, buy, award, stock_transfer_in, stock_transfer_out] |
| page | Integer | Page number, defaults to 1 | [optional] |
| pageSize | Integer | Page size, defaults to 10, max 500; server caps at 500 | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
CreateTransaction2 createStockTransaction(tradFiSpotTransactionRequest)
Fund transfer
Rate limit: 5 qps. Fund transfer moves USDT between the spot account and the stock account. - deposit: transfer from the spot account to the stock account. - withdraw: transfer from the stock account to the spot 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
TradFiSpotTransactionRequest tradFiSpotTransactionRequest = new TradFiSpotTransactionRequest(); // TradFiSpotTransactionRequest |
try {
CreateTransaction2 result = apiInstance.createStockTransaction(tradFiSpotTransactionRequest);
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 StockApi#createStockTransaction");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| tradFiSpotTransactionRequest | TradFiSpotTransactionRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
BalanceRecordList queryStockBalanceRecords().type(type).business(business).symbol(symbol).beginTime(beginTime).endTime(endTime).startId(startId).sortDirection(sortDirection).includeDetail(includeDetail).page(page).pageSize(pageSize).execute();
Query user balance records
Rate limit: 5 requests per second. Query the current user's raw balance records. User scope is derived from the request headers; a query parameter `user_id` is not supported. - `type` and `business` support multiple comma-separated values. - `begin_time` and `end_time` filter record creation time in seconds. When both are provided, `end_time` must be greater than `begin_time`. - Results are always sorted by primary key `id`; `sort_direction` accepts `asc` or `desc`. The default is `id desc`. With `start_id` and no `sort_direction`, the order is `id asc`, and only records with `id > start_id` are returned for incremental retrieval. - `detail` is omitted by default and returned only when `include_detail=true`. - `stock_change` is parsed from `detail.amount` for stock quantity records; `balance` is a cash balance snapshot, not a stock position balance.
// 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.StockApi;
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");
StockApi apiInstance = new StockApi(defaultClient);
String type = "deposit,fee"; // String | Record types, separated by commas
String business = "transfer,trade"; // String | Business identifiers, separated by commas
String symbol = "AAPL"; // String | Symbol
Long beginTime = 1769378400L; // Long | Start time (Unix timestamp in seconds). When both begin_time and end_time are provided, end_time must be greater than begin_time.
Long endTime = 1769464800L; // Long | End time (Unix timestamp in seconds). When both begin_time and end_time are provided, end_time must be greater than begin_time.
Long startId = 1000L; // Long | Starting primary key ID for incremental queries. Only records with a greater id are returned.
String sortDirection = "desc"; // String | Sort direction by primary key id. - asc: Ascending. - desc: Descending. When omitted, defaults to desc without start_id, or asc with start_id.
Boolean includeDetail = false; // Boolean | Whether to return the raw detail field; defaults to false when omitted
Integer page = 1; // Integer | Page number, defaults to 1
Integer pageSize = 20; // Integer | Records per page. Defaults to 10, maximum 100. The server caps values greater than 100 at 100.
try {
BalanceRecordList result = apiInstance.queryStockBalanceRecords()
.type(type)
.business(business)
.symbol(symbol)
.beginTime(beginTime)
.endTime(endTime)
.startId(startId)
.sortDirection(sortDirection)
.includeDetail(includeDetail)
.page(page)
.pageSize(pageSize)
.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 StockApi#queryStockBalanceRecords");
System.err.println("Status code: " + e.getCode());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}| Name | Type | Description | Notes |
|---|---|---|---|
| type | String | Record types, separated by commas | [optional] |
| business | String | Business identifiers, separated by commas | [optional] |
| symbol | String | Symbol | [optional] |
| beginTime | Long | Start time (Unix timestamp in seconds). When both begin_time and end_time are provided, end_time must be greater than begin_time. | [optional] |
| endTime | Long | End time (Unix timestamp in seconds). When both begin_time and end_time are provided, end_time must be greater than begin_time. | [optional] |
| startId | Long | Starting primary key ID for incremental queries. Only records with a greater id are returned. | [optional] |
| sortDirection | String | Sort direction by primary key id. - asc: Ascending. - desc: Descending. When omitted, defaults to desc without start_id, or asc with start_id. | [optional] [enum: asc, desc] |
| includeDetail | Boolean | Whether to return the raw detail field; defaults to false when omitted | [optional] |
| page | Integer | Page number, defaults to 1 | [optional] |
| pageSize | Integer | Records per page. Defaults to 10, maximum 100. The server caps values greater than 100 at 100. | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request success | - |
| 400 | Request failed | - |
Exchanges queryStockExchanges()
Query supported exchanges
Query stock spot supported exchanges and whether stock transfers are supported. Rate limit: 5 qps.
// 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.StockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockApi apiInstance = new StockApi(defaultClient);
try {
Exchanges result = apiInstance.queryStockExchanges();
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 StockApi#queryStockExchanges");
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 | Request success | - |
| 400 | Request failed | - |
FeeRate queryStockFeeRate()
Query fee rates for Japanese and Korean stocks
Query fee rates for Japanese and Korean stocks. Rate limit: 5 qps.
// 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.StockApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://api.gateio.ws/api/v4");
StockApi apiInstance = new StockApi(defaultClient);
try {
FeeRate result = apiInstance.queryStockFeeRate();
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 StockApi#queryStockFeeRate");
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 | Request success | - |
| 400 | Request failed | - |