[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
427 lines (287 loc) · 13.9 KB

UnifiedApi.md

File metadata and controls

427 lines (287 loc) · 13.9 KB

UnifiedApi

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

Method HTTP request Description
listUnifiedAccounts GET /unified/accounts Get unified account information
listUnifiedAccountMode GET /unified/account_mode Query mode of the unified account
setUnifiedAccountMode POST /unified/account_mode Set mode of the unified account
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

listUnifiedAccounts

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

Example

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));

Parameters

Name Type Description Notes
currency string Retrieve data of the specified currency [optional] [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: UnifiedAccount; }> UnifiedAccount

Authorization

apiv4

HTTP request headers

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

listUnifiedAccountMode

Promise<{ response: http.IncomingMessage; body: { [key: string]: boolean; }; }> listUnifiedAccountMode()

Query mode of the unified account

cross_margin - cross margin, usdt_futures - usdt futures

Example

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.listUnifiedAccountMode()
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

This endpoint does not need any parameter.

Return type

Promise<{ response: AxiosResponse; body: { [key: string]: boolean; }; }> boolean

Authorization

apiv4

HTTP request headers

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

setUnifiedAccountMode

Promise<{ response: http.IncomingMessage; body: { [key: string]: boolean; }; }> setUnifiedAccountMode(unifiedMode)

Set mode of the unified account

Example

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 unifiedMode = new UnifiedMode(); // UnifiedMode | 
api.setUnifiedAccountMode(unifiedMode)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

Name Type Description Notes
unifiedMode UnifiedMode

Return type

Promise<{ response: AxiosResponse; body: { [key: string]: boolean; }; }> boolean

Authorization

apiv4

HTTP request headers

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

getUnifiedBorrowable

Promise<{ response: http.IncomingMessage; body: UnifiedBorrowable; }> getUnifiedBorrowable(currency)

Query about the maximum borrowing for the unified account

Example

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));

Parameters

Name Type Description Notes
currency string Retrieve data of the specified currency [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: UnifiedBorrowable; }> UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

getUnifiedTransferable

Promise<{ response: http.IncomingMessage; body: UnifiedTransferable; }> getUnifiedTransferable(currency)

Query about the maximum transferable for the unified account

Example

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));

Parameters

Name Type Description Notes
currency string Retrieve data of the specified currency [default to undefined]

Return type

Promise<{ response: AxiosResponse; body: UnifiedTransferable; }> UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

listUnifiedLoans

Promise<{ response: http.IncomingMessage; body: Array; }> listUnifiedLoans(opts)

List loans

Example

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
};
api.listUnifiedLoans(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

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]

Return type

Promise<{ response: AxiosResponse; body: Array; }> UniLoan

Authorization

apiv4

HTTP request headers

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

createUnifiedLoan

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&#39;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`

Example

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));

Parameters

Name Type Description Notes
unifiedLoan UnifiedLoan

Return type

Promise<{ response: AxiosResponse; body?: any; }>

Authorization

apiv4

HTTP request headers

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

listUnifiedLoanRecords

Promise<{ response: http.IncomingMessage; body: Array; }> listUnifiedLoanRecords(opts)

Get load records

Example

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", // 'borrow' | 'repay' | 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));

Parameters

Name Type Description Notes
type Type 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]

Return type

Promise<{ response: AxiosResponse; body: Array; }> UnifiedLoanRecord

Authorization

apiv4

HTTP request headers

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

listUnifiedLoanInterestRecords

Promise<{ response: http.IncomingMessage; body: Array; }> listUnifiedLoanInterestRecords(opts)

List interest records

Example

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
};
api.listUnifiedLoanInterestRecords(opts)
   .then(value => console.log('API called successfully. Returned data: ', value.body),
         error => console.error(error));

Parameters

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]

Return type

Promise<{ response: AxiosResponse; body: Array; }> UniLoanInterestRecord

Authorization

apiv4

HTTP request headers

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