All URIs are relative to https://api.gateio.ws/api/v4
Method | HTTP request | Description |
---|---|---|
listUnifiedAccounts | GET /unified/accounts | Get unified account information |
getUnifiedBorrowable | GET /unified/borrowable | Query about the maximum borrowing for the unified account |
getUnifiedTransferable | GET /unified/transferable | Query about the maximum transferable for the unified account |
listUnifiedLoans | GET /unified/loans | List loans |
createUnifiedLoan | POST /unified/loans | Borrow or repay |
listUnifiedLoanRecords | GET /unified/loan_records | Get load records |
listUnifiedLoanInterestRecords | GET /unified/interest_records | List interest records |
getUnifiedRiskUnits | GET /unified/risk_units | 获取用户风险单元详情,仅在组合保证金模式有效 |
getUnifiedMode | GET /unified/unified_mode | Query mode of the unified account |
setUnifiedMode | PUT /unified/unified_mode | Set mode of the unified account |
getUnifiedEstimateRate | GET /unified/estimate_rate | Get unified estimate rate |
listCurrencyDiscountTiers | GET /unified/currency_discount_tiers | list currency discount tiers |
listLoanMarginTiers | GET /unified/loan_margin_tiers | 查询统一账户借贷梯度保证金 |
calculatePortfolioMargin | POST /unified/portfolio_calculator | 组合保证金计算器计算 |
getUserLeverageCurrencyConfig | GET /unified/leverage/user_currency_config | 用户最大、最小可设置币种杠杆倍数 |
getUserLeverageCurrencySetting | GET /unified/leverage/user_currency_setting | 获取用户币种杠杆倍数,currency不传则查询全部币种 |
setUserLeverageCurrencySetting | POST /unified/leverage/user_currency_setting | 设置借贷币种杠杆倍数 |
getHistoryLoanRate | GET /unified/history_loan_rate | 获取历史借币利率 |
Promise<{ response: http.IncomingMessage; body: UnifiedAccount; }> listUnifiedAccounts(opts)
Get unified account information
The assets of each currency in the account will be adjusted according to their liquidity, defined by corresponding adjustment coefficients, and then uniformly converted to USD to calculate the total asset value and position value of the account. You can refer to the Formula in the documentation
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const opts = {
'currency': "BTC" // string | Retrieve data of the specified currency
};
api.listUnifiedAccounts(opts)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Retrieve data of the specified currency | [optional] [default to undefined] |
Promise<{ response: AxiosResponse; body: UnifiedAccount; }> UnifiedAccount
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: UnifiedBorrowable; }> getUnifiedBorrowable(currency)
Query about the maximum borrowing for the unified account
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const currency = "BTC"; // string | Retrieve data of the specified currency
api.getUnifiedBorrowable(currency)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Retrieve data of the specified currency | [default to undefined] |
Promise<{ response: AxiosResponse; body: UnifiedBorrowable; }> UnifiedBorrowable
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: UnifiedTransferable; }> getUnifiedTransferable(currency)
Query about the maximum transferable for the unified account
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const currency = "BTC"; // string | Retrieve data of the specified currency
api.getUnifiedTransferable(currency)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Retrieve data of the specified currency | [default to undefined] |
Promise<{ response: AxiosResponse; body: UnifiedTransferable; }> UnifiedTransferable
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: Array; }> listUnifiedLoans(opts)
List loans
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const opts = {
'currency': "BTC", // string | Retrieve data of the specified currency
'page': 1, // number | Page number
'limit': 100, // number | Maximum response items. Default: 100, minimum: 1, Maximum: 100
'type': "platform" // string | Loan type, platform - platform, margin - margin
};
api.listUnifiedLoans(opts)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Retrieve data of the specified currency | [optional] [default to undefined] |
page | number | Page number | [optional] [default to 1] |
limit | number | Maximum response items. Default: 100, minimum: 1, Maximum: 100 | [optional] [default to 100] |
type | string | Loan type, platform - platform, margin - margin | [optional] [default to undefined] |
Promise<{ response: AxiosResponse; body: Array; }> UniLoan
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body?: any; }> createUnifiedLoan(unifiedLoan)
Borrow or repay
When borrowing, it is essential to ensure that the borrowed amount is not below the minimum borrowing threshold for the specific cryptocurrency and does not exceed the maximum borrowing limit set by the platform and the user. The interest on the loan will be automatically deducted from the account at regular intervals. It is the user's responsibility to manage the repayment of the borrowed amount. For repayment, the option to repay the entire borrowed amount is available by setting the parameter `repaid_all=true`
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const unifiedLoan = new UnifiedLoan(); // UnifiedLoan |
api.createUnifiedLoan(unifiedLoan)
.then(value => console.log('API called successfully.'),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
unifiedLoan | UnifiedLoan |
Promise<{ response: AxiosResponse; body?: any; }>
- Content-Type: application/json
- Accept: Not defined
Promise<{ response: http.IncomingMessage; body: Array; }> listUnifiedLoanRecords(opts)
Get load records
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const opts = {
'type': "type_example", // string | The types of lending records, borrow - indicates the action of borrowing funds, repay - indicates the action of repaying the borrowed funds
'currency': "BTC", // string | Retrieve data of the specified currency
'page': 1, // number | Page number
'limit': 100 // number | Maximum response items. Default: 100, minimum: 1, Maximum: 100
};
api.listUnifiedLoanRecords(opts)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
type | string | The types of lending records, borrow - indicates the action of borrowing funds, repay - indicates the action of repaying the borrowed funds | [optional] [default to undefined] |
currency | string | Retrieve data of the specified currency | [optional] [default to undefined] |
page | number | Page number | [optional] [default to 1] |
limit | number | Maximum response items. Default: 100, minimum: 1, Maximum: 100 | [optional] [default to 100] |
Promise<{ response: AxiosResponse; body: Array; }> UnifiedLoanRecord
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: Array; }> listUnifiedLoanInterestRecords(opts)
List interest records
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const opts = {
'currency': "BTC", // string | Retrieve data of the specified currency
'page': 1, // number | Page number
'limit': 100, // number | Maximum response items. Default: 100, minimum: 1, Maximum: 100
'from': 1627706330, // number | Start timestamp of the query
'to': 1635329650, // number | Time range ending, default to current time
'type': "platform" // string | 借贷类型,平台借币 - platform,杠杆借币 - margin,不传时默认为margin
};
api.listUnifiedLoanInterestRecords(opts)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Retrieve data of the specified currency | [optional] [default to undefined] |
page | number | Page number | [optional] [default to 1] |
limit | number | Maximum response items. Default: 100, minimum: 1, Maximum: 100 | [optional] [default to 100] |
from | number | Start timestamp of the query | [optional] [default to undefined] |
to | number | Time range ending, default to current time | [optional] [default to undefined] |
type | string | 借贷类型,平台借币 - platform,杠杆借币 - margin,不传时默认为margin | [optional] [default to undefined] |
Promise<{ response: AxiosResponse; body: Array; }> UniLoanInterestRecord
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: UnifiedRiskUnits; }> getUnifiedRiskUnits()
获取用户风险单元详情,仅在组合保证金模式有效
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
api.getUnifiedRiskUnits()
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
This endpoint does not need any parameter.
Promise<{ response: AxiosResponse; body: UnifiedRiskUnits; }> UnifiedRiskUnits
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: UnifiedModeSet; }> getUnifiedMode()
Query mode of the unified account
统一账户模式: - `classic`: 经典账户模式 - `multi_currency`: 跨币种保证金模式 - `portfolio`: 组合保证金模式 - `single_currency`: 单币种保证金模式
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
api.getUnifiedMode()
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
This endpoint does not need any parameter.
Promise<{ response: AxiosResponse; body: UnifiedModeSet; }> UnifiedModeSet
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body?: any; }> setUnifiedMode(unifiedModeSet)
Set mode of the unified account
每种账户模式的切换只需要传对应账户模式的参数,同时支持在切换账户模式时打开或关闭对应账户模式下的配置开关 - 开通经典账户模式时,mode=classic ``` PUT /unified/unified_mode { "mode": "classic" } ``` - 开通跨币种保证金模式,mode=multi_currency ``` PUT /unified/unified_mode { "mode": "multi_currency", "settings": { "usdt_futures": true } } ``` - 开通组合保证金模式时,mode=portfolio ``` PUT /unified/unified_mode { "mode": "portfolio", "settings": { "spot_hedge": true } } ``` - 开通组合保证金模式时,mode=single_currency ``` PUT /unified/unified_mode { "mode": "single_currency" } ```
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const unifiedModeSet = new UnifiedModeSet(); // UnifiedModeSet |
api.setUnifiedMode(unifiedModeSet)
.then(value => console.log('API called successfully.'),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
unifiedModeSet | UnifiedModeSet |
Promise<{ response: AxiosResponse; body?: any; }>
- Content-Type: application/json
- Accept: Not defined
Promise<{ response: http.IncomingMessage; body: { [key: string]: string; }; }> getUnifiedEstimateRate(currencies)
Get unified estimate rate
Due to fluctuations in lending depth, hourly interest rates may vary, and thus, I cannot provide exact rates. When a currency is not supported, the interest rate returned will be an empty string.
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const currencies = [["BTC","GT"]]; // Array<string> | Specify the currency names for querying in an array, separated by commas, with a maximum of 10 currencies.
api.getUnifiedEstimateRate(currencies)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
currencies | Array<string> | Specify the currency names for querying in an array, separated by commas, with a maximum of 10 currencies. | [default to undefined] |
Promise<{ response: AxiosResponse; body: { [key: string]: string; }; }> string
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: Array; }> listCurrencyDiscountTiers()
list currency discount tiers
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
const api = new GateApi.UnifiedApi(client);
api.listCurrencyDiscountTiers()
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
This endpoint does not need any parameter.
Promise<{ response: AxiosResponse; body: Array; }> UnifiedDiscount
No authorization required
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: Array; }> listLoanMarginTiers()
查询统一账户借贷梯度保证金
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
const api = new GateApi.UnifiedApi(client);
api.listLoanMarginTiers()
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
This endpoint does not need any parameter.
Promise<{ response: AxiosResponse; body: Array; }> UnifiedMarginTiers
No authorization required
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: UnifiedPortfolioOutput; }> calculatePortfolioMargin(unifiedPortfolioInput)
组合保证金计算器计算
组合保证金计算器 当输入为模拟仓位组合时,每个仓位包括仓位名和持有量,只支持市场范围:BTC、ETH的永续合约、期权、现货 当输入为模拟挂单时,每个挂单包括市场标识、挂单价、挂单量,只支持市场范围:BTC、ETH的永续合约、期权、现货。挂单不包括市价单
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
const api = new GateApi.UnifiedApi(client);
const unifiedPortfolioInput = new UnifiedPortfolioInput(); // UnifiedPortfolioInput |
api.calculatePortfolioMargin(unifiedPortfolioInput)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
unifiedPortfolioInput | UnifiedPortfolioInput |
Promise<{ response: AxiosResponse; body: UnifiedPortfolioOutput; }> UnifiedPortfolioOutput
No authorization required
- Content-Type: application/json
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: UnifiedLeverageConfig; }> getUserLeverageCurrencyConfig(currency)
用户最大、最小可设置币种杠杆倍数
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const currency = "BTC"; // string | Currency
api.getUserLeverageCurrencyConfig(currency)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Currency | [default to undefined] |
Promise<{ response: AxiosResponse; body: UnifiedLeverageConfig; }> UnifiedLeverageConfig
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body: UnifiedLeverageSetting; }> getUserLeverageCurrencySetting(opts)
获取用户币种杠杆倍数,currency不传则查询全部币种
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const opts = {
'currency': "BTC" // string | Currency
};
api.getUserLeverageCurrencySetting(opts)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Currency | [optional] [default to undefined] |
Promise<{ response: AxiosResponse; body: UnifiedLeverageSetting; }> UnifiedLeverageSetting
- Content-Type: Not defined
- Accept: application/json
Promise<{ response: http.IncomingMessage; body?: any; }> setUserLeverageCurrencySetting(inlineObject)
设置借贷币种杠杆倍数
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const inlineObject = new InlineObject(); // InlineObject |
api.setUserLeverageCurrencySetting(inlineObject)
.then(value => console.log('API called successfully.'),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
inlineObject | InlineObject |
Promise<{ response: AxiosResponse; body?: any; }>
- Content-Type: application/json
- Accept: Not defined
Promise<{ response: http.IncomingMessage; body: UnifiedHistoryLoanRate; }> getHistoryLoanRate(currency, opts)
获取历史借币利率
const GateApi = require('gate-api');
const client = new GateApi.ApiClient();
// uncomment the next line to change base path
// client.basePath = "https://some-other-host"
// Configure Gate APIv4 key authentication:
client.setApiKeySecret("YOUR_API_KEY", "YOUR_API_SECRET");
const api = new GateApi.UnifiedApi(client);
const currency = "USDT"; // string | Currency
const opts = {
'tier': "1", // string | 需要查询的上浮费率的vip等级
'page': 1, // number | Page number
'limit': 100 // number | Maximum response items. Default: 100, minimum: 1, Maximum: 100
};
api.getHistoryLoanRate(currency, opts)
.then(value => console.log('API called successfully. Returned data: ', value.body),
error => console.error(error));
Name | Type | Description | Notes |
---|---|---|---|
currency | string | Currency | [default to undefined] |
tier | string | 需要查询的上浮费率的vip等级 | [optional] [default to undefined] |
page | number | Page number | [optional] [default to 1] |
limit | number | Maximum response items. Default: 100, minimum: 1, Maximum: 100 | [optional] [default to 100] |
Promise<{ response: AxiosResponse; body: UnifiedHistoryLoanRate; }> UnifiedHistoryLoanRate
- Content-Type: Not defined
- Accept: application/json