All URIs are relative to https://api.gateio.ws/api/v4
| Method | HTTP request | Description |
|---|---|---|
| list_currency_pairs | GET /spot/currency_pairs | List all currency pairs supported |
| get_currency_pair | GET /spot/currency_pairs/{currency_pair} | Get detail of one single order |
| list_tickers | GET /spot/tickers | Retrieve ticker information |
| list_order_book | GET /spot/order_book | Retrieve order book |
| list_trades | GET /spot/trades | Retrieve market trades |
| list_candlesticks | GET /spot/candlesticks | Market candlesticks |
| get_fee | GET /spot/fee | Query user trading fee rates |
| list_spot_accounts | GET /spot/accounts | List spot accounts |
| create_batch_orders | POST /spot/batch_orders | Create a batch of orders |
| list_all_open_orders | GET /spot/open_orders | List all open orders |
| list_orders | GET /spot/orders | List orders |
| create_order | POST /spot/orders | Create an order |
| cancel_orders | DELETE /spot/orders | Cancel all `open` orders in specified currency pair |
| cancel_batch_orders | POST /spot/cancel_batch_orders | Cancel a batch of orders with an ID list |
| get_order | GET /spot/orders/{order_id} | Get a single order |
| cancel_order | DELETE /spot/orders/{order_id} | Cancel a single order |
| list_my_trades | GET /spot/my_trades | List personal trading history |
list[CurrencyPair] list_currency_pairs()
List all currency pairs supported
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.SpotApi(api_client)
try:
# List all currency pairs supported
api_response = api_instance.list_currency_pairs()
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 SpotApi->list_currency_pairs: %s\n" % e)This endpoint does not need any parameter.
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | All currency pairs retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
CurrencyPair get_currency_pair(currency_pair)
Get detail of one single order
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.SpotApi(api_client)
currency_pair = 'ETH_BTC' # str | Currency pair
try:
# Get detail of one single order
api_response = api_instance.get_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 SpotApi->get_currency_pair: %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 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Ticker] list_tickers(currency_pair=currency_pair)
Retrieve ticker information
Return only related data if currency_pair is specified; otherwise return all of them
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.SpotApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair (optional)
try:
# Retrieve ticker information
api_response = api_instance.list_tickers(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 SpotApi->list_tickers: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
OrderBook list_order_book(currency_pair, interval=interval, limit=limit)
Retrieve order book
Order book will be sorted by price from high to low on bids; reversed on asks
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.SpotApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair
interval = '0' # str | Order depth. 0 means no aggregation is applied. default to 0 (optional) (default to '0')
limit = 10 # int | Maximum number of order depth data in asks or bids (optional) (default to 10)
try:
# Retrieve order book
api_response = api_instance.list_order_book(currency_pair, interval=interval, 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 SpotApi->list_order_book: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair | |
| interval | str | Order depth. 0 means no aggregation is applied. default to 0 | [optional] [default to '0'] |
| limit | int | Maximum number of order depth data in asks or bids | [optional] [default to 10] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Trade] list_trades(currency_pair, limit=limit, last_id=last_id)
Retrieve market trades
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.SpotApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair
limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100)
last_id = '12345' # str | Specify list staring point using the `id` of last record in previous list-query results (optional)
try:
# Retrieve market trades
api_response = api_instance.list_trades(currency_pair, limit=limit, last_id=last_id)
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 SpotApi->list_trades: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair | |
| limit | int | Maximum number of records returned in one list | [optional] [default to 100] |
| last_id | str | Specify list staring point using the `id` of last record in previous list-query results | [optional] |
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[list[str]] list_candlesticks(currency_pair, limit=limit, _from=_from, to=to, interval=interval)
Market candlesticks
Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying from, to and interval
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.SpotApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair
limit = 100 # int | Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. (optional) (default to 100)
_from = 1546905600 # int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified (optional)
to = 1546935600 # int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time (optional)
interval = '30m' # str | Interval time between data points (optional) (default to '30m')
try:
# Market candlesticks
api_response = api_instance.list_candlesticks(currency_pair, limit=limit, _from=_from, to=to, interval=interval)
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 SpotApi->list_candlesticks: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair | |
| limit | int | Maximum recent data points returned. `limit` is conflicted with `from` and `to`. If either `from` or `to` is specified, request will be rejected. | [optional] [default to 100] |
| _from | int | Start time of candlesticks, formatted in Unix timestamp in seconds. Default to`to - 100 * interval` if not specified | [optional] |
| to | int | End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time | [optional] |
| interval | str | Interval time between data points | [optional] [default to '30m'] |
list[list[str]]
No authorization required
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
TradeFee get_fee(currency_pair=currency_pair)
Query user trading fee rates
- 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.SpotApi(api_client)
currency_pair = 'BTC_USDT' # str | Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs (optional)
try:
# Query user trading fee rates
api_response = api_instance.get_fee(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 SpotApi->get_fee: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Specify a currency pair to retrieve precise fee rate This field is optional. In most cases, the fee rate is identical among all currency pairs | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Successfully retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[SpotAccount] list_spot_accounts(currency=currency)
List spot 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.SpotApi(api_client)
currency = 'BTC' # str | Retrieved specified currency related data (optional)
try:
# List spot accounts
api_response = api_instance.list_spot_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 SpotApi->list_spot_accounts: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency | str | Retrieved specified currency related data | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[BatchOrder] create_batch_orders(order)
Create a batch of orders
Batch orders requirements: 1. custom order field text is required 2. At most 4 currency pairs, maximum 5 orders each, are allowed in one request 3. No mixture of spot orders and margin orders, i.e. account must be identical for all orders
- 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.SpotApi(api_client)
order = [gate_api.Order()] # list[Order] |
try:
# Create a batch of orders
api_response = api_instance.create_batch_orders(order)
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 SpotApi->create_batch_orders: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| order | list[Order] |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Request is completed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[OpenOrders] list_all_open_orders(page=page, limit=limit)
List all open orders
List open orders in all currency pairs. Note that pagination parameters affect record number in each currency pair's open order list. No pagination is applied to the number of currency pairs returned. All currency pairs with open orders will be returned
- 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.SpotApi(api_client)
page = 1 # int | Page number (optional) (default to 1)
limit = 100 # int | Maximum number of records returned in one page in each currency pair (optional) (default to 100)
try:
# List all open orders
api_response = api_instance.list_all_open_orders(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 SpotApi->list_all_open_orders: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| page | int | Page number | [optional] [default to 1] |
| limit | int | Maximum number of records returned in one page in each currency pair | [optional] [default to 100] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Order] list_orders(currency_pair, status, page=page, limit=limit)
List orders
- 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.SpotApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair
status = 'open' # str | List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled
page = 1 # int | Page number (optional) (default to 1)
limit = 100 # int | Maximum number of records returned. If `status` is `open`, maximum of `limit` is 100 (optional) (default to 100)
try:
# List orders
api_response = api_instance.list_orders(currency_pair, status, 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 SpotApi->list_orders: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair | |
| status | str | List orders based on status `open` - order is waiting to be filled `finished` - order has been filled or cancelled | |
| page | int | Page number | [optional] [default to 1] |
| limit | int | Maximum number of records returned. If `status` is `open`, maximum of `limit` is 100 | [optional] [default to 100] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Order create_order(order)
Create an 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.SpotApi(api_client)
order = gate_api.Order() # Order |
try:
# Create an order
api_response = api_instance.create_order(order)
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 SpotApi->create_order: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| order | Order |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 201 | Order created. | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Order] cancel_orders(currency_pair, side=side, account=account)
Cancel all open orders in specified currency pair
- 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.SpotApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair
side = 'sell' # str | All bids or asks. Both included in not specified (optional)
account = 'spot' # str | Specify account type. Default to all account types being included (optional)
try:
# Cancel all `open` orders in specified currency pair
api_response = api_instance.cancel_orders(currency_pair, side=side, account=account)
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 SpotApi->cancel_orders: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair | |
| side | str | All bids or asks. Both included in not specified | [optional] |
| account | str | Specify account type. Default to all account types being included | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Batch cancellation request accepted. Query order status by listing orders | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[CancelOrderResult] cancel_batch_orders(cancel_order)
Cancel a batch of orders with an ID list
Multiple currency pairs can be specified, but maximum 20 orders are allowed per request
- 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.SpotApi(api_client)
cancel_order = [gate_api.CancelOrder()] # list[CancelOrder] |
try:
# Cancel a batch of orders with an ID list
api_response = api_instance.cancel_batch_orders(cancel_order)
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 SpotApi->cancel_batch_orders: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| cancel_order | list[CancelOrder] |
- Content-Type: application/json
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Batch cancellation completed | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Order get_order(order_id, currency_pair)
Get a single 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.SpotApi(api_client)
order_id = '12345' # str | ID returned on order successfully being created
currency_pair = 'BTC_USDT' # str | Currency pair
try:
# Get a single order
api_response = api_instance.get_order(order_id, 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 SpotApi->get_order: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| order_id | str | ID returned on order successfully being created | |
| currency_pair | str | Currency pair |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Detail retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Order cancel_order(order_id, currency_pair)
Cancel a single 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.SpotApi(api_client)
order_id = '12345' # str | ID returned on order successfully being created
currency_pair = 'BTC_USDT' # str | Currency pair
try:
# Cancel a single order
api_response = api_instance.cancel_order(order_id, 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 SpotApi->cancel_order: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| order_id | str | ID returned on order successfully being created | |
| currency_pair | str | Currency pair |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | Order cancelled | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
list[Trade] list_my_trades(currency_pair, limit=limit, page=page, order_id=order_id)
List personal trading history
- 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.SpotApi(api_client)
currency_pair = 'BTC_USDT' # str | Currency pair
limit = 100 # int | Maximum number of records returned in one list (optional) (default to 100)
page = 1 # int | Page number (optional) (default to 1)
order_id = '12345' # str | List all trades of specified order (optional)
try:
# List personal trading history
api_response = api_instance.list_my_trades(currency_pair, limit=limit, page=page, order_id=order_id)
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 SpotApi->list_my_trades: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| currency_pair | str | Currency pair | |
| limit | int | Maximum number of records returned in one list | [optional] [default to 100] |
| page | int | Page number | [optional] [default to 1] |
| order_id | str | List all trades of specified order | [optional] |
- Content-Type: Not defined
- Accept: application/json
| Status code | Description | Response headers |
|---|---|---|
| 200 | List retrieved | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]