All URIs are relative to https://api.gateio.ws/api/v4
| Method | HTTP request | Description |
|---|---|---|
| list_margin_accounts | GET /margin/accounts | Margin account list |
| list_margin_account_book | GET /margin/account_book | Query margin account balance change history |
| list_funding_accounts | GET /margin/funding_accounts | Funding account list |
| get_auto_repay_status | GET /margin/auto_repay | Query user auto repayment settings |
| set_auto_repay | POST /margin/auto_repay | Update user auto repayment settings |
| get_margin_transferable | GET /margin/transferable | Get maximum transferable amount for isolated margin |
| get_user_margin_tier | GET /margin/user/loan_margin_tiers | Query user's own leverage lending tiers in current market |
| get_market_margin_tier | GET /margin/loan_margin_tiers | Query current market leverage lending tiers |
| set_user_market_leverage | POST /margin/leverage/user_market_setting | Set user market leverage multiplier |
| list_margin_user_account | GET /margin/user/account | Query user's isolated margin account list |
| list_cross_margin_loans | GET /margin/cross/loans | Query cross margin borrow history (deprecated) |
| list_cross_margin_repayments | GET /margin/cross/repayments | Retrieve cross margin repayments. (deprecated) |
list[MarginAccount] list_margin_accounts(currency_pair=currency_pair)
Margin account list
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair (optional)
try:
# Margin account list
api_response = api_instance.list_margin_accounts(currency_pair=currency_pair)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->list_margin_accounts: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved successfully | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[MarginAccountBook] list_margin_account_book(currency=currency, currency_pair=currency_pair, type=type, _from=_from, to=to, page=page, limit=limit)
Query margin account balance change history
Currently only provides transfer history to and from margin accounts. Query time range cannot exceed 30 days
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
currency = 'currency_example' # str | Query history for specified currency. If `currency` is specified, `currency_pair` must also be specified. (optional)
currency_pair = 'currency_pair_example' # str | Specify margin account currency pair. Used in combination with `currency`. Ignored if `currency` is not specified (optional)
type = 'lend' # str | Query by specified account change type. If not specified, all change types will be included. (optional)
_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)
page = 1 # int | Page number (optional) (default to 1)
limit = 100 # int | Maximum number of records returned in a single list (optional) (default to 100)
try:
# Query margin account balance change history
api_response = api_instance.list_margin_account_book(currency=currency, currency_pair=currency_pair, type=type, _from=_from, to=to, page=page, limit=limit)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->list_margin_account_book: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Query history for specified currency. If `currency` is specified, `currency_pair` must also be specified. | [optional] |
| currency_pair | str | Specify margin account currency pair. Used in combination with `currency`. Ignored if `currency` is not specified | [optional] |
| type | str | Query by specified account change type. If not specified, all change types will be included. | [optional] |
| _from | int | Start timestamp for the query | [optional] |
| to | int | End timestamp for the query, defaults to current time if not specified | [optional] |
| page | int | Page number | [optional] [default to 1] |
| limit | int | Maximum number of records returned in a single list | [optional] [default to 100] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved successfully | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[FundingAccount] list_funding_accounts(currency=currency)
Funding account list
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
currency = 'BTC' # str | Query by specified currency name (optional)
try:
# Funding account list
api_response = api_instance.list_funding_accounts(currency=currency)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->list_funding_accounts: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Query by specified currency name | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved successfully | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AutoRepaySetting get_auto_repay_status()
Query user auto repayment settings
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
try:
# Query user auto repayment settings
api_response = api_instance.get_auto_repay_status()
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->get_auto_repay_status: %s\n" % e)This endpoint does not need any parameter.
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | User's current auto repayment settings | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AutoRepaySetting set_auto_repay(status)
Update user auto repayment settings
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
status = 'on' # str | Whether to enable auto repayment: `on` - enabled, `off` - disabled
try:
# Update user auto repayment settings
api_response = api_instance.set_auto_repay(status)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->set_auto_repay: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| status | str | Whether to enable auto repayment: `on` - enabled, `off` - disabled |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | User's current auto repayment settings | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
MarginTransferable get_margin_transferable(currency, currency_pair=currency_pair)
Get maximum transferable amount for isolated margin
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
currency = 'BTC' # str | Query by specified currency name
currency_pair = 'BTC_USDT' # str | Currency pair (optional)
try:
# Get maximum transferable amount for isolated margin
api_response = api_instance.get_margin_transferable(currency, currency_pair=currency_pair)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->get_margin_transferable: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Query by specified currency name | |
| currency_pair | str | Currency pair | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[MarginLeverageTier] get_user_margin_tier(currency_pair)
Query user's own leverage lending tiers in current market
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair
try:
# Query user's own leverage lending tiers in current market
api_response = api_instance.get_user_margin_tier(currency_pair)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->get_user_margin_tier: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[MarginLeverageTier] get_market_margin_tier(currency_pair)
Query current market leverage lending tiers
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 class
api_instance = gate_api.MarginApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair
try:
# Query current market leverage lending tiers
api_response = api_instance.get_market_margin_tier(currency_pair)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->get_market_margin_tier: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
set_user_market_leverage(margin_market_leverage)
Set user market leverage multiplier
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
margin_market_leverage = gate_api.MarginMarketLeverage() # MarginMarketLeverage |
try:
# Set user market leverage multiplier
api_instance.set_user_market_leverage(margin_market_leverage)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->set_user_market_leverage: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| margin_market_leverage | MarginMarketLeverage |
void (empty response body)
- Content-Type: application/json
- Accept: Not defined
| Status code | Description | Response headers |
|---|---|---|
| 204 | Set successfully | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[MarginAccount] list_margin_user_account(currency_pair=currency_pair)
Query user's isolated margin account list
Supports querying risk ratio isolated accounts and margin ratio isolated accounts
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair (optional)
try:
# Query user's isolated margin account list
api_response = api_instance.list_margin_user_account(currency_pair=currency_pair)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->list_margin_user_account: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved successfully | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[CrossMarginLoan] list_cross_margin_loans(status, currency=currency, limit=limit, offset=offset, reverse=reverse)
Query cross margin borrow history (deprecated)
Sorted by creation time in descending order by default. Set reverse=false for ascending order
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
status = 56 # int | Filter by status. Supported values are 2 and 3. (deprecated.)
currency = 'currency_example' # str | Query by specified currency, includes all currencies if not specified (optional)
limit = 100 # int | Maximum number of records returned in a single list (optional) (default to 100)
offset = 0 # int | List offset, starting from 0 (optional) (default to 0)
reverse = True # bool | Whether to sort in descending order, which is the default. Set `reverse=false` to return ascending results (optional) (default to True)
try:
# Query cross margin borrow history (deprecated)
api_response = api_instance.list_cross_margin_loans(status, currency=currency, limit=limit, offset=offset, reverse=reverse)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->list_cross_margin_loans: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| status | int | Filter by status. Supported values are 2 and 3. (deprecated.) | |
| currency | str | Query by specified currency, includes all currencies if not specified | [optional] |
| limit | int | Maximum number of records returned in a single list | [optional] [default to 100] |
| offset | int | List offset, starting from 0 | [optional] [default to 0] |
| reverse | bool | Whether to sort in descending order, which is the default. Set `reverse=false` to return ascending results | [optional] [default to True] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Query successful | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[CrossMarginRepayment] list_cross_margin_repayments(currency=currency, loan_id=loan_id, limit=limit, offset=offset, reverse=reverse)
Retrieve cross margin repayments. (deprecated)
Sorted by creation time in descending order by default. Set reverse=false for ascending order
- Api Key Authentication (apiv4):
from __future__ import print_function
import gate_api
from gate_api.exceptions import ApiException, 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 authorization
configuration = 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 class
api_instance = gate_api.MarginApi(api_client)
currency = 'BTC' # str | (optional)
loan_id = '12345' # str | (optional)
limit = 100 # int | Maximum number of records returned in a single list (optional) (default to 100)
offset = 0 # int | List offset, starting from 0 (optional) (default to 0)
reverse = True # bool | Whether to sort in descending order, which is the default. Set `reverse=false` to return ascending results (optional) (default to True)
try:
# Retrieve cross margin repayments. (deprecated)
api_response = api_instance.list_cross_margin_repayments(currency=currency, loan_id=loan_id, limit=limit, offset=offset, reverse=reverse)
print(api_response)
except GateApiException as ex:
print("Gate api exception, label: %s, message: %s\n" % (ex.label, ex.message))
except ApiException as e:
print("Exception when calling MarginApi->list_cross_margin_repayments: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | [optional] | |
| loan_id | str | [optional] | |
| limit | int | Maximum number of records returned in a single list | [optional] [default to 100] |
| offset | int | List offset, starting from 0 | [optional] [default to 0] |
| reverse | bool | Whether to sort in descending order, which is the default. Set `reverse=false` to return ascending results | [optional] [default to True] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved successfully | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]