Skip to content

Latest commit

 

History

History
1493 lines (1154 loc) · 53.2 KB

File metadata and controls

1493 lines (1154 loc) · 53.2 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
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
getUnifiedTransferables GET /unified/transferables Batch query can be transferred out at most for unified accounts; each currency is the maximum value. After the user withdraws the currency, the amount of transferable currency will be changed.
getUnifiedBorrowableList GET /unified/batch_borrowable Batch query unified account can be borrowed up to a maximum
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 Get user risk unit details
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 List loan margin tiers
calculatePortfolioMargin POST /unified/portfolio_calculator Portfolio margin calculator
getUserLeverageCurrencyConfig GET /unified/leverage/user_currency_config Minimum currency leverage that can be set
getUserLeverageCurrencySetting GET /unified/leverage/user_currency_setting Get the leverage multiple of the user currency
setUserLeverageCurrencySetting POST /unified/leverage/user_currency_setting Set the loan currency leverage
listUnifiedCurrencies GET /unified/currencies List of loan currencies supported by unified account
getHistoryLoanRate GET /unified/history_loan_rate get historical lending rates

listUnifiedAccounts

UnifiedAccount listUnifiedAccounts().currency(currency).subUid(subUid).execute();

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

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currency = "BTC"; // String | Retrieve data of the specified currency
        String subUid = "10001"; // String | Sub account user ID
        try {
            UnifiedAccount result = apiInstance.listUnifiedAccounts()
                        .currency(currency)
                        .subUid(subUid)
                        .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 UnifiedApi#listUnifiedAccounts");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currency String Retrieve data of the specified currency [optional]
subUid String Sub account user ID [optional]

Return type

UnifiedAccount

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -

getUnifiedBorrowable

UnifiedBorrowable getUnifiedBorrowable(currency)

Query about the maximum borrowing for the unified account

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currency = "BTC"; // String | Retrieve data of the specified currency
        try {
            UnifiedBorrowable result = apiInstance.getUnifiedBorrowable(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 UnifiedApi#getUnifiedBorrowable");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currency String Retrieve data of the specified currency

Return type

UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

getUnifiedTransferable

UnifiedTransferable getUnifiedTransferable(currency)

Query about the maximum transferable for the unified account

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currency = "BTC"; // String | Retrieve data of the specified currency
        try {
            UnifiedTransferable result = apiInstance.getUnifiedTransferable(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 UnifiedApi#getUnifiedTransferable");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currency String Retrieve data of the specified currency

Return type

UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

getUnifiedTransferables

List<TransferablesResult> getUnifiedTransferables(currencies)

Batch query can be transferred out at most for unified accounts; each currency is the maximum value. After the user withdraws the currency, the amount of transferable currency will be changed.

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currencies = "BTC,ETH"; // String | Specify the currency name to query in batches, and support up to 100 pass parameters at a time.
        try {
            List<TransferablesResult> result = apiInstance.getUnifiedTransferables(currencies);
            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 UnifiedApi#getUnifiedTransferables");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currencies String Specify the currency name to query in batches, and support up to 100 pass parameters at a time.

Return type

List<TransferablesResult>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

getUnifiedBorrowableList

List<UnifiedBorrowable1> getUnifiedBorrowableList(currencies)

Batch query unified account can be borrowed up to a maximum

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        List<String> currencies = Arrays.asList(); // List<String> | Specify the currency names for querying in an array, separated by commas, with a maximum of 10 currencies.
        try {
            List<UnifiedBorrowable1> result = apiInstance.getUnifiedBorrowableList(currencies);
            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 UnifiedApi#getUnifiedBorrowableList");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currencies List<String> Specify the currency names for querying in an array, separated by commas, with a maximum of 10 currencies.

Return type

List<UnifiedBorrowable1>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

listUnifiedLoans

List<UniLoan> listUnifiedLoans().currency(currency).page(page).limit(limit).type(type).execute();

List loans

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currency = "BTC"; // String | Retrieve data of the specified currency
        Integer page = 1; // Integer | Page number
        Integer limit = 100; // Integer | Maximum response items.  Default: 100, minimum: 1, Maximum: 100
        String type = "platform"; // String | Loan type, platform - platform, margin - margin
        try {
            List<UniLoan> result = apiInstance.listUnifiedLoans()
                        .currency(currency)
                        .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 UnifiedApi#listUnifiedLoans");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currency String Retrieve data of the specified currency [optional]
page Integer Page number [optional] [default to 1]
limit Integer Maximum response items. Default: 100, minimum: 1, Maximum: 100 [optional] [default to 100]
type String Loan type, platform - platform, margin - margin [optional]

Return type

List<UniLoan>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

createUnifiedLoan

UnifiedLoanResult 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`

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        UnifiedLoan unifiedLoan = new UnifiedLoan(); // UnifiedLoan | 
        try {
            UnifiedLoanResult result = apiInstance.createUnifiedLoan(unifiedLoan);
            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 UnifiedApi#createUnifiedLoan");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
unifiedLoan UnifiedLoan

Return type

UnifiedLoanResult

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Operated successfully -

listUnifiedLoanRecords

List<UnifiedLoanRecord> listUnifiedLoanRecords().type(type).currency(currency).page(page).limit(limit).execute();

Get load records

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String 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
        String currency = "BTC"; // String | Retrieve data of the specified currency
        Integer page = 1; // Integer | Page number
        Integer limit = 100; // Integer | Maximum response items.  Default: 100, minimum: 1, Maximum: 100
        try {
            List<UnifiedLoanRecord> result = apiInstance.listUnifiedLoanRecords()
                        .type(type)
                        .currency(currency)
                        .page(page)
                        .limit(limit)
                        .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 UnifiedApi#listUnifiedLoanRecords");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

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]
currency String Retrieve data of the specified currency [optional]
page Integer Page number [optional] [default to 1]
limit Integer Maximum response items. Default: 100, minimum: 1, Maximum: 100 [optional] [default to 100]

Return type

List<UnifiedLoanRecord>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

listUnifiedLoanInterestRecords

List<UniLoanInterestRecord> listUnifiedLoanInterestRecords().currency(currency).page(page).limit(limit).from(from).to(to).type(type).execute();

List interest records

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currency = "BTC"; // String | Retrieve data of the specified currency
        Integer page = 1; // Integer | Page number
        Integer limit = 100; // Integer | Maximum response items.  Default: 100, minimum: 1, Maximum: 100
        Long from = 1627706330L; // Long | Start timestamp of the query
        Long to = 1635329650L; // Long | Time range ending, default to current time
        String type = "platform"; // String | Loan type, platform loan - platform, leverage loan - margin, if not passed, defaults to margin
        try {
            List<UniLoanInterestRecord> result = apiInstance.listUnifiedLoanInterestRecords()
                        .currency(currency)
                        .page(page)
                        .limit(limit)
                        .from(from)
                        .to(to)
                        .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 UnifiedApi#listUnifiedLoanInterestRecords");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currency String Retrieve data of the specified currency [optional]
page Integer Page number [optional] [default to 1]
limit Integer Maximum response items. Default: 100, minimum: 1, Maximum: 100 [optional] [default to 100]
from Long Start timestamp of the query [optional]
to Long Time range ending, default to current time [optional]
type String Loan type, platform loan - platform, leverage loan - margin, if not passed, defaults to margin [optional]

Return type

List<UniLoanInterestRecord>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

getUnifiedRiskUnits

UnifiedRiskUnits getUnifiedRiskUnits()

Get user risk unit details

Retrieve user risk unit details, only valid in portfolio margin mode

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        try {
            UnifiedRiskUnits result = apiInstance.getUnifiedRiskUnits();
            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 UnifiedApi#getUnifiedRiskUnits");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

This endpoint does not need any parameter.

Return type

UnifiedRiskUnits

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

getUnifiedMode

UnifiedModeSet getUnifiedMode()

Query mode of the unified account

Unified account mode: - `classic`: Classic account mode - `multi_currency`: Cross-currency margin mode - `portfolio`: Portfolio margin mode - `single_currency`: Single-currency margin mode

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        try {
            UnifiedModeSet result = apiInstance.getUnifiedMode();
            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 UnifiedApi#getUnifiedMode");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

This endpoint does not need any parameter.

Return type

UnifiedModeSet

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

setUnifiedMode

setUnifiedMode(unifiedModeSet)

Set mode of the unified account

Switching each account mode only requires passing the parameters of the corresponding account mode, and supports turning on or off the configuration switch in the corresponding account mode when switching the account mode - When opening the classic account mode, mode=classic ``` PUT /unified/unified_mode { &quot;mode&quot;: &quot;classic&quot; } ``` - Open the cross-currency margin mode, mode=multi_currency ``` PUT /unified/unified_mode { &quot;mode&quot;: &quot;multi_currency&quot;, &quot;settings&quot;: { &quot;usdt_futures&quot;: true } } ``` - When the portfolio margin mode is enabled, mode=portfolio ``` PUT /unified/unified_mode { &quot;mode&quot;: &quot;portfolio&quot;, &quot;settings&quot;: { &quot;spot_hedge&quot;: true } } ``` - When opening a single currency margin mode, mode=single_currency ``` PUT /unified/unified_mode { &quot;mode&quot;: &quot;single_currency&quot; } ```

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        UnifiedModeSet unifiedModeSet = new UnifiedModeSet(); // UnifiedModeSet | 
        try {
            apiInstance.setUnifiedMode(unifiedModeSet);
        } 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 UnifiedApi#setUnifiedMode");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
unifiedModeSet UnifiedModeSet

Return type

null (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
204 Success -

getUnifiedEstimateRate

Map<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.

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        List<String> currencies = Arrays.asList(); // List<String> | Specify the currency names for querying in an array, separated by commas, with a maximum of 10 currencies.
        try {
            Map<String, String> result = apiInstance.getUnifiedEstimateRate(currencies);
            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 UnifiedApi#getUnifiedEstimateRate");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currencies List<String> Specify the currency names for querying in an array, separated by commas, with a maximum of 10 currencies.

Return type

Map<String, String>

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

listCurrencyDiscountTiers

List<UnifiedDiscount> listCurrencyDiscountTiers()

List currency discount tiers

Example

// 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.UnifiedApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        try {
            List<UnifiedDiscount> result = apiInstance.listCurrencyDiscountTiers();
            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 UnifiedApi#listCurrencyDiscountTiers");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

This endpoint does not need any parameter.

Return type

List<UnifiedDiscount>

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

listLoanMarginTiers

List<UnifiedMarginTiers> listLoanMarginTiers()

List loan margin tiers

Example

// 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.UnifiedApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        try {
            List<UnifiedMarginTiers> result = apiInstance.listLoanMarginTiers();
            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 UnifiedApi#listLoanMarginTiers");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

This endpoint does not need any parameter.

Return type

List<UnifiedMarginTiers>

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

calculatePortfolioMargin

UnifiedPortfolioOutput calculatePortfolioMargin(unifiedPortfolioInput)

Portfolio margin calculator

Portfolio Margin Calculator When inputting a simulated position portfolio, each position includes the position name and quantity held, supporting markets within the range of BTC and ETH perpetual contracts, options, and spot markets. When inputting simulated orders, each order includes the market identifier, order price, and order quantity, supporting markets within the range of BTC and ETH perpetual contracts, options, and spot markets. Market orders are not included.

Example

// 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.UnifiedApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        UnifiedPortfolioInput unifiedPortfolioInput = new UnifiedPortfolioInput(); // UnifiedPortfolioInput | 
        try {
            UnifiedPortfolioOutput result = apiInstance.calculatePortfolioMargin(unifiedPortfolioInput);
            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 UnifiedApi#calculatePortfolioMargin");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
unifiedPortfolioInput UnifiedPortfolioInput

Return type

UnifiedPortfolioOutput

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

getUserLeverageCurrencyConfig

UnifiedLeverageConfig getUserLeverageCurrencyConfig(currency)

Minimum currency leverage that can be set

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currency = "BTC"; // String | Currency
        try {
            UnifiedLeverageConfig result = apiInstance.getUserLeverageCurrencyConfig(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 UnifiedApi#getUserLeverageCurrencyConfig");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currency String Currency

Return type

UnifiedLeverageConfig

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

getUserLeverageCurrencySetting

UnifiedLeverageSetting getUserLeverageCurrencySetting().currency(currency).execute();

Get the leverage multiple of the user currency

Get the user's currency leverage. If currency is not passed, query all currencies.

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currency = "BTC"; // String | Currency
        try {
            UnifiedLeverageSetting result = apiInstance.getUserLeverageCurrencySetting()
                        .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 UnifiedApi#getUserLeverageCurrencySetting");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currency String Currency [optional]

Return type

UnifiedLeverageSetting

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -

setUserLeverageCurrencySetting

setUserLeverageCurrencySetting(unifiedLeverageSetting)

Set the loan currency leverage

Example

// 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.UnifiedApi;

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

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        UnifiedLeverageSetting unifiedLeverageSetting = new UnifiedLeverageSetting(); // UnifiedLeverageSetting | 
        try {
            apiInstance.setUserLeverageCurrencySetting(unifiedLeverageSetting);
        } 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 UnifiedApi#setUserLeverageCurrencySetting");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
unifiedLeverageSetting UnifiedLeverageSetting

Return type

null (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status code Description Response headers
204 Success -

listUnifiedCurrencies

List<UnifiedCurrency> listUnifiedCurrencies().currency(currency).execute();

List of loan currencies supported by unified account

Example

// 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.UnifiedApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currency = "BTC"; // String | Currency
        try {
            List<UnifiedCurrency> result = apiInstance.listUnifiedCurrencies()
                        .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 UnifiedApi#listUnifiedCurrencies");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currency String Currency [optional]

Return type

List<UnifiedCurrency>

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 List retrieved -

getHistoryLoanRate

UnifiedHistoryLoanRate getHistoryLoanRate(currency).tier(tier).page(page).limit(limit).execute();

get historical lending rates

Example

// 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.UnifiedApi;

public class Example {
    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.gateio.ws/api/v4");

        UnifiedApi apiInstance = new UnifiedApi(defaultClient);
        String currency = "USDT"; // String | Currency
        String tier = "1"; // String | The VIP level of the floating rate that needs to be queried
        Integer page = 1; // Integer | Page number
        Integer limit = 100; // Integer | Maximum response items.  Default: 100, minimum: 1, Maximum: 100
        try {
            UnifiedHistoryLoanRate result = apiInstance.getHistoryLoanRate(currency)
                        .tier(tier)
                        .page(page)
                        .limit(limit)
                        .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 UnifiedApi#getHistoryLoanRate");
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response headers: " + e.getResponseHeaders());
            e.printStackTrace();
        }
    }
}

Parameters

Name Type Description Notes
currency String Currency
tier String The VIP level of the floating rate that needs to be queried [optional]
page Integer Page number [optional] [default to 1]
limit Integer Maximum response items. Default: 100, minimum: 1, Maximum: 100 [optional] [default to 100]

Return type

UnifiedHistoryLoanRate

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status code Description Response headers
200 Successfully retrieved -