All URIs are relative to https://api.gateio.ws/api/v4
| Method | HTTP request | Description |
|---|---|---|
| list_unified_accounts | GET /unified/accounts | Get unified account information |
| get_unified_borrowable | GET /unified/borrowable | Query maximum borrowable amount for unified account |
| get_unified_transferable | GET /unified/transferable | Query maximum transferable amount for unified account |
| get_unified_transferables | GET /unified/transferables | Batch query maximum transferable amount for unified accounts. Each currency shows the maximum value. After user withdrawal, the transferable amount for all currencies will change |
| get_unified_borrowable_list | GET /unified/batch_borrowable | Batch query unified account maximum borrowable amount |
| list_unified_loans | GET /unified/loans | Query loans |
| create_unified_loan | POST /unified/loans | Borrow or repay |
| list_unified_loan_records | GET /unified/loan_records | Query loan records |
| list_unified_loan_interest_records | GET /unified/interest_records | Query interest deduction records |
| get_unified_risk_units | GET /unified/risk_units | Get user risk unit details |
| get_unified_mode | GET /unified/unified_mode | Query mode of the unified account |
| set_unified_mode | PUT /unified/unified_mode | Set unified account mode |
| get_unified_estimate_rate | GET /unified/estimate_rate | Query unified account estimated interest rate |
| list_currency_discount_tiers | GET /unified/currency_discount_tiers | Query unified account tiered |
| list_loan_margin_tiers | GET /unified/loan_margin_tiers | Query unified account tiered loan margin |
| calculate_portfolio_margin | POST /unified/portfolio_calculator | Portfolio margin calculator |
| set_user_leverage | POST /unified/leverage/user_setting | Set leverage for all of the user's borrowed currencies |
| get_user_leverage_currency_config | GET /unified/leverage/user_currency_config | Maximum and minimum currency leverage that can be set |
| get_user_leverage_currency_setting | GET /unified/leverage/user_currency_setting | Get user currency leverage |
| set_user_leverage_currency_setting | POST /unified/leverage/user_currency_setting | Set loan currency leverage |
| list_unified_currencies | GET /unified/currencies | List of loan currencies supported by unified account |
| get_history_loan_rate | GET /unified/history_loan_rate | Get historical lending rates |
| set_unified_collateral | POST /unified/collateral_currencies | Set collateral currency |
| get_estimated_quick_repayment | GET /unified/estimated_quick_repayment | Estimated quick repayment details |
| create_quick_repayment | POST /unified/quick_repayment | Quick repayment |
| get_unified_delta_neutral | GET /unified/delta_neutral | Query the account Delta-neutral strategy mode setting |
| set_unified_delta_neutral | POST /unified/delta_neutral | Set the account Delta-neutral strategy mode |
UnifiedAccount list_unified_accounts(currency=currency, sub_uid=sub_uid)
Get unified account information
The assets of each currency in the account are assigned adjustment coefficients according to their liquidity and uniformly converted to USD to calculate the account's asset and position values. For details, see Margin Formula.
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currency='BTC'# str | Query by specified currency name (optional)sub_uid='10001'# str | Sub account user ID (optional)try:
# Get unified account informationapi_response=api_instance.list_unified_accounts(currency=currency, sub_uid=sub_uid)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->list_unified_accounts: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Query by specified currency name | [optional] |
| sub_uid | str | Sub account user ID | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved successfully | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UnifiedBorrowable get_unified_borrowable(currency)
Query maximum borrowable amount for unified account
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currency='BTC'# str | Query by specified currency nametry:
# Query maximum borrowable amount for unified accountapi_response=api_instance.get_unified_borrowable(currency)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_unified_borrowable: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Query by specified currency name |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UnifiedTransferable get_unified_transferable(currency)
Query maximum transferable amount for unified account
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currency='BTC'# str | Query by specified currency nametry:
# Query maximum transferable amount for unified accountapi_response=api_instance.get_unified_transferable(currency)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_unified_transferable: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Query by specified currency name |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[TransferablesResult] get_unified_transferables(currencies)
Batch query maximum transferable amount for unified accounts. Each currency shows the maximum value. After user withdrawal, the transferable amount for all currencies will change
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currencies='BTC,ETH'# str | Specify the currency name to query in batches, and support up to 100 pass parameters at a timetry:
# Batch query maximum transferable amount for unified accounts. Each currency shows the maximum value. After user withdrawal, the transferable amount for all currencies will changeapi_response=api_instance.get_unified_transferables(currencies)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_unified_transferables: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currencies | str | Specify the currency name to query in batches, and support up to 100 pass parameters at a time |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[UnifiedBorrowable] get_unified_borrowable_list(currencies)
Batch query unified account maximum borrowable amount
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currencies= ['[\"BTC\",\"GT\"]'] # list[str] | Specify currency names for querying in an array, separated by commas, maximum 10 currenciestry:
# Batch query unified account maximum borrowable amountapi_response=api_instance.get_unified_borrowable_list(currencies)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_unified_borrowable_list: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currencies | list[str] | Specify currency names for querying in an array, separated by commas, maximum 10 currencies |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[UniLoan] list_unified_loans(currency=currency, page=page, limit=limit, type=type)
Query loans
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currency='BTC'# str | Query by specified currency name (optional)page=1# int | Page number (optional) (default to 1)limit=100# int | Maximum number of items returned. Default: 100, minimum: 1, maximum: 100 (optional) (default to 100)type='platform'# str | Loan type: platform borrowing - platform, margin borrowing - margin (optional)try:
# Query loansapi_response=api_instance.list_unified_loans(currency=currency, page=page, limit=limit, type=type)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->list_unified_loans: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Query by specified currency name | [optional] |
| page | int | Page number | [optional] [default to 1] |
| limit | int | Maximum number of items returned. Default: 100, minimum: 1, maximum: 100 | [optional] [default to 100] |
| type | str | Loan type: platform borrowing - platform, margin borrowing - margin | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UnifiedLoanResult create_unified_loan(unified_loan)
Borrow or repay
When borrowing, ensure 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 user. Loan interest will be automatically deducted from the account at regular intervals. Users are responsible for managing repayment of borrowed amounts. For repayment, use repaid_all=true to repay all available amounts
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
unified_loan=gate_api.UnifiedLoan() # UnifiedLoan | try:
# Borrow or repayapi_response=api_instance.create_unified_loan(unified_loan)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->create_unified_loan: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| unified_loan | UnifiedLoan |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Operation successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[UnifiedLoanRecord] list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)
Query loan records
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
type='type_example'# str | Loan record type: borrow - borrowing, repay - repayment (optional)currency='BTC'# str | Query by specified currency name (optional)page=1# int | Page number (optional) (default to 1)limit=100# int | Maximum number of items returned. Default: 100, minimum: 1, maximum: 100 (optional) (default to 100)try:
# Query loan recordsapi_response=api_instance.list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->list_unified_loan_records: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| type | str | Loan record type: borrow - borrowing, repay - repayment | [optional] |
| currency | str | Query by specified currency name | [optional] |
| page | int | Page number | [optional] [default to 1] |
| limit | int | Maximum number of items returned. Default: 100, minimum: 1, maximum: 100 | [optional] [default to 100] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[UniLoanInterestRecord] list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)
Query interest deduction records
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currency='BTC'# str | Query by specified currency name (optional)page=1# int | Page number (optional) (default to 1)limit=100# int | Maximum number of items returned. Default: 100, minimum: 1, maximum: 100 (optional) (default to 100)_from=1627706330# int | Start timestamp for the query (optional)to=1635329650# int | End timestamp for the query, defaults to current time if not specified (optional)type='platform'# str | Loan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified (optional)try:
# Query interest deduction recordsapi_response=api_instance.list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->list_unified_loan_interest_records: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Query by specified currency name | [optional] |
| page | int | Page number | [optional] [default to 1] |
| limit | int | Maximum number of items returned. Default: 100, minimum: 1, maximum: 100 | [optional] [default to 100] |
| _from | int | Start timestamp for the query | [optional] |
| to | int | End timestamp for the query, defaults to current time if not specified | [optional] |
| type | str | Loan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UnifiedRiskUnits get_unified_risk_units()
Get user risk unit details
Get user risk unit details, only valid in portfolio margin mode
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
try:
# Get user risk unit detailsapi_response=api_instance.get_unified_risk_units()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_unified_risk_units: %s\n"%e)This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UnifiedModeSet get_unified_mode()
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
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
try:
# Query mode of the unified accountapi_response=api_instance.get_unified_mode()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_unified_mode: %s\n"%e)This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
set_unified_mode(unified_mode_set)
Set unified account mode
Each account mode switch only requires passing the corresponding account mode parameter, and also supports turning on or off the configuration switches under the corresponding account mode during the switch. - When enabling the classic account mode, mode=classic PUT /unified/unified_mode { \"mode\": \"classic\" } - When enabling the cross-currency margin "multi_currency", "settings": { "usdt_futures": true } } - When enabling the portfolio margin mode, mode=portfolio PUT /unified/unified_mode { "mode": "portfolio", "settings": { "spot_hedge": true } } - When enabling the single-currency margin mode, mode=single_currency PUT /unified/unified_mode { "mode": "single_currency" } ```
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
unified_mode_set=gate_api.UnifiedModeSet() # UnifiedModeSet | try:
# Set unified account modeapi_instance.set_unified_mode(unified_mode_set)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->set_unified_mode: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| unified_mode_set | UnifiedModeSet |
void (empty response body)
- Content-Type: application/json
- Accept: Not defined
| Status code | Description | Response headers |
|---|---|---|
| 204 | Set successfully | - |
[Back to top][Back to API list][Back to Model list][Back to README]
dict(str, str) get_unified_estimate_rate(currencies)
Query unified account estimated interest rate
Interest rates fluctuate hourly based on lending depth, so exact rates cannot be provided. When a currency is not supported, the interest rate returned will be an empty string
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currencies= ['[\"BTC\",\"GT\"]'] # list[str] | Specify currency names for querying in an array, separated by commas, maximum 10 currenciestry:
# Query unified account estimated interest rateapi_response=api_instance.get_unified_estimate_rate(currencies)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_unified_estimate_rate: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currencies | list[str] | Specify currency names for querying in an array, separated by commas, maximum 10 currencies |
dict(str, str)
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[UnifiedDiscount] list_currency_discount_tiers()
Query unified account tiered
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.configuration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
try:
# Query unified account tieredapi_response=api_instance.list_currency_discount_tiers()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->list_currency_discount_tiers: %s\n"%e)This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[UnifiedMarginTiers] list_loan_margin_tiers()
Query unified account tiered loan margin
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.configuration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
try:
# Query unified account tiered loan marginapi_response=api_instance.list_loan_margin_tiers()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->list_loan_margin_tiers: %s\n"%e)This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UnifiedPortfolioOutput calculate_portfolio_margin(unified_portfolio_input)
Portfolio margin calculator
Portfolio Margin Calculator This interface calculates maintenance and initial margin requirements under the portfolio margin model for custom simulated position and order portfolios. It currently supports all underlying currencies with active options trading. Each simulated position requires a name and holding quantity; each simulated pending order requires a market identifier, price, and quantity. Market orders are not supported.
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.configuration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
unified_portfolio_input=gate_api.UnifiedPortfolioInput() # UnifiedPortfolioInput | try:
# Portfolio margin calculatorapi_response=api_instance.calculate_portfolio_margin(unified_portfolio_input)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->calculate_portfolio_margin: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| unified_portfolio_input | UnifiedPortfolioInput |
No authorization required
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[LeverageFailedCurrencies] set_user_leverage(user_leverage_setting)
Set leverage for all of the user's borrowed currencies
Note the following: - Leverage cannot be changed for currencies with outstanding loans. - A leverage value above a currency's limit is capped at that limit. - Failures are not rolled back and affect only the currencies that failed. For example, if USDT has an outstanding loan, only the USDT leverage remains unchanged.
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
user_leverage_setting=gate_api.UserLeverageSetting() # UserLeverageSetting | try:
# Set leverage for all of the user's borrowed currenciesapi_response=api_instance.set_user_leverage(user_leverage_setting)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->set_user_leverage: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| user_leverage_setting | UserLeverageSetting |
list[LeverageFailedCurrencies]
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Set successfully | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UnifiedLeverageConfig get_user_leverage_currency_config(currency)
Maximum and minimum currency leverage that can be set
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currency='BTC'# str | Currencytry:
# Maximum and minimum currency leverage that can be setapi_response=api_instance.get_user_leverage_currency_config(currency)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_user_leverage_currency_config: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Currency |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[UnifiedLeverageSetting] get_user_leverage_currency_setting(currency=currency)
Get user currency leverage
Get user currency leverage. If currency is not specified, query all currencies
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currency='BTC'# str | Currency (optional)try:
# Get user currency leverageapi_response=api_instance.get_user_leverage_currency_setting(currency=currency)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_user_leverage_currency_setting: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Currency | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
set_user_leverage_currency_setting(unified_leverage_setting)
Set loan currency leverage
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
unified_leverage_setting=gate_api.UnifiedLeverageSetting() # UnifiedLeverageSetting | try:
# Set loan currency leverageapi_instance.set_user_leverage_currency_setting(unified_leverage_setting)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->set_user_leverage_currency_setting: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| unified_leverage_setting | UnifiedLeverageSetting |
void (empty response body)
- Content-Type: application/json
- Accept: Not defined
| Status code | Description | Response headers |
|---|---|---|
| 204 | Set successfully | - |
[Back to top][Back to API list][Back to Model list][Back to README]
list[UnifiedCurrency] list_unified_currencies(currency=currency)
List of loan currencies supported by unified account
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.configuration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currency='BTC'# str | Currency (optional)try:
# List of loan currencies supported by unified accountapi_response=api_instance.list_unified_currencies(currency=currency)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->list_unified_currencies: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Currency | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved successfully | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UnifiedHistoryLoanRate get_history_loan_rate(currency, tier=tier, page=page, limit=limit)
Get historical lending rates
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.configuration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
currency='USDT'# str | Currencytier='1'# str | VIP level for the floating rate to be queried (optional)page=1# int | Page number (optional) (default to 1)limit=100# int | Maximum number of items returned. Default: 100, minimum: 1, maximum: 100 (optional) (default to 100)try:
# Get historical lending ratesapi_response=api_instance.get_history_loan_rate(currency, tier=tier, page=page, limit=limit)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_history_loan_rate: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Currency | |
| tier | str | VIP level for the floating rate to be queried | [optional] |
| page | int | Page number | [optional] [default to 1] |
| limit | int | Maximum number of items returned. Default: 100, minimum: 1, maximum: 100 | [optional] [default to 100] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top][Back to API list][Back to Model list][Back to README]
UnifiedCollateralRes set_unified_collateral(unified_collateral_req)
Set collateral currency
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
unified_collateral_req=gate_api.UnifiedCollateralReq() # UnifiedCollateralReq | try:
# Set collateral currencyapi_response=api_instance.set_unified_collateral(unified_collateral_req)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->set_unified_collateral: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| unified_collateral_req | UnifiedCollateralReq |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Updated successfully | - |
[Back to top][Back to API list][Back to Model list][Back to README]
QuickEstimatedRepayment get_estimated_quick_repayment()
Estimated quick repayment details
Available for unified account cross-currency margin mode and portfolio margin mode
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
try:
# Estimated quick repayment detailsapi_response=api_instance.get_estimated_quick_repayment()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_estimated_quick_repayment: %s\n"%e)This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
| 400 | Invalid request parameters | - |
| 401 | Authentication failed | - |
| 403 | Access denied (e.g. account mode does not support quick repayment) | - |
[Back to top][Back to API list][Back to Model list][Back to README]
QuickRepaymentResponse create_quick_repayment(quick_repayment_request)
Quick repayment
Available for unified account cross-currency margin mode and portfolio margin mode. Use GET /unified/estimated_quick_repayment to query liabilities and pending repayment information.
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
quick_repayment_request=gate_api.QuickRepaymentRequest() # QuickRepaymentRequest | try:
# Quick repaymentapi_response=api_instance.create_quick_repayment(quick_repayment_request)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->create_quick_repayment: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| quick_repayment_request | QuickRepaymentRequest |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Repayment successful | - |
| 400 | Invalid request parameters | - |
| 401 | Authentication failed | - |
| 403 | Access denied (e.g. account mode does not support quick repayment) | - |
[Back to top][Back to API list][Back to Model list][Back to README]
DeltaNeutralEnabled get_unified_delta_neutral()
Query the account Delta-neutral strategy mode setting
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
try:
# Query the account Delta-neutral strategy mode settingapi_response=api_instance.get_unified_delta_neutral()
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->get_unified_delta_neutral: %s\n"%e)This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
| 401 | Authentication failed | - |
| 403 | Access denied (e.g. insufficient VIP level or the account is not in cross-currency margin mode) | - |
[Back to top][Back to API list][Back to Model list][Back to README]
DeltaNeutralEnabled set_unified_delta_neutral(delta_neutral_enabled)
Set the account Delta-neutral strategy mode
Enable or disable the account Delta-neutral strategy mode. Requirements for enabling: VIP level >= 4 and the account is in cross-currency margin mode; otherwise 403 is returned. Returns the enabled status after the setting takes effect.
- Api Key Authentication (apiv4):
from __future__ importprint_functionimportgate_apifromgate_api.exceptionsimportApiException, GateApiException# Defining the host is optional and defaults to https://api.gateio.ws/api/v4# See configuration.py for a list of all supported configuration parameters.# The client must configure the authentication and authorization parameters# in accordance with the API server security policy.# Examples for each auth method are provided below, use the example that# satisfies your auth use case.# Configure APIv4 key authorizationconfiguration=gate_api.Configuration(
host="https://api.gateio.ws/api/v4",
key="YOU_API_KEY",
secret="YOUR_API_SECRET"
)
api_client=gate_api.ApiClient(configuration)
# Create an instance of the API classapi_instance=gate_api.UnifiedApi(api_client)
delta_neutral_enabled=gate_api.DeltaNeutralEnabled() # DeltaNeutralEnabled | try:
# Set the account Delta-neutral strategy modeapi_response=api_instance.set_unified_delta_neutral(delta_neutral_enabled)
print(api_response)
exceptGateApiExceptionasex:
print("Gate api exception, label: %s, message: %s\n"% (ex.label, ex.message))
exceptApiExceptionase:
print("Exception when calling UnifiedApi->set_unified_delta_neutral: %s\n"%e)| Name | Type | Description | Notes |
|---|---|---|---|
| delta_neutral_enabled | DeltaNeutralEnabled |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Set successfully | - |
| 400 | Invalid request parameters | - |
| 401 | Authentication failed | - |
| 403 | Access denied (e.g. insufficient VIP level or the account is not in cross-currency margin mode) | - |
[Back to top][Back to API list][Back to Model list][Back to README]