Skip to content

Latest commit

History

History
1838 lines (1374 loc) · 66 KB

File metadata and controls

1838 lines (1374 loc) · 66 KB

gate_api.UnifiedApi

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

MethodHTTP requestDescription
list_unified_accountsGET /unified/accountsGet unified account information
get_unified_borrowableGET /unified/borrowableQuery maximum borrowable amount for unified account
get_unified_transferableGET /unified/transferableQuery maximum transferable amount for unified account
get_unified_transferablesGET /unified/transferablesBatch 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_listGET /unified/batch_borrowableBatch query unified account maximum borrowable amount
list_unified_loansGET /unified/loansQuery loans
create_unified_loanPOST /unified/loansBorrow or repay
list_unified_loan_recordsGET /unified/loan_recordsQuery loan records
list_unified_loan_interest_recordsGET /unified/interest_recordsQuery interest deduction records
get_unified_risk_unitsGET /unified/risk_unitsGet user risk unit details
get_unified_modeGET /unified/unified_modeQuery mode of the unified account
set_unified_modePUT /unified/unified_modeSet unified account mode
get_unified_estimate_rateGET /unified/estimate_rateQuery unified account estimated interest rate
list_currency_discount_tiersGET /unified/currency_discount_tiersQuery unified account tiered
list_loan_margin_tiersGET /unified/loan_margin_tiersQuery unified account tiered loan margin
calculate_portfolio_marginPOST /unified/portfolio_calculatorPortfolio margin calculator
set_user_leveragePOST /unified/leverage/user_settingSet leverage for all of the user's borrowed currencies
get_user_leverage_currency_configGET /unified/leverage/user_currency_configMaximum and minimum currency leverage that can be set
get_user_leverage_currency_settingGET /unified/leverage/user_currency_settingGet user currency leverage
set_user_leverage_currency_settingPOST /unified/leverage/user_currency_settingSet loan currency leverage
list_unified_currenciesGET /unified/currenciesList of loan currencies supported by unified account
get_history_loan_rateGET /unified/history_loan_rateGet historical lending rates
set_unified_collateralPOST /unified/collateral_currenciesSet collateral currency
get_estimated_quick_repaymentGET /unified/estimated_quick_repaymentEstimated quick repayment details
create_quick_repaymentPOST /unified/quick_repaymentQuick repayment
get_unified_delta_neutralGET /unified/delta_neutralQuery the account Delta-neutral strategy mode setting
set_unified_delta_neutralPOST /unified/delta_neutralSet the account Delta-neutral strategy mode

list_unified_accounts

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.

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
sub_uidstrSub account user ID[optional]

Return type

UnifiedAccount

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable

UnifiedBorrowable get_unified_borrowable(currency)

Query maximum borrowable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferable

UnifiedTransferable get_unified_transferable(currency)

Query maximum transferable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferables

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

Example

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

Parameters

NameTypeDescriptionNotes
currenciesstrSpecify 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable_list

list[UnifiedBorrowable] get_unified_borrowable_list(currencies)

Batch query unified account maximum borrowable amount

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

list[UnifiedBorrowable]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loans

list[UniLoan] list_unified_loans(currency=currency, page=page, limit=limit, type=type)

Query loans

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
typestrLoan type: platform borrowing - platform, margin borrowing - margin[optional]

Return type

list[UniLoan]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

create_unified_loan

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

Example

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

Parameters

NameTypeDescriptionNotes
unified_loanUnifiedLoan

Return type

UnifiedLoanResult

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Operation successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_records

list[UnifiedLoanRecord] list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)

Query loan records

Example

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

Parameters

NameTypeDescriptionNotes
typestrLoan record type: borrow - borrowing, repay - repayment[optional]
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_interest_records

list[UniLoanInterestRecord] list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)

Query interest deduction records

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
_fromintStart timestamp for the query[optional]
tointEnd timestamp for the query, defaults to current time if not specified[optional]
typestrLoan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified[optional]

Return type

list[UniLoanInterestRecord]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_risk_units

UnifiedRiskUnits get_unified_risk_units()

Get user risk unit details

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_mode

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_mode

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" } ```

Example

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

Parameters

NameTypeDescriptionNotes
unified_mode_setUnifiedModeSet

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_estimate_rate

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

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

dict(str, str)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_currency_discount_tiers

list[UnifiedDiscount] list_currency_discount_tiers()

Query unified account tiered

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_loan_margin_tiers

list[UnifiedMarginTiers] list_loan_margin_tiers()

Query unified account tiered loan margin

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

calculate_portfolio_margin

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.

Example

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)

Parameters

NameTypeDescriptionNotes
unified_portfolio_inputUnifiedPortfolioInput

Return type

UnifiedPortfolioOutput

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage

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.

Example

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

Parameters

NameTypeDescriptionNotes
user_leverage_settingUserLeverageSetting

Return type

list[LeverageFailedCurrencies]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_config

UnifiedLeverageConfig get_user_leverage_currency_config(currency)

Maximum and minimum currency leverage that can be set

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency

Return type

UnifiedLeverageConfig

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_setting

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

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedLeverageSetting]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage_currency_setting

set_user_leverage_currency_setting(unified_leverage_setting)

Set loan currency leverage

Example

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

Parameters

NameTypeDescriptionNotes
unified_leverage_settingUnifiedLeverageSetting

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_currencies

list[UnifiedCurrency] list_unified_currencies(currency=currency)

List of loan currencies supported by unified account

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedCurrency]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_history_loan_rate

UnifiedHistoryLoanRate get_history_loan_rate(currency, tier=tier, page=page, limit=limit)

Get historical lending rates

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency
tierstrVIP level for the floating rate to be queried[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_collateral

UnifiedCollateralRes set_unified_collateral(unified_collateral_req)

Set collateral currency

Example

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

Parameters

NameTypeDescriptionNotes
unified_collateral_reqUnifiedCollateralReq

Return type

UnifiedCollateralRes

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Updated successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_estimated_quick_repayment

QuickEstimatedRepayment get_estimated_quick_repayment()

Estimated quick repayment details

Available for unified account cross-currency margin mode and portfolio margin mode

Example

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

Parameters

This endpoint does not need any parameter.

Return type

QuickEstimatedRepayment

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

create_quick_repayment

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.

Example

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

Parameters

NameTypeDescriptionNotes
quick_repayment_requestQuickRepaymentRequest

Return type

QuickRepaymentResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Repayment successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_delta_neutral

DeltaNeutralEnabled get_unified_delta_neutral()

Query the account Delta-neutral strategy mode setting

Example

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

Parameters

This endpoint does not need any parameter.

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
401Authentication failed-
403Access 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]

set_unified_delta_neutral

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.

Example

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

Parameters

NameTypeDescriptionNotes
delta_neutral_enabledDeltaNeutralEnabled

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-
400Invalid request parameters-
401Authentication failed-
403Access 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]

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
gateapi-python/docs/UnifiedApi.md at master · gate/gateapi-python · GitHub
Skip to content

Latest commit

History

History
1838 lines (1374 loc) · 66 KB

File metadata and controls

1838 lines (1374 loc) · 66 KB

gate_api.UnifiedApi

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

MethodHTTP requestDescription
list_unified_accountsGET /unified/accountsGet unified account information
get_unified_borrowableGET /unified/borrowableQuery maximum borrowable amount for unified account
get_unified_transferableGET /unified/transferableQuery maximum transferable amount for unified account
get_unified_transferablesGET /unified/transferablesBatch 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_listGET /unified/batch_borrowableBatch query unified account maximum borrowable amount
list_unified_loansGET /unified/loansQuery loans
create_unified_loanPOST /unified/loansBorrow or repay
list_unified_loan_recordsGET /unified/loan_recordsQuery loan records
list_unified_loan_interest_recordsGET /unified/interest_recordsQuery interest deduction records
get_unified_risk_unitsGET /unified/risk_unitsGet user risk unit details
get_unified_modeGET /unified/unified_modeQuery mode of the unified account
set_unified_modePUT /unified/unified_modeSet unified account mode
get_unified_estimate_rateGET /unified/estimate_rateQuery unified account estimated interest rate
list_currency_discount_tiersGET /unified/currency_discount_tiersQuery unified account tiered
list_loan_margin_tiersGET /unified/loan_margin_tiersQuery unified account tiered loan margin
calculate_portfolio_marginPOST /unified/portfolio_calculatorPortfolio margin calculator
set_user_leveragePOST /unified/leverage/user_settingSet leverage for all of the user's borrowed currencies
get_user_leverage_currency_configGET /unified/leverage/user_currency_configMaximum and minimum currency leverage that can be set
get_user_leverage_currency_settingGET /unified/leverage/user_currency_settingGet user currency leverage
set_user_leverage_currency_settingPOST /unified/leverage/user_currency_settingSet loan currency leverage
list_unified_currenciesGET /unified/currenciesList of loan currencies supported by unified account
get_history_loan_rateGET /unified/history_loan_rateGet historical lending rates
set_unified_collateralPOST /unified/collateral_currenciesSet collateral currency
get_estimated_quick_repaymentGET /unified/estimated_quick_repaymentEstimated quick repayment details
create_quick_repaymentPOST /unified/quick_repaymentQuick repayment
get_unified_delta_neutralGET /unified/delta_neutralQuery the account Delta-neutral strategy mode setting
set_unified_delta_neutralPOST /unified/delta_neutralSet the account Delta-neutral strategy mode

list_unified_accounts

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.

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
sub_uidstrSub account user ID[optional]

Return type

UnifiedAccount

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable

UnifiedBorrowable get_unified_borrowable(currency)

Query maximum borrowable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferable

UnifiedTransferable get_unified_transferable(currency)

Query maximum transferable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferables

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

Example

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

Parameters

NameTypeDescriptionNotes
currenciesstrSpecify 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable_list

list[UnifiedBorrowable] get_unified_borrowable_list(currencies)

Batch query unified account maximum borrowable amount

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

list[UnifiedBorrowable]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loans

list[UniLoan] list_unified_loans(currency=currency, page=page, limit=limit, type=type)

Query loans

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
typestrLoan type: platform borrowing - platform, margin borrowing - margin[optional]

Return type

list[UniLoan]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

create_unified_loan

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

Example

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

Parameters

NameTypeDescriptionNotes
unified_loanUnifiedLoan

Return type

UnifiedLoanResult

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Operation successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_records

list[UnifiedLoanRecord] list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)

Query loan records

Example

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

Parameters

NameTypeDescriptionNotes
typestrLoan record type: borrow - borrowing, repay - repayment[optional]
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_interest_records

list[UniLoanInterestRecord] list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)

Query interest deduction records

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
_fromintStart timestamp for the query[optional]
tointEnd timestamp for the query, defaults to current time if not specified[optional]
typestrLoan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified[optional]

Return type

list[UniLoanInterestRecord]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_risk_units

UnifiedRiskUnits get_unified_risk_units()

Get user risk unit details

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_mode

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_mode

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" } ```

Example

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

Parameters

NameTypeDescriptionNotes
unified_mode_setUnifiedModeSet

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_estimate_rate

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

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

dict(str, str)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_currency_discount_tiers

list[UnifiedDiscount] list_currency_discount_tiers()

Query unified account tiered

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_loan_margin_tiers

list[UnifiedMarginTiers] list_loan_margin_tiers()

Query unified account tiered loan margin

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

calculate_portfolio_margin

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.

Example

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)

Parameters

NameTypeDescriptionNotes
unified_portfolio_inputUnifiedPortfolioInput

Return type

UnifiedPortfolioOutput

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage

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.

Example

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

Parameters

NameTypeDescriptionNotes
user_leverage_settingUserLeverageSetting

Return type

list[LeverageFailedCurrencies]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_config

UnifiedLeverageConfig get_user_leverage_currency_config(currency)

Maximum and minimum currency leverage that can be set

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency

Return type

UnifiedLeverageConfig

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_setting

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

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedLeverageSetting]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage_currency_setting

set_user_leverage_currency_setting(unified_leverage_setting)

Set loan currency leverage

Example

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

Parameters

NameTypeDescriptionNotes
unified_leverage_settingUnifiedLeverageSetting

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_currencies

list[UnifiedCurrency] list_unified_currencies(currency=currency)

List of loan currencies supported by unified account

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedCurrency]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_history_loan_rate

UnifiedHistoryLoanRate get_history_loan_rate(currency, tier=tier, page=page, limit=limit)

Get historical lending rates

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency
tierstrVIP level for the floating rate to be queried[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_collateral

UnifiedCollateralRes set_unified_collateral(unified_collateral_req)

Set collateral currency

Example

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

Parameters

NameTypeDescriptionNotes
unified_collateral_reqUnifiedCollateralReq

Return type

UnifiedCollateralRes

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Updated successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_estimated_quick_repayment

QuickEstimatedRepayment get_estimated_quick_repayment()

Estimated quick repayment details

Available for unified account cross-currency margin mode and portfolio margin mode

Example

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

Parameters

This endpoint does not need any parameter.

Return type

QuickEstimatedRepayment

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

create_quick_repayment

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.

Example

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

Parameters

NameTypeDescriptionNotes
quick_repayment_requestQuickRepaymentRequest

Return type

QuickRepaymentResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Repayment successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_delta_neutral

DeltaNeutralEnabled get_unified_delta_neutral()

Query the account Delta-neutral strategy mode setting

Example

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

Parameters

This endpoint does not need any parameter.

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
401Authentication failed-
403Access 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]

set_unified_delta_neutral

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.

Example

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

Parameters

NameTypeDescriptionNotes
delta_neutral_enabledDeltaNeutralEnabled

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-
400Invalid request parameters-
401Authentication failed-
403Access 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]

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' gateapi-python/docs/UnifiedApi.md at master · gate/gateapi-python · GitHub
Skip to content

Latest commit

History

History
1838 lines (1374 loc) · 66 KB

File metadata and controls

1838 lines (1374 loc) · 66 KB

gate_api.UnifiedApi

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

MethodHTTP requestDescription
list_unified_accountsGET /unified/accountsGet unified account information
get_unified_borrowableGET /unified/borrowableQuery maximum borrowable amount for unified account
get_unified_transferableGET /unified/transferableQuery maximum transferable amount for unified account
get_unified_transferablesGET /unified/transferablesBatch 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_listGET /unified/batch_borrowableBatch query unified account maximum borrowable amount
list_unified_loansGET /unified/loansQuery loans
create_unified_loanPOST /unified/loansBorrow or repay
list_unified_loan_recordsGET /unified/loan_recordsQuery loan records
list_unified_loan_interest_recordsGET /unified/interest_recordsQuery interest deduction records
get_unified_risk_unitsGET /unified/risk_unitsGet user risk unit details
get_unified_modeGET /unified/unified_modeQuery mode of the unified account
set_unified_modePUT /unified/unified_modeSet unified account mode
get_unified_estimate_rateGET /unified/estimate_rateQuery unified account estimated interest rate
list_currency_discount_tiersGET /unified/currency_discount_tiersQuery unified account tiered
list_loan_margin_tiersGET /unified/loan_margin_tiersQuery unified account tiered loan margin
calculate_portfolio_marginPOST /unified/portfolio_calculatorPortfolio margin calculator
set_user_leveragePOST /unified/leverage/user_settingSet leverage for all of the user's borrowed currencies
get_user_leverage_currency_configGET /unified/leverage/user_currency_configMaximum and minimum currency leverage that can be set
get_user_leverage_currency_settingGET /unified/leverage/user_currency_settingGet user currency leverage
set_user_leverage_currency_settingPOST /unified/leverage/user_currency_settingSet loan currency leverage
list_unified_currenciesGET /unified/currenciesList of loan currencies supported by unified account
get_history_loan_rateGET /unified/history_loan_rateGet historical lending rates
set_unified_collateralPOST /unified/collateral_currenciesSet collateral currency
get_estimated_quick_repaymentGET /unified/estimated_quick_repaymentEstimated quick repayment details
create_quick_repaymentPOST /unified/quick_repaymentQuick repayment
get_unified_delta_neutralGET /unified/delta_neutralQuery the account Delta-neutral strategy mode setting
set_unified_delta_neutralPOST /unified/delta_neutralSet the account Delta-neutral strategy mode

list_unified_accounts

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.

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
sub_uidstrSub account user ID[optional]

Return type

UnifiedAccount

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable

UnifiedBorrowable get_unified_borrowable(currency)

Query maximum borrowable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferable

UnifiedTransferable get_unified_transferable(currency)

Query maximum transferable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferables

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

Example

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

Parameters

NameTypeDescriptionNotes
currenciesstrSpecify 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable_list

list[UnifiedBorrowable] get_unified_borrowable_list(currencies)

Batch query unified account maximum borrowable amount

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

list[UnifiedBorrowable]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loans

list[UniLoan] list_unified_loans(currency=currency, page=page, limit=limit, type=type)

Query loans

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
typestrLoan type: platform borrowing - platform, margin borrowing - margin[optional]

Return type

list[UniLoan]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

create_unified_loan

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

Example

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

Parameters

NameTypeDescriptionNotes
unified_loanUnifiedLoan

Return type

UnifiedLoanResult

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Operation successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_records

list[UnifiedLoanRecord] list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)

Query loan records

Example

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

Parameters

NameTypeDescriptionNotes
typestrLoan record type: borrow - borrowing, repay - repayment[optional]
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_interest_records

list[UniLoanInterestRecord] list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)

Query interest deduction records

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
_fromintStart timestamp for the query[optional]
tointEnd timestamp for the query, defaults to current time if not specified[optional]
typestrLoan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified[optional]

Return type

list[UniLoanInterestRecord]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_risk_units

UnifiedRiskUnits get_unified_risk_units()

Get user risk unit details

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_mode

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_mode

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" } ```

Example

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

Parameters

NameTypeDescriptionNotes
unified_mode_setUnifiedModeSet

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_estimate_rate

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

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

dict(str, str)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_currency_discount_tiers

list[UnifiedDiscount] list_currency_discount_tiers()

Query unified account tiered

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_loan_margin_tiers

list[UnifiedMarginTiers] list_loan_margin_tiers()

Query unified account tiered loan margin

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

calculate_portfolio_margin

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.

Example

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)

Parameters

NameTypeDescriptionNotes
unified_portfolio_inputUnifiedPortfolioInput

Return type

UnifiedPortfolioOutput

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage

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.

Example

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

Parameters

NameTypeDescriptionNotes
user_leverage_settingUserLeverageSetting

Return type

list[LeverageFailedCurrencies]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_config

UnifiedLeverageConfig get_user_leverage_currency_config(currency)

Maximum and minimum currency leverage that can be set

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency

Return type

UnifiedLeverageConfig

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_setting

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

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedLeverageSetting]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage_currency_setting

set_user_leverage_currency_setting(unified_leverage_setting)

Set loan currency leverage

Example

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

Parameters

NameTypeDescriptionNotes
unified_leverage_settingUnifiedLeverageSetting

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_currencies

list[UnifiedCurrency] list_unified_currencies(currency=currency)

List of loan currencies supported by unified account

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedCurrency]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_history_loan_rate

UnifiedHistoryLoanRate get_history_loan_rate(currency, tier=tier, page=page, limit=limit)

Get historical lending rates

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency
tierstrVIP level for the floating rate to be queried[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_collateral

UnifiedCollateralRes set_unified_collateral(unified_collateral_req)

Set collateral currency

Example

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

Parameters

NameTypeDescriptionNotes
unified_collateral_reqUnifiedCollateralReq

Return type

UnifiedCollateralRes

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Updated successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_estimated_quick_repayment

QuickEstimatedRepayment get_estimated_quick_repayment()

Estimated quick repayment details

Available for unified account cross-currency margin mode and portfolio margin mode

Example

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

Parameters

This endpoint does not need any parameter.

Return type

QuickEstimatedRepayment

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

create_quick_repayment

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.

Example

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

Parameters

NameTypeDescriptionNotes
quick_repayment_requestQuickRepaymentRequest

Return type

QuickRepaymentResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Repayment successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_delta_neutral

DeltaNeutralEnabled get_unified_delta_neutral()

Query the account Delta-neutral strategy mode setting

Example

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

Parameters

This endpoint does not need any parameter.

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
401Authentication failed-
403Access 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]

set_unified_delta_neutral

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.

Example

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

Parameters

NameTypeDescriptionNotes
delta_neutral_enabledDeltaNeutralEnabled

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-
400Invalid request parameters-
401Authentication failed-
403Access 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]

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' gateapi-python/docs/UnifiedApi.md at master · gate/gateapi-python · GitHub
Skip to content

Latest commit

History

History
1838 lines (1374 loc) · 66 KB

File metadata and controls

1838 lines (1374 loc) · 66 KB

gate_api.UnifiedApi

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

MethodHTTP requestDescription
list_unified_accountsGET /unified/accountsGet unified account information
get_unified_borrowableGET /unified/borrowableQuery maximum borrowable amount for unified account
get_unified_transferableGET /unified/transferableQuery maximum transferable amount for unified account
get_unified_transferablesGET /unified/transferablesBatch 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_listGET /unified/batch_borrowableBatch query unified account maximum borrowable amount
list_unified_loansGET /unified/loansQuery loans
create_unified_loanPOST /unified/loansBorrow or repay
list_unified_loan_recordsGET /unified/loan_recordsQuery loan records
list_unified_loan_interest_recordsGET /unified/interest_recordsQuery interest deduction records
get_unified_risk_unitsGET /unified/risk_unitsGet user risk unit details
get_unified_modeGET /unified/unified_modeQuery mode of the unified account
set_unified_modePUT /unified/unified_modeSet unified account mode
get_unified_estimate_rateGET /unified/estimate_rateQuery unified account estimated interest rate
list_currency_discount_tiersGET /unified/currency_discount_tiersQuery unified account tiered
list_loan_margin_tiersGET /unified/loan_margin_tiersQuery unified account tiered loan margin
calculate_portfolio_marginPOST /unified/portfolio_calculatorPortfolio margin calculator
set_user_leveragePOST /unified/leverage/user_settingSet leverage for all of the user's borrowed currencies
get_user_leverage_currency_configGET /unified/leverage/user_currency_configMaximum and minimum currency leverage that can be set
get_user_leverage_currency_settingGET /unified/leverage/user_currency_settingGet user currency leverage
set_user_leverage_currency_settingPOST /unified/leverage/user_currency_settingSet loan currency leverage
list_unified_currenciesGET /unified/currenciesList of loan currencies supported by unified account
get_history_loan_rateGET /unified/history_loan_rateGet historical lending rates
set_unified_collateralPOST /unified/collateral_currenciesSet collateral currency
get_estimated_quick_repaymentGET /unified/estimated_quick_repaymentEstimated quick repayment details
create_quick_repaymentPOST /unified/quick_repaymentQuick repayment
get_unified_delta_neutralGET /unified/delta_neutralQuery the account Delta-neutral strategy mode setting
set_unified_delta_neutralPOST /unified/delta_neutralSet the account Delta-neutral strategy mode

list_unified_accounts

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.

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
sub_uidstrSub account user ID[optional]

Return type

UnifiedAccount

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable

UnifiedBorrowable get_unified_borrowable(currency)

Query maximum borrowable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferable

UnifiedTransferable get_unified_transferable(currency)

Query maximum transferable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferables

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

Example

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

Parameters

NameTypeDescriptionNotes
currenciesstrSpecify 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable_list

list[UnifiedBorrowable] get_unified_borrowable_list(currencies)

Batch query unified account maximum borrowable amount

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

list[UnifiedBorrowable]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loans

list[UniLoan] list_unified_loans(currency=currency, page=page, limit=limit, type=type)

Query loans

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
typestrLoan type: platform borrowing - platform, margin borrowing - margin[optional]

Return type

list[UniLoan]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

create_unified_loan

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

Example

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

Parameters

NameTypeDescriptionNotes
unified_loanUnifiedLoan

Return type

UnifiedLoanResult

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Operation successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_records

list[UnifiedLoanRecord] list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)

Query loan records

Example

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

Parameters

NameTypeDescriptionNotes
typestrLoan record type: borrow - borrowing, repay - repayment[optional]
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_interest_records

list[UniLoanInterestRecord] list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)

Query interest deduction records

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
_fromintStart timestamp for the query[optional]
tointEnd timestamp for the query, defaults to current time if not specified[optional]
typestrLoan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified[optional]

Return type

list[UniLoanInterestRecord]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_risk_units

UnifiedRiskUnits get_unified_risk_units()

Get user risk unit details

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_mode

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_mode

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" } ```

Example

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

Parameters

NameTypeDescriptionNotes
unified_mode_setUnifiedModeSet

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_estimate_rate

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

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

dict(str, str)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_currency_discount_tiers

list[UnifiedDiscount] list_currency_discount_tiers()

Query unified account tiered

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_loan_margin_tiers

list[UnifiedMarginTiers] list_loan_margin_tiers()

Query unified account tiered loan margin

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

calculate_portfolio_margin

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.

Example

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)

Parameters

NameTypeDescriptionNotes
unified_portfolio_inputUnifiedPortfolioInput

Return type

UnifiedPortfolioOutput

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage

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.

Example

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

Parameters

NameTypeDescriptionNotes
user_leverage_settingUserLeverageSetting

Return type

list[LeverageFailedCurrencies]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_config

UnifiedLeverageConfig get_user_leverage_currency_config(currency)

Maximum and minimum currency leverage that can be set

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency

Return type

UnifiedLeverageConfig

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_setting

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

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedLeverageSetting]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage_currency_setting

set_user_leverage_currency_setting(unified_leverage_setting)

Set loan currency leverage

Example

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

Parameters

NameTypeDescriptionNotes
unified_leverage_settingUnifiedLeverageSetting

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_currencies

list[UnifiedCurrency] list_unified_currencies(currency=currency)

List of loan currencies supported by unified account

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedCurrency]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_history_loan_rate

UnifiedHistoryLoanRate get_history_loan_rate(currency, tier=tier, page=page, limit=limit)

Get historical lending rates

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency
tierstrVIP level for the floating rate to be queried[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_collateral

UnifiedCollateralRes set_unified_collateral(unified_collateral_req)

Set collateral currency

Example

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

Parameters

NameTypeDescriptionNotes
unified_collateral_reqUnifiedCollateralReq

Return type

UnifiedCollateralRes

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Updated successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_estimated_quick_repayment

QuickEstimatedRepayment get_estimated_quick_repayment()

Estimated quick repayment details

Available for unified account cross-currency margin mode and portfolio margin mode

Example

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

Parameters

This endpoint does not need any parameter.

Return type

QuickEstimatedRepayment

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

create_quick_repayment

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.

Example

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

Parameters

NameTypeDescriptionNotes
quick_repayment_requestQuickRepaymentRequest

Return type

QuickRepaymentResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Repayment successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_delta_neutral

DeltaNeutralEnabled get_unified_delta_neutral()

Query the account Delta-neutral strategy mode setting

Example

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

Parameters

This endpoint does not need any parameter.

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
401Authentication failed-
403Access 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]

set_unified_delta_neutral

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.

Example

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

Parameters

NameTypeDescriptionNotes
delta_neutral_enabledDeltaNeutralEnabled

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-
400Invalid request parameters-
401Authentication failed-
403Access 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]

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' gateapi-python/docs/UnifiedApi.md at master · gate/gateapi-python · GitHub
Skip to content

Latest commit

History

History
1838 lines (1374 loc) · 66 KB

File metadata and controls

1838 lines (1374 loc) · 66 KB

gate_api.UnifiedApi

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

MethodHTTP requestDescription
list_unified_accountsGET /unified/accountsGet unified account information
get_unified_borrowableGET /unified/borrowableQuery maximum borrowable amount for unified account
get_unified_transferableGET /unified/transferableQuery maximum transferable amount for unified account
get_unified_transferablesGET /unified/transferablesBatch 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_listGET /unified/batch_borrowableBatch query unified account maximum borrowable amount
list_unified_loansGET /unified/loansQuery loans
create_unified_loanPOST /unified/loansBorrow or repay
list_unified_loan_recordsGET /unified/loan_recordsQuery loan records
list_unified_loan_interest_recordsGET /unified/interest_recordsQuery interest deduction records
get_unified_risk_unitsGET /unified/risk_unitsGet user risk unit details
get_unified_modeGET /unified/unified_modeQuery mode of the unified account
set_unified_modePUT /unified/unified_modeSet unified account mode
get_unified_estimate_rateGET /unified/estimate_rateQuery unified account estimated interest rate
list_currency_discount_tiersGET /unified/currency_discount_tiersQuery unified account tiered
list_loan_margin_tiersGET /unified/loan_margin_tiersQuery unified account tiered loan margin
calculate_portfolio_marginPOST /unified/portfolio_calculatorPortfolio margin calculator
set_user_leveragePOST /unified/leverage/user_settingSet leverage for all of the user's borrowed currencies
get_user_leverage_currency_configGET /unified/leverage/user_currency_configMaximum and minimum currency leverage that can be set
get_user_leverage_currency_settingGET /unified/leverage/user_currency_settingGet user currency leverage
set_user_leverage_currency_settingPOST /unified/leverage/user_currency_settingSet loan currency leverage
list_unified_currenciesGET /unified/currenciesList of loan currencies supported by unified account
get_history_loan_rateGET /unified/history_loan_rateGet historical lending rates
set_unified_collateralPOST /unified/collateral_currenciesSet collateral currency
get_estimated_quick_repaymentGET /unified/estimated_quick_repaymentEstimated quick repayment details
create_quick_repaymentPOST /unified/quick_repaymentQuick repayment
get_unified_delta_neutralGET /unified/delta_neutralQuery the account Delta-neutral strategy mode setting
set_unified_delta_neutralPOST /unified/delta_neutralSet the account Delta-neutral strategy mode

list_unified_accounts

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.

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
sub_uidstrSub account user ID[optional]

Return type

UnifiedAccount

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable

UnifiedBorrowable get_unified_borrowable(currency)

Query maximum borrowable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferable

UnifiedTransferable get_unified_transferable(currency)

Query maximum transferable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferables

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

Example

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

Parameters

NameTypeDescriptionNotes
currenciesstrSpecify 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable_list

list[UnifiedBorrowable] get_unified_borrowable_list(currencies)

Batch query unified account maximum borrowable amount

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

list[UnifiedBorrowable]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loans

list[UniLoan] list_unified_loans(currency=currency, page=page, limit=limit, type=type)

Query loans

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
typestrLoan type: platform borrowing - platform, margin borrowing - margin[optional]

Return type

list[UniLoan]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

create_unified_loan

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

Example

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

Parameters

NameTypeDescriptionNotes
unified_loanUnifiedLoan

Return type

UnifiedLoanResult

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Operation successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_records

list[UnifiedLoanRecord] list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)

Query loan records

Example

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

Parameters

NameTypeDescriptionNotes
typestrLoan record type: borrow - borrowing, repay - repayment[optional]
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_interest_records

list[UniLoanInterestRecord] list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)

Query interest deduction records

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
_fromintStart timestamp for the query[optional]
tointEnd timestamp for the query, defaults to current time if not specified[optional]
typestrLoan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified[optional]

Return type

list[UniLoanInterestRecord]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_risk_units

UnifiedRiskUnits get_unified_risk_units()

Get user risk unit details

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_mode

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_mode

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" } ```

Example

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

Parameters

NameTypeDescriptionNotes
unified_mode_setUnifiedModeSet

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_estimate_rate

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

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

dict(str, str)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_currency_discount_tiers

list[UnifiedDiscount] list_currency_discount_tiers()

Query unified account tiered

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_loan_margin_tiers

list[UnifiedMarginTiers] list_loan_margin_tiers()

Query unified account tiered loan margin

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

calculate_portfolio_margin

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.

Example

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)

Parameters

NameTypeDescriptionNotes
unified_portfolio_inputUnifiedPortfolioInput

Return type

UnifiedPortfolioOutput

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage

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.

Example

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

Parameters

NameTypeDescriptionNotes
user_leverage_settingUserLeverageSetting

Return type

list[LeverageFailedCurrencies]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_config

UnifiedLeverageConfig get_user_leverage_currency_config(currency)

Maximum and minimum currency leverage that can be set

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency

Return type

UnifiedLeverageConfig

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_setting

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

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedLeverageSetting]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage_currency_setting

set_user_leverage_currency_setting(unified_leverage_setting)

Set loan currency leverage

Example

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

Parameters

NameTypeDescriptionNotes
unified_leverage_settingUnifiedLeverageSetting

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_currencies

list[UnifiedCurrency] list_unified_currencies(currency=currency)

List of loan currencies supported by unified account

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedCurrency]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_history_loan_rate

UnifiedHistoryLoanRate get_history_loan_rate(currency, tier=tier, page=page, limit=limit)

Get historical lending rates

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency
tierstrVIP level for the floating rate to be queried[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_collateral

UnifiedCollateralRes set_unified_collateral(unified_collateral_req)

Set collateral currency

Example

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

Parameters

NameTypeDescriptionNotes
unified_collateral_reqUnifiedCollateralReq

Return type

UnifiedCollateralRes

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Updated successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_estimated_quick_repayment

QuickEstimatedRepayment get_estimated_quick_repayment()

Estimated quick repayment details

Available for unified account cross-currency margin mode and portfolio margin mode

Example

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

Parameters

This endpoint does not need any parameter.

Return type

QuickEstimatedRepayment

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

create_quick_repayment

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.

Example

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

Parameters

NameTypeDescriptionNotes
quick_repayment_requestQuickRepaymentRequest

Return type

QuickRepaymentResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Repayment successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_delta_neutral

DeltaNeutralEnabled get_unified_delta_neutral()

Query the account Delta-neutral strategy mode setting

Example

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

Parameters

This endpoint does not need any parameter.

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
401Authentication failed-
403Access 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]

set_unified_delta_neutral

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.

Example

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

Parameters

NameTypeDescriptionNotes
delta_neutral_enabledDeltaNeutralEnabled

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-
400Invalid request parameters-
401Authentication failed-
403Access 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]

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' gateapi-python/docs/UnifiedApi.md at master · gate/gateapi-python · GitHub
Skip to content

Latest commit

History

History
1838 lines (1374 loc) · 66 KB

File metadata and controls

1838 lines (1374 loc) · 66 KB

gate_api.UnifiedApi

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

MethodHTTP requestDescription
list_unified_accountsGET /unified/accountsGet unified account information
get_unified_borrowableGET /unified/borrowableQuery maximum borrowable amount for unified account
get_unified_transferableGET /unified/transferableQuery maximum transferable amount for unified account
get_unified_transferablesGET /unified/transferablesBatch 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_listGET /unified/batch_borrowableBatch query unified account maximum borrowable amount
list_unified_loansGET /unified/loansQuery loans
create_unified_loanPOST /unified/loansBorrow or repay
list_unified_loan_recordsGET /unified/loan_recordsQuery loan records
list_unified_loan_interest_recordsGET /unified/interest_recordsQuery interest deduction records
get_unified_risk_unitsGET /unified/risk_unitsGet user risk unit details
get_unified_modeGET /unified/unified_modeQuery mode of the unified account
set_unified_modePUT /unified/unified_modeSet unified account mode
get_unified_estimate_rateGET /unified/estimate_rateQuery unified account estimated interest rate
list_currency_discount_tiersGET /unified/currency_discount_tiersQuery unified account tiered
list_loan_margin_tiersGET /unified/loan_margin_tiersQuery unified account tiered loan margin
calculate_portfolio_marginPOST /unified/portfolio_calculatorPortfolio margin calculator
set_user_leveragePOST /unified/leverage/user_settingSet leverage for all of the user's borrowed currencies
get_user_leverage_currency_configGET /unified/leverage/user_currency_configMaximum and minimum currency leverage that can be set
get_user_leverage_currency_settingGET /unified/leverage/user_currency_settingGet user currency leverage
set_user_leverage_currency_settingPOST /unified/leverage/user_currency_settingSet loan currency leverage
list_unified_currenciesGET /unified/currenciesList of loan currencies supported by unified account
get_history_loan_rateGET /unified/history_loan_rateGet historical lending rates
set_unified_collateralPOST /unified/collateral_currenciesSet collateral currency
get_estimated_quick_repaymentGET /unified/estimated_quick_repaymentEstimated quick repayment details
create_quick_repaymentPOST /unified/quick_repaymentQuick repayment
get_unified_delta_neutralGET /unified/delta_neutralQuery the account Delta-neutral strategy mode setting
set_unified_delta_neutralPOST /unified/delta_neutralSet the account Delta-neutral strategy mode

list_unified_accounts

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.

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
sub_uidstrSub account user ID[optional]

Return type

UnifiedAccount

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable

UnifiedBorrowable get_unified_borrowable(currency)

Query maximum borrowable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferable

UnifiedTransferable get_unified_transferable(currency)

Query maximum transferable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferables

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

Example

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

Parameters

NameTypeDescriptionNotes
currenciesstrSpecify 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable_list

list[UnifiedBorrowable] get_unified_borrowable_list(currencies)

Batch query unified account maximum borrowable amount

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

list[UnifiedBorrowable]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loans

list[UniLoan] list_unified_loans(currency=currency, page=page, limit=limit, type=type)

Query loans

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
typestrLoan type: platform borrowing - platform, margin borrowing - margin[optional]

Return type

list[UniLoan]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

create_unified_loan

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

Example

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

Parameters

NameTypeDescriptionNotes
unified_loanUnifiedLoan

Return type

UnifiedLoanResult

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Operation successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_records

list[UnifiedLoanRecord] list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)

Query loan records

Example

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

Parameters

NameTypeDescriptionNotes
typestrLoan record type: borrow - borrowing, repay - repayment[optional]
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_interest_records

list[UniLoanInterestRecord] list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)

Query interest deduction records

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
_fromintStart timestamp for the query[optional]
tointEnd timestamp for the query, defaults to current time if not specified[optional]
typestrLoan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified[optional]

Return type

list[UniLoanInterestRecord]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_risk_units

UnifiedRiskUnits get_unified_risk_units()

Get user risk unit details

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_mode

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_mode

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" } ```

Example

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

Parameters

NameTypeDescriptionNotes
unified_mode_setUnifiedModeSet

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_estimate_rate

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

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

dict(str, str)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_currency_discount_tiers

list[UnifiedDiscount] list_currency_discount_tiers()

Query unified account tiered

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_loan_margin_tiers

list[UnifiedMarginTiers] list_loan_margin_tiers()

Query unified account tiered loan margin

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

calculate_portfolio_margin

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.

Example

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)

Parameters

NameTypeDescriptionNotes
unified_portfolio_inputUnifiedPortfolioInput

Return type

UnifiedPortfolioOutput

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage

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.

Example

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

Parameters

NameTypeDescriptionNotes
user_leverage_settingUserLeverageSetting

Return type

list[LeverageFailedCurrencies]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_config

UnifiedLeverageConfig get_user_leverage_currency_config(currency)

Maximum and minimum currency leverage that can be set

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency

Return type

UnifiedLeverageConfig

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_setting

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

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedLeverageSetting]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage_currency_setting

set_user_leverage_currency_setting(unified_leverage_setting)

Set loan currency leverage

Example

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

Parameters

NameTypeDescriptionNotes
unified_leverage_settingUnifiedLeverageSetting

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_currencies

list[UnifiedCurrency] list_unified_currencies(currency=currency)

List of loan currencies supported by unified account

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedCurrency]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_history_loan_rate

UnifiedHistoryLoanRate get_history_loan_rate(currency, tier=tier, page=page, limit=limit)

Get historical lending rates

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency
tierstrVIP level for the floating rate to be queried[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_collateral

UnifiedCollateralRes set_unified_collateral(unified_collateral_req)

Set collateral currency

Example

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

Parameters

NameTypeDescriptionNotes
unified_collateral_reqUnifiedCollateralReq

Return type

UnifiedCollateralRes

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Updated successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_estimated_quick_repayment

QuickEstimatedRepayment get_estimated_quick_repayment()

Estimated quick repayment details

Available for unified account cross-currency margin mode and portfolio margin mode

Example

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

Parameters

This endpoint does not need any parameter.

Return type

QuickEstimatedRepayment

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

create_quick_repayment

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.

Example

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

Parameters

NameTypeDescriptionNotes
quick_repayment_requestQuickRepaymentRequest

Return type

QuickRepaymentResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Repayment successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_delta_neutral

DeltaNeutralEnabled get_unified_delta_neutral()

Query the account Delta-neutral strategy mode setting

Example

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

Parameters

This endpoint does not need any parameter.

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
401Authentication failed-
403Access 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]

set_unified_delta_neutral

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.

Example

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

Parameters

NameTypeDescriptionNotes
delta_neutral_enabledDeltaNeutralEnabled

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-
400Invalid request parameters-
401Authentication failed-
403Access 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]

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' gateapi-python/docs/UnifiedApi.md at master · gate/gateapi-python · GitHub
Skip to content

Latest commit

History

History
1838 lines (1374 loc) · 66 KB

File metadata and controls

1838 lines (1374 loc) · 66 KB

gate_api.UnifiedApi

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

MethodHTTP requestDescription
list_unified_accountsGET /unified/accountsGet unified account information
get_unified_borrowableGET /unified/borrowableQuery maximum borrowable amount for unified account
get_unified_transferableGET /unified/transferableQuery maximum transferable amount for unified account
get_unified_transferablesGET /unified/transferablesBatch 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_listGET /unified/batch_borrowableBatch query unified account maximum borrowable amount
list_unified_loansGET /unified/loansQuery loans
create_unified_loanPOST /unified/loansBorrow or repay
list_unified_loan_recordsGET /unified/loan_recordsQuery loan records
list_unified_loan_interest_recordsGET /unified/interest_recordsQuery interest deduction records
get_unified_risk_unitsGET /unified/risk_unitsGet user risk unit details
get_unified_modeGET /unified/unified_modeQuery mode of the unified account
set_unified_modePUT /unified/unified_modeSet unified account mode
get_unified_estimate_rateGET /unified/estimate_rateQuery unified account estimated interest rate
list_currency_discount_tiersGET /unified/currency_discount_tiersQuery unified account tiered
list_loan_margin_tiersGET /unified/loan_margin_tiersQuery unified account tiered loan margin
calculate_portfolio_marginPOST /unified/portfolio_calculatorPortfolio margin calculator
set_user_leveragePOST /unified/leverage/user_settingSet leverage for all of the user's borrowed currencies
get_user_leverage_currency_configGET /unified/leverage/user_currency_configMaximum and minimum currency leverage that can be set
get_user_leverage_currency_settingGET /unified/leverage/user_currency_settingGet user currency leverage
set_user_leverage_currency_settingPOST /unified/leverage/user_currency_settingSet loan currency leverage
list_unified_currenciesGET /unified/currenciesList of loan currencies supported by unified account
get_history_loan_rateGET /unified/history_loan_rateGet historical lending rates
set_unified_collateralPOST /unified/collateral_currenciesSet collateral currency
get_estimated_quick_repaymentGET /unified/estimated_quick_repaymentEstimated quick repayment details
create_quick_repaymentPOST /unified/quick_repaymentQuick repayment
get_unified_delta_neutralGET /unified/delta_neutralQuery the account Delta-neutral strategy mode setting
set_unified_delta_neutralPOST /unified/delta_neutralSet the account Delta-neutral strategy mode

list_unified_accounts

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.

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
sub_uidstrSub account user ID[optional]

Return type

UnifiedAccount

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable

UnifiedBorrowable get_unified_borrowable(currency)

Query maximum borrowable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferable

UnifiedTransferable get_unified_transferable(currency)

Query maximum transferable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferables

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

Example

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

Parameters

NameTypeDescriptionNotes
currenciesstrSpecify 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable_list

list[UnifiedBorrowable] get_unified_borrowable_list(currencies)

Batch query unified account maximum borrowable amount

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

list[UnifiedBorrowable]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loans

list[UniLoan] list_unified_loans(currency=currency, page=page, limit=limit, type=type)

Query loans

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
typestrLoan type: platform borrowing - platform, margin borrowing - margin[optional]

Return type

list[UniLoan]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

create_unified_loan

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

Example

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

Parameters

NameTypeDescriptionNotes
unified_loanUnifiedLoan

Return type

UnifiedLoanResult

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Operation successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_records

list[UnifiedLoanRecord] list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)

Query loan records

Example

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

Parameters

NameTypeDescriptionNotes
typestrLoan record type: borrow - borrowing, repay - repayment[optional]
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_interest_records

list[UniLoanInterestRecord] list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)

Query interest deduction records

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
_fromintStart timestamp for the query[optional]
tointEnd timestamp for the query, defaults to current time if not specified[optional]
typestrLoan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified[optional]

Return type

list[UniLoanInterestRecord]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_risk_units

UnifiedRiskUnits get_unified_risk_units()

Get user risk unit details

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_mode

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_mode

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" } ```

Example

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

Parameters

NameTypeDescriptionNotes
unified_mode_setUnifiedModeSet

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_estimate_rate

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

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

dict(str, str)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_currency_discount_tiers

list[UnifiedDiscount] list_currency_discount_tiers()

Query unified account tiered

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_loan_margin_tiers

list[UnifiedMarginTiers] list_loan_margin_tiers()

Query unified account tiered loan margin

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

calculate_portfolio_margin

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.

Example

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)

Parameters

NameTypeDescriptionNotes
unified_portfolio_inputUnifiedPortfolioInput

Return type

UnifiedPortfolioOutput

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage

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.

Example

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

Parameters

NameTypeDescriptionNotes
user_leverage_settingUserLeverageSetting

Return type

list[LeverageFailedCurrencies]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_config

UnifiedLeverageConfig get_user_leverage_currency_config(currency)

Maximum and minimum currency leverage that can be set

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency

Return type

UnifiedLeverageConfig

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_setting

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

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedLeverageSetting]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage_currency_setting

set_user_leverage_currency_setting(unified_leverage_setting)

Set loan currency leverage

Example

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

Parameters

NameTypeDescriptionNotes
unified_leverage_settingUnifiedLeverageSetting

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_currencies

list[UnifiedCurrency] list_unified_currencies(currency=currency)

List of loan currencies supported by unified account

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedCurrency]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_history_loan_rate

UnifiedHistoryLoanRate get_history_loan_rate(currency, tier=tier, page=page, limit=limit)

Get historical lending rates

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency
tierstrVIP level for the floating rate to be queried[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_collateral

UnifiedCollateralRes set_unified_collateral(unified_collateral_req)

Set collateral currency

Example

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

Parameters

NameTypeDescriptionNotes
unified_collateral_reqUnifiedCollateralReq

Return type

UnifiedCollateralRes

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Updated successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_estimated_quick_repayment

QuickEstimatedRepayment get_estimated_quick_repayment()

Estimated quick repayment details

Available for unified account cross-currency margin mode and portfolio margin mode

Example

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

Parameters

This endpoint does not need any parameter.

Return type

QuickEstimatedRepayment

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

create_quick_repayment

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.

Example

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

Parameters

NameTypeDescriptionNotes
quick_repayment_requestQuickRepaymentRequest

Return type

QuickRepaymentResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Repayment successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_delta_neutral

DeltaNeutralEnabled get_unified_delta_neutral()

Query the account Delta-neutral strategy mode setting

Example

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

Parameters

This endpoint does not need any parameter.

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
401Authentication failed-
403Access 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]

set_unified_delta_neutral

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.

Example

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

Parameters

NameTypeDescriptionNotes
delta_neutral_enabledDeltaNeutralEnabled

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-
400Invalid request parameters-
401Authentication failed-
403Access 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]

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); gateapi-python/docs/UnifiedApi.md at master · gate/gateapi-python · GitHub
Skip to content

Latest commit

History

History
1838 lines (1374 loc) · 66 KB

File metadata and controls

1838 lines (1374 loc) · 66 KB

gate_api.UnifiedApi

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

MethodHTTP requestDescription
list_unified_accountsGET /unified/accountsGet unified account information
get_unified_borrowableGET /unified/borrowableQuery maximum borrowable amount for unified account
get_unified_transferableGET /unified/transferableQuery maximum transferable amount for unified account
get_unified_transferablesGET /unified/transferablesBatch 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_listGET /unified/batch_borrowableBatch query unified account maximum borrowable amount
list_unified_loansGET /unified/loansQuery loans
create_unified_loanPOST /unified/loansBorrow or repay
list_unified_loan_recordsGET /unified/loan_recordsQuery loan records
list_unified_loan_interest_recordsGET /unified/interest_recordsQuery interest deduction records
get_unified_risk_unitsGET /unified/risk_unitsGet user risk unit details
get_unified_modeGET /unified/unified_modeQuery mode of the unified account
set_unified_modePUT /unified/unified_modeSet unified account mode
get_unified_estimate_rateGET /unified/estimate_rateQuery unified account estimated interest rate
list_currency_discount_tiersGET /unified/currency_discount_tiersQuery unified account tiered
list_loan_margin_tiersGET /unified/loan_margin_tiersQuery unified account tiered loan margin
calculate_portfolio_marginPOST /unified/portfolio_calculatorPortfolio margin calculator
set_user_leveragePOST /unified/leverage/user_settingSet leverage for all of the user's borrowed currencies
get_user_leverage_currency_configGET /unified/leverage/user_currency_configMaximum and minimum currency leverage that can be set
get_user_leverage_currency_settingGET /unified/leverage/user_currency_settingGet user currency leverage
set_user_leverage_currency_settingPOST /unified/leverage/user_currency_settingSet loan currency leverage
list_unified_currenciesGET /unified/currenciesList of loan currencies supported by unified account
get_history_loan_rateGET /unified/history_loan_rateGet historical lending rates
set_unified_collateralPOST /unified/collateral_currenciesSet collateral currency
get_estimated_quick_repaymentGET /unified/estimated_quick_repaymentEstimated quick repayment details
create_quick_repaymentPOST /unified/quick_repaymentQuick repayment
get_unified_delta_neutralGET /unified/delta_neutralQuery the account Delta-neutral strategy mode setting
set_unified_delta_neutralPOST /unified/delta_neutralSet the account Delta-neutral strategy mode

list_unified_accounts

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.

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
sub_uidstrSub account user ID[optional]

Return type

UnifiedAccount

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable

UnifiedBorrowable get_unified_borrowable(currency)

Query maximum borrowable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedBorrowable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferable

UnifiedTransferable get_unified_transferable(currency)

Query maximum transferable amount for unified account

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name

Return type

UnifiedTransferable

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_transferables

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

Example

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

Parameters

NameTypeDescriptionNotes
currenciesstrSpecify 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_borrowable_list

list[UnifiedBorrowable] get_unified_borrowable_list(currencies)

Batch query unified account maximum borrowable amount

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

list[UnifiedBorrowable]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loans

list[UniLoan] list_unified_loans(currency=currency, page=page, limit=limit, type=type)

Query loans

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
typestrLoan type: platform borrowing - platform, margin borrowing - margin[optional]

Return type

list[UniLoan]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

create_unified_loan

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

Example

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

Parameters

NameTypeDescriptionNotes
unified_loanUnifiedLoan

Return type

UnifiedLoanResult

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Operation successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_records

list[UnifiedLoanRecord] list_unified_loan_records(type=type, currency=currency, page=page, limit=limit)

Query loan records

Example

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

Parameters

NameTypeDescriptionNotes
typestrLoan record type: borrow - borrowing, repay - repayment[optional]
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_loan_interest_records

list[UniLoanInterestRecord] list_unified_loan_interest_records(currency=currency, page=page, limit=limit, _from=_from, to=to, type=type)

Query interest deduction records

Example

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

Parameters

NameTypeDescriptionNotes
currencystrQuery by specified currency name[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. Default: 100, minimum: 1, maximum: 100[optional] [default to 100]
_fromintStart timestamp for the query[optional]
tointEnd timestamp for the query, defaults to current time if not specified[optional]
typestrLoan type: platform borrowing - platform, margin borrowing - margin. Defaults to margin if not specified[optional]

Return type

list[UniLoanInterestRecord]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_risk_units

UnifiedRiskUnits get_unified_risk_units()

Get user risk unit details

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_mode

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

Example

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

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_mode

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" } ```

Example

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

Parameters

NameTypeDescriptionNotes
unified_mode_setUnifiedModeSet

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_estimate_rate

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

Example

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

Parameters

NameTypeDescriptionNotes
currencieslist[str]Specify currency names for querying in an array, separated by commas, maximum 10 currencies

Return type

dict(str, str)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_currency_discount_tiers

list[UnifiedDiscount] list_currency_discount_tiers()

Query unified account tiered

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

list_loan_margin_tiers

list[UnifiedMarginTiers] list_loan_margin_tiers()

Query unified account tiered loan margin

Example

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)

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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

calculate_portfolio_margin

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.

Example

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)

Parameters

NameTypeDescriptionNotes
unified_portfolio_inputUnifiedPortfolioInput

Return type

UnifiedPortfolioOutput

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage

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.

Example

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

Parameters

NameTypeDescriptionNotes
user_leverage_settingUserLeverageSetting

Return type

list[LeverageFailedCurrencies]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_config

UnifiedLeverageConfig get_user_leverage_currency_config(currency)

Maximum and minimum currency leverage that can be set

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency

Return type

UnifiedLeverageConfig

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

get_user_leverage_currency_setting

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

Example

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

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedLeverageSetting]

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_user_leverage_currency_setting

set_user_leverage_currency_setting(unified_leverage_setting)

Set loan currency leverage

Example

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

Parameters

NameTypeDescriptionNotes
unified_leverage_settingUnifiedLeverageSetting

Return type

void (empty response body)

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
204Set successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

list_unified_currencies

list[UnifiedCurrency] list_unified_currencies(currency=currency)

List of loan currencies supported by unified account

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency[optional]

Return type

list[UnifiedCurrency]

Authorization

No authorization required

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200List retrieved successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_history_loan_rate

UnifiedHistoryLoanRate get_history_loan_rate(currency, tier=tier, page=page, limit=limit)

Get historical lending rates

Example

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)

Parameters

NameTypeDescriptionNotes
currencystrCurrency
tierstrVIP level for the floating rate to be queried[optional]
pageintPage number[optional] [default to 1]
limitintMaximum number of items returned. 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 codeDescriptionResponse headers
200Query successful-

[Back to top][Back to API list][Back to Model list][Back to README]

set_unified_collateral

UnifiedCollateralRes set_unified_collateral(unified_collateral_req)

Set collateral currency

Example

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

Parameters

NameTypeDescriptionNotes
unified_collateral_reqUnifiedCollateralReq

Return type

UnifiedCollateralRes

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Updated successfully-

[Back to top][Back to API list][Back to Model list][Back to README]

get_estimated_quick_repayment

QuickEstimatedRepayment get_estimated_quick_repayment()

Estimated quick repayment details

Available for unified account cross-currency margin mode and portfolio margin mode

Example

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

Parameters

This endpoint does not need any parameter.

Return type

QuickEstimatedRepayment

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

create_quick_repayment

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.

Example

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

Parameters

NameTypeDescriptionNotes
quick_repayment_requestQuickRepaymentRequest

Return type

QuickRepaymentResponse

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Repayment successful-
400Invalid request parameters-
401Authentication failed-
403Access denied (e.g. account mode does not support quick repayment)-

[Back to top][Back to API list][Back to Model list][Back to README]

get_unified_delta_neutral

DeltaNeutralEnabled get_unified_delta_neutral()

Query the account Delta-neutral strategy mode setting

Example

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

Parameters

This endpoint does not need any parameter.

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Query successful-
401Authentication failed-
403Access 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]

set_unified_delta_neutral

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.

Example

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

Parameters

NameTypeDescriptionNotes
delta_neutral_enabledDeltaNeutralEnabled

Return type

DeltaNeutralEnabled

Authorization

apiv4

HTTP request headers

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

HTTP response details

Status codeDescriptionResponse headers
200Set successfully-
400Invalid request parameters-
401Authentication failed-
403Access 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]