NAV Navbar
Python Shell

Gate API v4 v4.15.1

Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.

APIv4 provides spot, margin and futures trading operations. There are public APIs to retrieve the real-time market statistics, and private APIs which needs authentication to trade on user's behalf.

Base URLs:

Terms of service

Email: Gate API support

Web: Gate API support

License: Apache License 2.0

Available SDK:

WebSocket

WebSocket has multiple entries based on trading type, which are:

Spot trading

Note that spot trading WebSocket's APIv4 key support is explained in section APIv4 Keys support

Perpetual Contract

Delivery Contract

Changelog

v4.15.1

2020-08-04

v4.14.1

2020-07-08

v4.14.0

2020-07-06

v4.13.1

2020-06-28

v4.13.0

2020-05-20

v4.12.0

2020-04-08

v4.11.2

2020-03-29

v4.11.1

2020-03-23

v4.11.0

2020-03-20

v4.10.1

2020-02-24

v4.10.0

2020-02-17

v4.9.1

2020-01-07

v4.9.0

2019-12-17

v4.8.2

2019-12-02

v4.8.1

2019-11-27

v4.8.0

2019-11-07

To use USDT futures, just replace /futures with /futures/usdt, e.g. use GET /futures/usdt/accounts to retrieve futures accounts settled in USDT, while GET /futures/btc/accounts returns accounts in BTC.

For compatibility, GET /futures/xxx defaults to GET /futures/btc/xxx, e.g. GET /futures/accounts will be treated as GET /futures/btc/accounts

v4.7.3

2019-07-18

v4.6.3

2019-06-11

v4.7.2

2019-05-29

v4.7.1

2019-04-17

v4.6.2

2019-04-24

v4.6.1

2019-04-02

v4.6.0

2019-03-21

SDK related only

v4.5.2

2019-03-14

v4.5.1

2019-03-11

v4.5.0

2019-03-05

To avoid version confusion, all versions in APIv4 (documents and SDKs are both included) will start with 4 from now on

v1.3.0

2019-02-13

Important update

v1.2.1

2019-02-13

v1.2.0

2019-01-17

v1.1.0

2019-01-08

v1.0.0

2018-12-30

API General Information

HTTP convention

Time

All time related fields are unix timestamp in seconds if no extra note. But they may differ in format(int64, number or string). Possible values like the following may be returned:

The best way to handle time fields is to parsing them as a number with decimal places. If higher precision is not needed, you can safely cast them to integer(or long). Our SDKs listed above has already taken proper deserialization to handle them

Pagination

Pagination is achieved using one of the following method

In both method, limit limits the maximum number of records returned in one request. If no additional explanation, it defaults to 100 if not provided and its maximum value is limited to 1000.

page starts from 1, mimicking common paging used in web pages. To iterate the whole list, use the same limit and increment page by 1 until the records length is shorter than the limit

offset starts from 0, behaving like common DB search. To iterate the whole list, increment offset by limit until the records length is shorter than the limit.

For example, if the total number of orders is 201. Using page-limit method, send request parameters like the following:

  1. page=1&limit=100
  2. page=2&limit=100
  3. page=3&limit=100

Using limit-offset method, send request parameters like:

  1. limit=100&offset=0
  2. limit=100&offset=100
  3. limit=100&offset=200

Some endpoints may return additional pagination metadata. If present, they are sent back through the response header. Take GET /futures/{settle}/orders as an example, following headers will be returned

Comparison with APIv2

APIv4 is a standalone brand new HTTP REST API, currently used in parallel with APIv2. APIv4 provides complete trading operations, with more highly secured authentication method. What's more, APIv4 specification is written following OpenAPI Specification. SDKs and documents are all generated from the same spec, which ensures consistency between documents and implementation.

The ways APIv4 and APIv2 differ are:

  1. Their API keys are separated from each other. Once logged into the web console, v2 API keys are generated on "APIKeys" page, while v4 "APIv4Keys" page.
  2. APIv2 supports only spot trading, while v4 supports all trading operations in spot, margin and futures.

Which one to choose:

  1. If margin or futures trading are needed, choose APIv4.
  2. If only spot trading or wallet operation is required, choose on your own.

Authentication

APIv4 uses standalone API keys management from APIv2. So before using APIv4, you need to log into the console to generate new API keys for APIv4.

When creating a new key, you can choose to enable or disable spot & margin, futures, wallet, or withdrawal permission. Each enabled permission can be configured to read-only or read-write(i.e., all permissions). Besides, you can attach an IP whitelist, which requires the server only accept requests from specified IPs. Each key can have at most 10 IPs formatted in IPv4(not supporting IP range though). If IP whitelist is not set. the server will skip client IP validation.

Each user can create at most 5 keys with separate permissions. It is recommended to set a name for key denoting how the key will be used.

Note: If the key is named with spot or futures, then it could be the default name after APIv4 migration. For details refer to About APIv4 key improvement section

Created key can also be updated or deleted, but any modification could take effect in at most 5 minutes.

One more thing to notice that futures TestNet trading is a separate environment from futures real trading. Real trading API keys cannot be used in TestNet. If you want to test futures API with TestNet, you need to log into the console to generate TestNet API keys(in "Futures TestNet APIKeys" tab on "APIv4Keys" page). Making futures requests are identical between real and TestNet trading, with the only exceptions are different base URLs and different API keys.

About APIv4 key improvement

Previously(before April 2020) futures APIv4 key are separated from spot one. But this is no longer the case any more. You can create multiple keys with each key having multiple permissions now. e.g. you can create one key with spot read/write and futures read/write permission which can be used in both spot and futures trading.

History API keys will not be affected by this improvement. Previous spot key and futures key are now one key with only spot permissions enabled, another only futures permission enabled. You can reconfigure their permissions after migration.

APIv4 Permissions

APIv4 operation permissions are divided into different groups:

All GET operations are read operations, others write operations. Each permission group can be set to either disabled, read-only or read-write.

One thing to notice that even though withdrawal API has only one operation(i.e., POST /withdrawals), for general concern, it is still separated from wallet API into a standalone permission group, while withdrawal history retrieving API stays inside wallet operations(i.e., GET /wallet/withdrawals).

APIv4 signed request requirements

  1. Generate APIv4 Key pairs in web console, and make sure it has the right permissions.
  2. Set request header KEY to the key.
  3. Set request header Timestamp to current time formatted in Unix time in seconds. Pay attention that the gap between its value and current time cannot exceed 60 seconds.
  4. Set request header SIGN to encrypted request signature. Refer to next section for how signature string is generated. Signature generation method is HexEncode(HMAC_SHA512(secret, signature_string)), i.e., the hexadecimal digest output of HMAC-SHA512 with APIv4 secret as secret and signature string as message,
  5. Make sure request client's IP is in your APIv4 Key's IP whitelist.

API Signature string generation

In APIv4, signature string is concatenated as the following way:

Request Method + "\n" + Request URL + "\n" + Query String + "\n" + HexEncode(SHA512(Request Payload)) + "\n" + Timestamp

Request Method

Request method in UPPERCASE, e.g. POST, GET

Request URL

Request url. Protocol, host and port are not included, e.g. /api/v4/futures/orders

Query String

Request query string without URL encode. query parameters order should be the same as how they are concatenated in the request URL, e.g. status=finished&limit=50. Use empty string("") if no query parameters.

HexEncode(SHA512(Request Payload))

Hash the request body with SHA512 and output its Hex encoded form. If no request body, use empty string's hashed result, i.e. cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e

Timestamp

Timestamp request header value.

Examples

Note: all example signature string are broken into multiple lines for displaying purpose only. Only the \n character in signature string is reserved in reality.

Suppose the key we used is key, while the secret is secret.

  1. List all orders
    GET /api/v4/futures/orders?contract=BTC_USD&status=finished&limit=50 HTTP/1.1

Signature string:

    GET\n
    /api/v4/futures/orders\n
    contract=BTC_USD&status=finished&limit=50\n
    cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e\n
    1541993715

Explanation:

  • /api/v4/futures/orders: request url
  • contract=BTC_USD&status=finished&limit=50: keep the query string as it is in the request url
  • request body use empty string's hashed result
  • 1541993715: Unix timestamp in seconds

Signature generated

55f84ea195d6fe57ce62464daaa7c3c02fa9d1dde954e4c898289c9a2407a3d6fb3faf24deff16790d726b66ac9f74526668b13bd01029199cc4fcc522418b8a

  1. Create an order
    POST /api/v4/futures/orders HTTP/1.1

    {"contract":"BTC_USD","type":"limit","size":100,"price":6800,"time_in_force":"gtc"}

Signature string:

    POST\n
    /api/v4/futures/orders\n
    \n
    ad3c169203dc3026558f01b4df307641fa1fa361f086b2306658886d5708767b1854797c68d9e62fef2f991645aa82673622ebf417e091d0bd22bafe5d956cca\n
    1541993715

Explanation:

  • request query string is empty, use plain empty string
  • use the hashed result of the json-string-formatted request body

Signature generated

eae42da914a590ddf727473aff25fc87d50b64783941061f47a3fdb92742541fc4c2c14017581b4199a1418d54471c269c03a38d788d802e2c306c37636389f0


# example authentication implementation in Python

"""
Python SDK is recommended as it has already implemented the authentication process for every API:
"""

import time
import hashlib
import hmac
import requests
import json

def gen_sign(method, url, query_string=None, payload_string=None):
    key = ''        # api_key
    secret = ''     # api_secret

    t = time.time()
    m = hashlib.sha512()
    m.update((payload_string or "").encode('utf-8'))
    hashed_payload = m.hexdigest()
    s = '%s\n%s\n%s\n%s\n%s' % (method, url, query_string or "", hashed_payload, t)
    sign = hmac.new(secret.encode('utf-8'), s.encode('utf-8'), hashlib.sha512).hexdigest()
    return {'KEY': key, 'Timestamp': str(t), 'SIGN': sign}

if __name__ == "__main__":
    host = "https://api.gateio.ws"
    prefix = "/api/v4"
    common_headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

    url = '/futures/orders'
    body = {"contract": "BTC_USD", "size": 100, "price": "30", "tif": "gtc"}
    request_content = json.dumps(body)
    sign_headers = gen_sign('POST', prefix + url, "", request_content)
    sign_headers.update(common_headers)
    print('signature headers: %s' % sign_headers)
    res = requests.post(host + prefix + url, headers=sign_headers, data=request_content)
    print(res.status_code)
    print(res.content)

Limits

Request limits

Withdraw:

Spot:

Futures:

Error Handling

For all abnormal requests, APIv4 will return non-2xx status code, with a response body in JSON format to explain the error.

The error response body follows a format like:

{
  "label": "INVALID_PARAM_VALUE",
  "message": "Invalid parameter `text` with value: abc"
}

Take Python requests for example, error handling can be written like:

Following examples only deal with business-related errors. Network timeout or other common errors need to be handled separately:

import requests
r = requests.get("https://api.gateio.ws/api/v4/futures/btc/contracts/BTC_USD")
try:
    r.raise_for_status()
except requests.HTTPError:
    # catch 2xx errors, parse error message in body, and do something based on `label`
    if r.json()['label'] == 'xxx':
        print(r.json())

or with Python SDK:

import json
from gate_api import FuturesApi
from gate_api.rest import ApiException

api = FuturesApi()
try:    
    api.get_futures_contract(settle='btc', contract="BTC_USD")
except ApiException as e:  # ApiException wraps whole error information, see implementation for details
    detail = json.loads(e.value.body)
    if detail['label'] == 'xxx':
        print(detail)

label list

label Meaning
INVALID_PARAM_VALUE Invalid parameter value
INVALID_PROTOCOL Invalid parameter value
INVALID_ARGUMENT Invalid argument
INVALID_REQUEST_BODY Invalid request body
MISSING_REQUIRED_PARAM Missing required parameter
BAD_REQUEST Invalid request
INVALID_CONTENT_TYPE Invalid Content-Type header
NOT_ACCEPTABLE Invalid Accept- Header
METHOD_NOT_ALLOWED Request method is not allowed
NOT_FOUND Request URL not exists
label Meaning
INVALID_CREDENTIALS Invalid credentials provided
INVALID_KEY Invalid API Key
IP_FORBIDDEN Request IP not in whitelist
READ_ONLY API key is read-only
INVALID_SIGNATURE Invalid signature
MISSING_REQUIRED_HEADER Missing required authentication header
REQUEST_EXPIRED Request Timestamp is far from the server time
ACCOUNT_LOCKED Account is locked
FORBIDDEN Account has no permission to request operation
label Meaning
SUB_ACCOUNT_NOT_FOUND Sub account not found
SUB_ACCOUNT_LOCKED Sub account is locked
MARGIN_BALANCE_EXCEPTION Abnormal margin account
MARGIN_TRANSFER_FAILED Failed to transfer with margin account
TOO_MUCH_FUTURES_AVAILABLE Futures balance exceeds max allowed
FUTURES_BALANCE_NOT_ENOUGH Futures balance not enough
ACCOUNT_EXCEPTION Abnormal account
SUB_ACCOUNT_TRANSFER_FAILED Failed to transfer with sub account
ADDRESS_NOT_USED Address never being used in web console
TOO_FAST Withdrawing request exceeds frequency limit
label Meaning
INVALID_PRECISION Invalid precision
INVALID_CURRENCY Invalid currency
INVALID_CURRENCY_PAIR Invalid currency pair
POC_FILL_IMMEDIATELY Order would match and take immediately so it's cancelled
ORDER_NOT_FOUND Order not found
ORDER_CLOSED Order already closed
ORDER_CANCELLED Order already cancelled
QUANTITY_NOT_ENOUGH Amount is not enough
BALANCE_NOT_ENOUGH Balance is not enough
MARGIN_NOT_SUPPORTED Request currency pair doesn't provide margin trading
MARGIN_BALANCE_NOT_ENOUGH Margin balance is not enough
AMOUNT_TOO_LITTLE Amount does not reach minimum required
AMOUNT_TOO_MUCH Amount exceeds maximum allowed
REPEATED_CREATION Repeated creation
LOAN_NOT_FOUND Margin loan is not found
LOAN_RECORD_NOT_FOUND Margin loan record is not found
NO_MATCHED_LOAN No loan can match request borrow requirement
NOT_MERGEABLE Request loans cannot be merged
NO_CHANGE No change is made
REPAY_TOO_MUCH Repay more than required
TOO_MANY_CURRENCY_PAIRS Too many currency pairs in batch orders creation
TOO_MANY_ORDERS Too many orders in one currency pair in batch orders creation
MIXED_ACCOUNT_TYPE More than one account type is used in batch orders creation
AUTO_BORROW_TOO_MUCH Auto borrow exceeds maximum allowed
label Meaning
USER_NOT_FOUND User has no futures account
CONTRACT_NO_COUNTER No counter order found
CONTRACT_NOT_FOUND Contract not found
RISK_LIMIT_EXCEEDED Risk limit exceeded
INSUFFICIENT_AVAILABLE Balance is not enough
LIQUIDATE_IMMEDIATELY Operation may cause liquidation
LEVERAGE_TOO_HIGH leverage too high
LEVERAGE_TOO_LOW leverage too low
ORDER_NOT_FOUND Order not found
ORDER_NOT_OWNED Order not owned
ORDER_FINISHED Order already finished
TOO_MANY_ORDERS Too many open orders
POSITION_CROSS_MARGIN margin updating is not allowed in cross margin
POSITION_IN_LIQUIDATION Position is being liquidated
POSITION_IN_CLOSE Position is closing
POSITION_EMPTY Position is empty
REMOVE_TOO_MUCH Changed margin exceeds allowed
RISK_LIMIT_NOT_MULTIPLE Risk limit is not a multiple of step
RISK_LIMIT_TOO_HIGH Risk limit too high
RISK_LIMIT_TOO_lOW Risk limit too low
PRICE_TOO_DEVIATED Order price deviates too much from mark price
SIZE_TOO_LARGE Order size exceeds maximum
SIZE_TOO_SMALL Order size does not reach minimum
PRICE_OVER_LIQUIDATION Price to increase position can not exceeds liquidation price
PRICE_OVER_BANKRUPT Price to decrease position cannot exceeds bankrupting price
ORDER_POC_IMMEDIATE POC order will be finished immediately
INCREASE_POSITION POC order will increase position
CONTRACT_IN_DELISTING Contract is delisting, only reduce-only order or close order is allowed
label Meaning
INTERNAL Internal server error
SERVER_ERROR Internal server error
TOO_BUSY Server is too busy at the moment

FAQ

Withdrawal

Withdrawal operations

Withdraw

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/withdrawals'
query_param = ''
body='{"currency":"ETH","address":"1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs","amount":"222.61","memo":""}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/withdrawals"
query_param=""
body_param='{"currency":"ETH","address":"1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs","amount":"222.61","memo":""}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /withdrawals

Withdraw

Body parameter

{
  "currency": "ETH",
  "address": "1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs",
  "amount": "222.61",
  "memo": ""
}

Parameters

Name In Type Required Description
body body object true none
» amount body string true Trade amount
» currency body string true Record currency
» address body string false Withdrawal address. Required for withdrawals
» memo body string false Extra withdrawal memo

Example responses

202 Response

{
  "id": "210496",
  "timestamp": "1542000000",
  "currency": "ETH",
  "address": "1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs",
  "txid": "128988928203223323290",
  "amount": "222.61",
  "memo": "",
  "status": "DONE"
}

Responses

Status Meaning Description Schema
202 Accepted Withdraw request is accepted. Refer to withdrawal records for status Inline

Response Schema

Status Code 202

Name Type Description
» id string Record ID
» txid string Hash record of the withdrawal
» timestamp string Record time
» amount string Trade amount
» currency string Record currency
» address string Withdrawal address. Required for withdrawals
» memo string Extra withdrawal memo
» status string Record status.

- DONE: done
- CANCEL: cancelled
- REQUEST: requesting
- MANUAL: waiting for manual approval
- BCODE: GateCode operation

Enumerated Values

Property Value
status DONE
status CANCEL
status REQUEST
status MANUAL
status BCODE

Wallet

Wallet

Generate currency deposit address

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/wallet/deposit_address'
query_param = 'currency=string'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/wallet/deposit_address"
query_param="currency=string"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /wallet/deposit_address

Generate currency deposit address

Parameters

Name In Type Required Description
currency query string true Currency name

Example responses

200 Response

{
  "currency": "ETH",
  "address": "LPXtk1kWHioP62SzfqwKbYE3Z7Wt2ujYEc"
}

Responses

Status Meaning Description Schema
200 OK Address successfully generated Inline

Response Schema

Status Code 200

Name Type Description
» currency string Currency detail
» address string Deposit address

Retrieve withdrawal records

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/wallet/withdrawals'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/wallet/withdrawals"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /wallet/withdrawals

Retrieve withdrawal records

Record time range cannot exceed 30 days

Parameters

Name In Type Required Description
currency query string false Filter by currency. Return all currency records if not specified
from query integer(int64) false Time range beginning, default to 7 days before current time
to query integer(int64) false Time range ending, default to current time
limit query integer false Maximum number of records returned in one list
offset query integer false List offset, starting from 0

Example responses

200 Response

[
  {
    "id": "210496",
    "timestamp": "1542000000",
    "currency": "ETH",
    "address": "1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs",
    "txid": "128988928203223323290",
    "amount": "222.61",
    "memo": "",
    "status": "DONE"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» id string Record ID
» txid string Hash record of the withdrawal
» timestamp string Record time
» amount string Trade amount
» currency string Record currency
» address string Withdrawal address. Required for withdrawals
» memo string Extra withdrawal memo
» status string Record status.

- DONE: done
- CANCEL: cancelled
- REQUEST: requesting
- MANUAL: waiting for manual approval
- BCODE: GateCode operation

Enumerated Values

Property Value
status DONE
status CANCEL
status REQUEST
status MANUAL
status BCODE

Retrieve deposit records

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/wallet/deposits'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/wallet/deposits"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /wallet/deposits

Retrieve deposit records

Record time range cannot exceed 30 days

Parameters

Name In Type Required Description
currency query string false Filter by currency. Return all currency records if not specified
from query integer(int64) false Time range beginning, default to 7 days before current time
to query integer(int64) false Time range ending, default to current time
limit query integer false Maximum number of records returned in one list
offset query integer false List offset, starting from 0

Example responses

200 Response

[
  {
    "id": "210496",
    "timestamp": "1542000000",
    "currency": "ETH",
    "address": "1HkxtBAMrA3tP5ENnYY2CZortjZvFDH5Cs",
    "txid": "128988928203223323290",
    "amount": "222.61",
    "memo": "",
    "status": "DONE"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» id string Record ID
» txid string Hash record of the withdrawal
» timestamp string Record time
» amount string Trade amount
» currency string Record currency
» address string Withdrawal address. Required for withdrawals
» memo string Extra withdrawal memo
» status string Record status.

- DONE: done
- CANCEL: cancelled
- REQUEST: requesting
- MANUAL: waiting for manual approval
- BCODE: GateCode operation

Enumerated Values

Property Value
status DONE
status CANCEL
status REQUEST
status MANUAL
status BCODE

Transfer between trading accounts

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/wallet/transfers'
query_param = ''
body='{"currency":"BTC","from":"spot","to":"margin","amount":"1","currency_pair":"BTC_USDT"}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/wallet/transfers"
query_param=""
body_param='{"currency":"BTC","from":"spot","to":"margin","amount":"1","currency_pair":"BTC_USDT"}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /wallet/transfers

Transfer between trading accounts

Transfer between different accounts. Currently support transfers between the following:

  1. spot - margin
  2. spot - futures(perpetual)
  3. spot - delivery

Body parameter

{
  "currency": "BTC",
  "from": "spot",
  "to": "margin",
  "amount": "1",
  "currency_pair": "BTC_USDT"
}

Parameters

Name In Type Required Description
body body object true none
» currency body string true Transfer currency. For futures account, currency can be set to POINT or settle currency
» from body string true Account transferred from
» to body string true Account transferred to
» amount body string true Transfer amount
» currency_pair body string false Margin currency pair. Required if transfer from or to margin account
» settle body string false Futures settle currency. Required if currency is POINT

Enumerated Values

Parameter Value
» from spot
» from margin
» from futures
» from delivery
» to spot
» to margin
» to futures
» to delivery

Responses

Status Meaning Description Schema
204 No Content Balance transferred None

Transfer between main and sub accounts

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/wallet/sub_account_transfers'
query_param = ''
body='{"currency":"BTC","sub_account":"10002","direction":"to","amount":"1"}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/wallet/sub_account_transfers"
query_param=""
body_param='{"currency":"BTC","sub_account":"10002","direction":"to","amount":"1"}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /wallet/sub_account_transfers

Transfer between main and sub accounts

Body parameter

{
  "currency": "BTC",
  "sub_account": "10002",
  "direction": "to",
  "amount": "1"
}

Parameters

Name In Type Required Description
body body object true none
» currency body string true Transfer currency name
» sub_account body string true Sub account user ID
» direction body string true Transfer direction. to - transfer into sub account; from - transfer out from sub account
» amount body string true Transfer amount

Enumerated Values

Parameter Value
» direction to
» direction from

Responses

Status Meaning Description Schema
204 No Content Balance transferred None

Transfer records between main and sub accounts

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/wallet/sub_account_transfers'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/wallet/sub_account_transfers"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /wallet/sub_account_transfers

Transfer records between main and sub accounts

Record time range cannot exceed 30 days

Note: only records after 2020-04-10 can be retrieved

Parameters

Name In Type Required Description
sub_uid query string false Sub account user ID. Return records related to all sub accounts if not specified
from query integer(int64) false Time range beginning, default to 7 days before current time
to query integer(int64) false Time range ending, default to current time
limit query integer false Maximum number of records returned in one list
offset query integer false List offset, starting from 0

Example responses

200 Response

[
  {
    "uid": "10001",
    "timest": "1592809000",
    "source": "web",
    "currency": "BTC",
    "sub_account": "10002",
    "direction": "to",
    "amount": "1"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» currency string Transfer currency name
» sub_account string Sub account user ID
» direction string Transfer direction. to - transfer into sub account; from - transfer out from sub account
» amount string Transfer amount
» uid string Main account user ID
» timest string Transfer timestamp
» source string Where the operation is initiated from

Enumerated Values

Property Value
direction to
direction from

Spot

Spot trading

List all currency pairs supported

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/currency_pairs'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/spot/currency_pairs \
  -H 'Accept: application/json'

GET /spot/currency_pairs

List all currency pairs supported

Example responses

200 Response

[
  {
    "id": "ETH_USDT",
    "base": "ETH",
    "quote": "USDT",
    "fee": "0.2",
    "min_base_amount": "0.001",
    "min_quote_amount": "1.0",
    "amount_precision": 3,
    "precision": 6,
    "trade_status": "tradable"
  }
]

Responses

Status Meaning Description Schema
200 OK All currency pairs retrieved [CurrencyPair]

Get detail of one single order

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/currency_pairs/ETH_BTC'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/spot/currency_pairs/ETH_BTC \
  -H 'Accept: application/json'

GET /spot/currency_pairs/{currency_pair}

Get detail of one single order

Parameters

Name In Type Required Description
currency_pair path string true Currency pair

Example responses

200 Response

{
  "id": "ETH_USDT",
  "base": "ETH",
  "quote": "USDT",
  "fee": "0.2",
  "min_base_amount": "0.001",
  "min_quote_amount": "1.0",
  "amount_precision": 3,
  "precision": 6,
  "trade_status": "tradable"
}

Responses

Status Meaning Description Schema
200 OK Successfully retrieved CurrencyPair

Retrieve ticker information

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/tickers'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/spot/tickers \
  -H 'Accept: application/json'

GET /spot/tickers

Retrieve ticker information

Return only related data if currency_pair is specified; otherwise return all of them

Parameters

Name In Type Required Description
currency_pair query string false Currency pair

Example responses

200 Response

[
  {
    "currency_pair": "ETH_BTC",
    "last": "10.32",
    "lowest_ask": "10.32",
    "highest_bid": "10.33",
    "change_percentage": "-0.0052",
    "base_volume": "132.4",
    "quote_volume": "1366.36",
    "high_24h": "10.33",
    "low_24h": "10.32"
  }
]

Responses

Status Meaning Description Schema
200 OK Successfully retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» currency_pair string Currency pair
» last string Last trading price
» lowest_ask string Lowest ask
» highest_bid string Highest bid
» change_percentage string Change percentage.
» base_volume string Base currency trade volume
» quote_volume string Quote currency trade volume
» high_24h string Highest price in 24h
» low_24h string Lowest price in 24h

Retrieve order book

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/order_book'
query_param = 'currency_pair=BTC_USDT'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/spot/order_book?currency_pair=BTC_USDT \
  -H 'Accept: application/json'

GET /spot/order_book

Retrieve order book

Order book will be sorted by price from high to low on bids; reversed on asks

Parameters

Name In Type Required Description
currency_pair query string true Currency pair
interval query string false Order depth. 0 means no aggregation is applied. default to 0
limit query integer false Maximum number of order depth data in asks or bids

Example responses

200 Response

{
  "asks": [
    [
      "1.52",
      "1.151"
    ],
    [
      "1.53",
      "1.218"
    ]
  ],
  "bids": [
    [
      "1.17",
      "201.863"
    ],
    [
      "1.16",
      "725.464"
    ]
  ]
}

Responses

Status Meaning Description Schema
200 OK Successfully retrieved Inline

Response Schema

Status Code 200

Name Type Description
» asks array Asks order depth
»» None array price and amount
» bids array Bids order depth
»» None array price and amount

Retrieve market trades

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/trades'
query_param = 'currency_pair=BTC_USDT'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/spot/trades?currency_pair=BTC_USDT \
  -H 'Accept: application/json'

GET /spot/trades

Retrieve market trades

Parameters

Name In Type Required Description
currency_pair query string true Currency pair
limit query integer false Maximum number of records returned in one list
last_id query string false Specify list staring point using the id of last record in previous list-query results

Example responses

200 Response

[
  {
    "id": "1232893232",
    "create_time": "1548000000",
    "order_id": "4128442423",
    "side": "buy",
    "role": "maker",
    "amount": "0.15",
    "price": "0.03",
    "fee": "0.0005",
    "fee_currency": "ETH",
    "point_fee": "0",
    "gt_fee": "0"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» id string Trade ID
» create_time string Trading time
» side string Order side
» role string Trade role
» amount string Trade amount
» price string Order price
» order_id string Related order ID. No value in public endpoints
» fee string Fee deducted. No value in public endpoints
» fee_currency string Fee currency unit. No value in public endpoints
» point_fee string Point used to deduct fee
» gt_fee string GT used to deduct fee

Enumerated Values

Property Value
side buy
side sell
role taker
role maker

Market candlesticks

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/candlesticks'
query_param = 'currency_pair=BTC_USDT'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/spot/candlesticks?currency_pair=BTC_USDT \
  -H 'Accept: application/json'

GET /spot/candlesticks

Market candlesticks

Maximum of 1000 points are returned in one query. Be sure not to exceed the limit when specifying from, to and interval

Parameters

Name In Type Required Description
currency_pair query string true Currency pair
limit query integer false Maximum recent data points returned. limit is conflicted with from and to. If either from or to is specified, request will be rejected.
from query integer(int64) false Start time of candlesticks, formatted in Unix timestamp in seconds.
to query integer(int64) false End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
interval query string false Interval time between data points

Detailed descriptions

from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default toto - 100 * interval if not specified

Enumerated Values

Parameter Value
interval 10s
interval 1m
interval 5m
interval 15m
interval 30m
interval 1h
interval 4h
interval 8h
interval 1d
interval 7d

Example responses

200 Response

[
  [
    "1539852480",
    "971519.677",
    "0.0021724",
    "0.0021922",
    "0.0021724",
    "0.0021737"
  ]
]

Responses

Status Meaning Description Schema
200 OK Successfully retrieved [[string]]

Response Schema

Status Code 200

Name Type Description
» None array Candlestick data point detail. Meaning from left to right:

- Unix timestamp in seconds
- Trading volume
- Close price
- Highest price
- Lowest price
- Open price

List spot accounts

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/accounts'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/spot/accounts"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /spot/accounts

List spot accounts

Parameters

Name In Type Required Description
currency query string false Retrieved specified currency related data

Example responses

200 Response

[
  {
    "currency": "ETH",
    "available": "968.8",
    "locked": "0"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» currency string Currency detail
» available string Available amount
» locked string Locked amount, used in trading

Create a batch of orders

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/batch_orders'
query_param = ''
body='[{"text":"t-123456","currency_pair":"ETH_BTC","type":"limit","account":"spot","side":"buy","amount":"1","price":"5.00032","time_in_force":"gtc","auto_borrow":false}]'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/spot/batch_orders"
query_param=""
body_param='[{"text":"t-123456","currency_pair":"ETH_BTC","type":"limit","account":"spot","side":"buy","amount":"1","price":"5.00032","time_in_force":"gtc","auto_borrow":false}]'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /spot/batch_orders

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

Body parameter

[
  {
    "text": "t-123456",
    "currency_pair": "ETH_BTC",
    "type": "limit",
    "account": "spot",
    "side": "buy",
    "amount": "1",
    "price": "5.00032",
    "time_in_force": "gtc",
    "auto_borrow": false
  }
]

Parameters

Name In Type Required Description
body body array[object] true none

Example responses

200 Response

[
  {
    "text": "t-123456",
    "succeeded": true,
    "label": "",
    "message": "",
    "id": "12332324",
    "create_time": "1548000000",
    "update_time": "1548000100",
    "currency_pair": "ETC_BTC",
    "status": "cancelled",
    "type": "limit",
    "account": "spot",
    "side": "buy",
    "amount": "1",
    "price": "5.00032",
    "time_in_force": "gtc",
    "left": "0.5",
    "filled_total": "2.50016",
    "fee": "0.005",
    "fee_currency": "ETH",
    "point_fee": "0",
    "gt_fee": "0",
    "gt_discount": false,
    "rebated_fee": "0",
    "rebated_fee_currency": "BTC"
  }
]

Responses

Status Meaning Description Schema
200 OK Request is completed [Inline]

Response Schema

Status Code 200

Name Type Description
» None object Batch order details
»» text string User defined information. If not empty, must follow the rules below:

1. prefixed with t-
2. no longer than 28 bytes without t- prefix
3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.)
»» succeeded boolean Whether order succeeds
»» label string Error label, empty string if order succeeds
»» message string Detailed error message, empty string if order succeeds
»» id string Order ID
»» create_time string Order creation time
»» update_time string Order last modification time
»» status string Order status

- open: to be filled
- closed: filled
- cancelled: cancelled
»» currency_pair string Currency pair
»» type string Order type. limit - limit order
»» account string Account type. spot - use spot account; margin - use margin account
»» side string Order side
»» amount string Trade amount
»» price string Order price
»» time_in_force string Time in force

- gtc: GoodTillCancelled
- ioc: ImmediateOrCancelled, taker only
- poc: PendingOrCancelled, makes a post-only order that always enjoys a maker fee
»» left string Amount left to fill
»» fill_price string Total filled in quote currency. Deprecated in favor of filled_total
»» filled_total string Total filled in quote currency
»» fee string Fee deducted
»» fee_currency string Fee currency unit
»» point_fee string Point used to deduct fee
»» gt_fee string GT used to deduct fee
»» gt_discount boolean Whether GT fee discount is used
»» rebated_fee string Rebated fee
»» rebated_fee_currency string Rebated fee currency unit

Enumerated Values

Property Value
status open
status closed
status cancelled
type limit
account spot
account margin
side buy
side sell
time_in_force gtc
time_in_force ioc
time_in_force poc

List all open orders

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/open_orders'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/spot/open_orders"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /spot/open_orders

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

Parameters

Name In Type Required Description
page query integer false Page number
limit query integer false Maximum number of records returned in one page in each currency pair

Example responses

200 Response

[
  {
    "currency_pair": "ETH_BTC",
    "total": 1,
    "orders": [
      {
        "id": "12332324",
        "text": "t-123456",
        "create_time": "1548000000",
        "update_time": "1548000100",
        "currency_pair": "ETH_BTC",
        "status": "open",
        "type": "limit",
        "account": "spot",
        "side": "buy",
        "amount": "1",
        "price": "5.00032",
        "time_in_force": "gtc",
        "left": "0.5",
        "filled_total": "2.50016",
        "fee": "0.005",
        "fee_currency": "ETH",
        "point_fee": "0",
        "gt_fee": "0",
        "gt_discount": false,
        "rebated_fee": "0",
        "rebated_fee_currency": "BTC"
      }
    ]
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» currency_pair string Currency pair
» total integer Total open orders in this currency pair
» orders array none
»» None object Spot order details
»»» id string Order ID
»»» text string User defined information. If not empty, must follow the rules below:

1. prefixed with t-
2. no longer than 28 bytes without t- prefix
3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.)
»»» create_time string Order creation time
»»» update_time string Order last modification time
»»» status string Order status

- open: to be filled
- closed: filled
- cancelled: cancelled
»»» currency_pair string Currency pair
»»» type string Order type. limit - limit order
»»» account string Account type. spot - use spot account; margin - use margin account
»»» side string Order side
»»» amount string Trade amount
»»» price string Order price
»»» time_in_force string Time in force

- gtc: GoodTillCancelled
- ioc: ImmediateOrCancelled, taker only
- poc: PendingOrCancelled, makes a post-only order that always enjoys a maker fee
»»» left string Amount left to fill
»»» fill_price string Total filled in quote currency. Deprecated in favor of filled_total
»»» filled_total string Total filled in quote currency
»»» fee string Fee deducted
»»» fee_currency string Fee currency unit
»»» point_fee string Point used to deduct fee
»»» gt_fee string GT used to deduct fee
»»» gt_discount boolean Whether GT fee discount is used
»»» rebated_fee string Rebated fee
»»» rebated_fee_currency string Rebated fee currency unit

Enumerated Values

Property Value
status open
status closed
status cancelled
type limit
account spot
account margin
side buy
side sell
time_in_force gtc
time_in_force ioc
time_in_force poc

Create an order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/orders'
query_param = ''
body='{"text":"t-123456","currency_pair":"ETH_BTC","type":"limit","account":"spot","side":"buy","amount":"1","price":"5.00032","time_in_force":"gtc","auto_borrow":false}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/spot/orders"
query_param=""
body_param='{"text":"t-123456","currency_pair":"ETH_BTC","type":"limit","account":"spot","side":"buy","amount":"1","price":"5.00032","time_in_force":"gtc","auto_borrow":false}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /spot/orders

Create an order

Body parameter

{
  "text": "t-123456",
  "currency_pair": "ETH_BTC",
  "type": "limit",
  "account": "spot",
  "side": "buy",
  "amount": "1",
  "price": "5.00032",
  "time_in_force": "gtc",
  "auto_borrow": false
}

Parameters

Name In Type Required Description
body body Order true none
» text body string false User defined information. If not empty, must follow the rules below:
» currency_pair body string true Currency pair
» type body string false Order type. limit - limit order
» account body string false Account type. spot - use spot account; margin - use margin account
» side body string true Order side
» amount body string true Trade amount
» price body string true Order price
» time_in_force body string false Time in force
» auto_borrow body boolean false Used in margin trading(i.e. account is margin) to allow automatic loan of insufficient part if balance is not enough.

Detailed descriptions

» text: User defined information. If not empty, must follow the rules below:

  1. prefixed with t-
  2. no longer than 28 bytes without t- prefix
  3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.)

» time_in_force: Time in force

Enumerated Values

Parameter Value
» type limit
» account spot
» account margin
» side buy
» side sell
» time_in_force gtc
» time_in_force ioc
» time_in_force poc

Example responses

201 Response

{
  "id": "12332324",
  "text": "t-123456",
  "create_time": "1548000000",
  "update_time": "1548000100",
  "currency_pair": "ETH_BTC",
  "status": "cancelled",
  "type": "limit",
  "account": "spot",
  "side": "buy",
  "amount": "1",
  "price": "5.00032",
  "time_in_force": "gtc",
  "left": "0.5",
  "filled_total": "2.50016",
  "fee": "0.005",
  "fee_currency": "ETH",
  "point_fee": "0",
  "gt_fee": "0",
  "gt_discount": false,
  "rebated_fee": "0",
  "rebated_fee_currency": "BTC"
}

Responses

Status Meaning Description Schema
201 Created Order created. Order

List orders

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/orders'
query_param = 'currency_pair=BTC_USDT&status=open'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/spot/orders"
query_param="currency_pair=BTC_USDT&status=open"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /spot/orders

List orders

Parameters

Name In Type Required Description
currency_pair query string true Currency pair
status query string true List orders based on status
page query integer false Page number
limit query integer false Maximum number of records returned. If status is open, maximum of limit is 100

Detailed descriptions

status: List orders based on status

open - order is waiting to be filled finished - order has been filled or cancelled

Enumerated Values

Parameter Value
status open
status finished

Example responses

200 Response

[
  {
    "id": "12332324",
    "text": "t-123456",
    "create_time": "1548000000",
    "update_time": "1548000100",
    "currency_pair": "ETH_BTC",
    "status": "cancelled",
    "type": "limit",
    "account": "spot",
    "side": "buy",
    "amount": "1",
    "price": "5.00032",
    "time_in_force": "gtc",
    "left": "0.5",
    "filled_total": "2.50016",
    "fee": "0.005",
    "fee_currency": "ETH",
    "point_fee": "0",
    "gt_fee": "0",
    "gt_discount": false,
    "rebated_fee": "0",
    "rebated_fee_currency": "BTC"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Order]

Cancel all open orders in specified currency pair

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/orders'
query_param = 'currency_pair=BTC_USDT'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/spot/orders"
query_param="currency_pair=BTC_USDT"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /spot/orders

Cancel all open orders in specified currency pair

Parameters

Name In Type Required Description
currency_pair query string true Currency pair
side query string false All bids or asks. Both included in not specified
account query string false Specify account type. Default to all account types being included

Enumerated Values

Parameter Value
side buy
side sell
account spot
account margin

Example responses

200 Response

[
  {
    "id": "12332324",
    "text": "t-123456",
    "create_time": "1548000000",
    "update_time": "1548000100",
    "currency_pair": "ETH_BTC",
    "status": "cancelled",
    "type": "limit",
    "account": "spot",
    "side": "buy",
    "amount": "1",
    "price": "5.00032",
    "time_in_force": "gtc",
    "left": "0.5",
    "filled_total": "2.50016",
    "fee": "0.005",
    "fee_currency": "ETH",
    "point_fee": "0",
    "gt_fee": "0",
    "gt_discount": false,
    "rebated_fee": "0",
    "rebated_fee_currency": "BTC"
  }
]

Responses

Status Meaning Description Schema
200 OK Batch cancellation request accepted. Query order status by listing orders [Order]

Cancel a batch of orders with an ID list

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/cancel_batch_orders'
query_param = ''
body='[{"currency_pair":"BTC_USDT","id":"123456"}]'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/spot/cancel_batch_orders"
query_param=""
body_param='[{"currency_pair":"BTC_USDT","id":"123456"}]'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /spot/cancel_batch_orders

Cancel a batch of orders with an ID list

Multiple currency pairs can be specified, but maximum 20 orders are allowed per request

Body parameter

[
  {
    "currency_pair": "BTC_USDT",
    "id": "123456"
  }
]

Parameters

Name In Type Required Description
body body array[object] true none

Example responses

200 Response

[
  {
    "currency_pair": "BTC_USDT",
    "id": "123456",
    "succeeded": true,
    "label": null,
    "message": null
  }
]

Responses

Status Meaning Description Schema
200 OK Batch cancellation completed [Inline]

Response Schema

Status Code 200

Name Type Description
» CancelOrderResult object Order cancellation result
»» currency_pair string Order currency pair
»» id string Order ID
»» succeeded boolean Whether cancellation succeeded
»» label string Error label when failed to cancel the order; emtpy if succeeded
»» message string Error message when failed to cancel the order; empty if succeeded

Get a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/orders/12345'
query_param = 'currency_pair=BTC_USDT'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/spot/orders/12345"
query_param="currency_pair=BTC_USDT"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /spot/orders/{order_id}

Get a single order

Parameters

Name In Type Required Description
order_id path string true ID returned on order successfully being created
currency_pair query string true Currency pair

Example responses

200 Response

{
  "id": "12332324",
  "text": "t-123456",
  "create_time": "1548000000",
  "update_time": "1548000100",
  "currency_pair": "ETH_BTC",
  "status": "cancelled",
  "type": "limit",
  "account": "spot",
  "side": "buy",
  "amount": "1",
  "price": "5.00032",
  "time_in_force": "gtc",
  "left": "0.5",
  "filled_total": "2.50016",
  "fee": "0.005",
  "fee_currency": "ETH",
  "point_fee": "0",
  "gt_fee": "0",
  "gt_discount": false,
  "rebated_fee": "0",
  "rebated_fee_currency": "BTC"
}

Responses

Status Meaning Description Schema
200 OK Detail retrieved Order

Cancel a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/orders/12345'
query_param = 'currency_pair=BTC_USDT'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/spot/orders/12345"
query_param="currency_pair=BTC_USDT"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /spot/orders/{order_id}

Cancel a single order

Parameters

Name In Type Required Description
order_id path string true ID returned on order successfully being created
currency_pair query string true Currency pair

Example responses

200 Response

{
  "id": "12332324",
  "text": "t-123456",
  "create_time": "1548000000",
  "update_time": "1548000100",
  "currency_pair": "ETH_BTC",
  "status": "cancelled",
  "type": "limit",
  "account": "spot",
  "side": "buy",
  "amount": "1",
  "price": "5.00032",
  "time_in_force": "gtc",
  "left": "0.5",
  "filled_total": "2.50016",
  "fee": "0.005",
  "fee_currency": "ETH",
  "point_fee": "0",
  "gt_fee": "0",
  "gt_discount": false,
  "rebated_fee": "0",
  "rebated_fee_currency": "BTC"
}

Responses

Status Meaning Description Schema
200 OK Order cancelled Order

List personal trading history

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/spot/my_trades'
query_param = 'currency_pair=BTC_USDT'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/spot/my_trades"
query_param="currency_pair=BTC_USDT"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /spot/my_trades

List personal trading history

Parameters

Name In Type Required Description
currency_pair query string true Currency pair
limit query integer false Maximum number of records returned in one list
page query integer false Page number
order_id query string false List all trades of specified order

Example responses

200 Response

[
  {
    "id": "1232893232",
    "create_time": "1548000000",
    "order_id": "4128442423",
    "side": "buy",
    "role": "maker",
    "amount": "0.15",
    "price": "0.03",
    "fee": "0.0005",
    "fee_currency": "ETH",
    "point_fee": "0",
    "gt_fee": "0"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» id string Trade ID
» create_time string Trading time
» side string Order side
» role string Trade role
» amount string Trade amount
» price string Order price
» order_id string Related order ID. No value in public endpoints
» fee string Fee deducted. No value in public endpoints
» fee_currency string Fee currency unit. No value in public endpoints
» point_fee string Point used to deduct fee
» gt_fee string GT used to deduct fee

Enumerated Values

Property Value
side buy
side sell
role taker
role maker

Margin

Margin API; margin trading uses spot trading API

List all supported currency pairs supported in margin trading

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/currency_pairs'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/margin/currency_pairs \
  -H 'Accept: application/json'

GET /margin/currency_pairs

List all supported currency pairs supported in margin trading

Example responses

200 Response

[
  {
    "id": "ETH_USDT",
    "base": "ETH",
    "quote": "USDT",
    "leverage": 3,
    "min_base_amount": "0.01",
    "min_quote_amount": "100",
    "max_quote_amount": "1000000"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» id string Currency pair
» base string Base currency
» quote string Quote currency
» leverage integer Leverage
» min_base_amount string Minimum base currency to loan, null means no limit
» min_quote_amount string Minimum quote currency to loan, null means no limit
» max_quote_amount string Maximum borrowable amount for quote currency. Base currency limit is calculated by quote maximum and market price. null means no limit

Order book of lending loans

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/funding_book'
query_param = 'currency=BTC'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/margin/funding_book?currency=BTC \
  -H 'Accept: application/json'

GET /margin/funding_book

Order book of lending loans

Parameters

Name In Type Required Description
currency query string true Retrieved specified currency related data

Example responses

200 Response

[
  {
    "rate": "0.002",
    "amount": "320.03",
    "days": 10
  }
]

Responses

Status Meaning Description Schema
200 OK Order book retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» rate string Loan rate
» amount string Borrowable amount
» days integer How long the loan should be repaid

Margin account list

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/accounts'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/margin/accounts"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /margin/accounts

Margin account list

Parameters

Name In Type Required Description
currency_pair query string false Currency pair

Example responses

200 Response

[
  {
    "currency_pair": "ETH_BTC",
    "base": {
      "currency": "ETH",
      "available": "30.1",
      "locked": "0",
      "borrowed": "10.1"
    },
    "quote": {
      "currency": "BTC",
      "available": "10",
      "locked": "0",
      "borrowed": "1.5"
    }
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» None object Margin account detail. base refers to base currency, while `quotes to quote currency
»» currency_pair string Currency pair
»» base object Account currency detail
»»» currency string Currency name
»»» available string Amount suitable for margin trading.
»»» locked string Locked amount, used in margin trading
»»» borrowed string Borrowed amount
»» quote object Account currency detail
»»» currency string Currency name
»»» available string Amount suitable for margin trading.
»»» locked string Locked amount, used in margin trading
»»» borrowed string Borrowed amount

List margin account balance change history

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/account_book'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/margin/account_book"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /margin/account_book

List margin account balance change history

Only transferring from or to margin account are provided for now. Time range allows 30 days at most

Parameters

Name In Type Required Description
currency query string false List records related to specified currency only. If specified, currency_pair is also required.
currency_pair query string false List records related to specified currency pair. Used in combination with currency. Ignored if currency is not provided
from query integer(int64) false Time range beginning, default to 7 days before current time
to query integer(int64) false Time range ending, default to current time
page query integer false Page number
limit query integer false Maximum number of records returned in one list

Example responses

200 Response

[
  {
    "id": "123456",
    "time": "1547633726",
    "currency": "BTC",
    "currency_pair": "BTC_USDT",
    "change": "1.03",
    "balance": "4.59316525194"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» id string Balance change record ID
» time string Balance changed timestamp
» currency string Currency changed
» currency_pair string Account currency pair
» change string Amount changed. Positive value means transferring in, while negative out
» balance string Balance after change

Funding account list

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/funding_accounts'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/margin/funding_accounts"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /margin/funding_accounts

Funding account list

Parameters

Name In Type Required Description
currency query string false Retrieved specified currency related data

Example responses

200 Response

[
  {
    "currency": "BTC",
    "available": "1.238",
    "locked": "0",
    "lent": "3.32",
    "total_lent": "3.32"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» currency string Currency name
» available string Available assets to lend, which is identical to spot account available
» locked string Locked amount. i.e. amount in open loans
» lent string Amount that is loaned but not repaid
» total_lent string Amount used for lending. total_lent = lent + locked

Lend or borrow

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loans'
query_param = ''
body='{"side":"borrow","currency":"BTC","rate":"0.002","amount":"1.5","days":10,"auto_renew":true,"currency_pair":"ETH_BTC","fee_rate":"0.18","orig_id":"123424"}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/margin/loans"
query_param=""
body_param='{"side":"borrow","currency":"BTC","rate":"0.002","amount":"1.5","days":10,"auto_renew":true,"currency_pair":"ETH_BTC","fee_rate":"0.18","orig_id":"123424"}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /margin/loans

Lend or borrow

Body parameter

{
  "side": "borrow",
  "currency": "BTC",
  "rate": "0.002",
  "amount": "1.5",
  "days": 10,
  "auto_renew": true,
  "currency_pair": "ETH_BTC",
  "fee_rate": "0.18",
  "orig_id": "123424"
}

Parameters

Name In Type Required Description
body body Loan true none
» side body string true Loan side
» currency body string true Loan currency
» rate body string false Loan rate. Only rates in [0.0002, 0.002] are supported.
» amount body string true Loan amount
» days body integer true Loan days
» auto_renew body boolean false Auto renew the loan on expiration
» currency_pair body string false Currency pair. Required for borrowing side
» fee_rate body string false Loan fee rate
» orig_id body string false Original loan ID if the loan is auto-renewed. Equal to id if not

Detailed descriptions

» rate: Loan rate. Only rates in [0.0002, 0.002] are supported.

Not required in lending. Market rate calculated from recent rates will be used if not set

Enumerated Values

Parameter Value
» side lend
» side borrow

Example responses

201 Response

{
  "id": "123435",
  "create_time": "1548000000",
  "expire_time": "1548100000",
  "side": "borrow",
  "status": "loaned",
  "currency": "BTC",
  "rate": "0.002",
  "amount": "1.5",
  "days": 10,
  "auto_renew": true,
  "currency_pair": "ETH_BTC",
  "left": "0",
  "repaid": "0",
  "paid_interest": "0",
  "unpaid_interest": "0",
  "fee_rate": "0.18",
  "orig_id": "123424"
}

Responses

Status Meaning Description Schema
201 Created Loan created Loan

List all loans

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loans'
query_param = 'status=open&side=lend'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/margin/loans"
query_param="status=open&side=lend"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /margin/loans

List all loans

Parameters

Name In Type Required Description
status query string true Loan status
side query string true Lend or borrow
currency query string false Retrieved specified currency related data
currency_pair query string false Currency pair
sort_by query string false Specify which field is used to sort. create_time or rate is supported. Default to create_time
reverse_sort query boolean false Whether to sort in descending order. Default to true
page query integer false Page number
limit query integer false Maximum number of records returned in one list

Enumerated Values

Parameter Value
status open
status loaned
status finished
status auto_repaid
side lend
side borrow
sort_by create_time
sort_by rate

Example responses

200 Response

[
  {
    "id": "123435",
    "create_time": "1548000000",
    "expire_time": "1548100000",
    "side": "borrow",
    "status": "loaned",
    "currency": "BTC",
    "rate": "0.002",
    "amount": "1.5",
    "days": 10,
    "auto_renew": true,
    "currency_pair": "ETH_BTC",
    "left": "0",
    "repaid": "0",
    "paid_interest": "0",
    "unpaid_interest": "0",
    "fee_rate": "0.18",
    "orig_id": "123424"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Loan]

Merge multiple lending loans

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/merged_loans'
query_param = 'currency=BTC&ids=123,234,345'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/margin/merged_loans"
query_param="currency=BTC&ids=123,234,345"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /margin/merged_loans

Merge multiple lending loans

Parameters

Name In Type Required Description
currency query string true Retrieved specified currency related data
ids query string true Lending loan ID list separated by ,. Maximum of 20 IDs are allowed in one request

Example responses

201 Response

{
  "id": "123435",
  "create_time": "1548000000",
  "expire_time": "1548100000",
  "side": "borrow",
  "status": "loaned",
  "currency": "BTC",
  "rate": "0.002",
  "amount": "1.5",
  "days": 10,
  "auto_renew": true,
  "currency_pair": "ETH_BTC",
  "left": "0",
  "repaid": "0",
  "paid_interest": "0",
  "unpaid_interest": "0",
  "fee_rate": "0.18",
  "orig_id": "123424"
}

Responses

Status Meaning Description Schema
201 Created Loans merged Loan

Retrieve one single loan detail

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loans/12345'
query_param = 'side=lend'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/margin/loans/12345"
query_param="side=lend"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /margin/loans/{loan_id}

Retrieve one single loan detail

Parameters

Name In Type Required Description
side query string true Lend or borrow
loan_id path string true Loan ID

Enumerated Values

Parameter Value
side lend
side borrow

Example responses

200 Response

{
  "id": "123435",
  "create_time": "1548000000",
  "expire_time": "1548100000",
  "side": "borrow",
  "status": "loaned",
  "currency": "BTC",
  "rate": "0.002",
  "amount": "1.5",
  "days": 10,
  "auto_renew": true,
  "currency_pair": "ETH_BTC",
  "left": "0",
  "repaid": "0",
  "paid_interest": "0",
  "unpaid_interest": "0",
  "fee_rate": "0.18",
  "orig_id": "123424"
}

Responses

Status Meaning Description Schema
200 OK List retrieved Loan

Modify a loan

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loans/12345'
query_param = ''
body='{"currency":"BTC","side":"borrow","currency_pair":"BTC_USDT","auto_renew":false}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('PATCH', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('PATCH', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="PATCH"
url="/margin/loans/12345"
query_param=""
body_param='{"currency":"BTC","side":"borrow","currency_pair":"BTC_USDT","auto_renew":false}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

PATCH /margin/loans/{loan_id}

Modify a loan

Only auto_renew modification is supported currently

Body parameter

{
  "currency": "BTC",
  "side": "borrow",
  "currency_pair": "BTC_USDT",
  "auto_renew": false
}

Parameters

Name In Type Required Description
body body object true none
» currency body string true Loan currency
» side body string true Loan side. Possible values are lend and borrow. For LoanRecord patching, only lend is supported
» auto_renew body boolean true Auto renew
» currency_pair body string false Currency pair. Required for borrowing side
» loan_id body string false Loan ID. Required for LoanRecord patching
loan_id path string true Loan ID

Enumerated Values

Parameter Value
» side lend
» side borrow

Example responses

200 Response

{
  "id": "123435",
  "create_time": "1548000000",
  "expire_time": "1548100000",
  "side": "borrow",
  "status": "loaned",
  "currency": "BTC",
  "rate": "0.002",
  "amount": "1.5",
  "days": 10,
  "auto_renew": true,
  "currency_pair": "ETH_BTC",
  "left": "0",
  "repaid": "0",
  "paid_interest": "0",
  "unpaid_interest": "0",
  "fee_rate": "0.18",
  "orig_id": "123424"
}

Responses

Status Meaning Description Schema
200 OK Updated Loan

Cancel lending loan

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loans/12345'
query_param = 'currency=BTC'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/margin/loans/12345"
query_param="currency=BTC"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /margin/loans/{loan_id}

Cancel lending loan

Only lending loans can be cancelled

Parameters

Name In Type Required Description
currency query string true Retrieved specified currency related data
loan_id path string true Loan ID

Example responses

200 Response

{
  "id": "123435",
  "create_time": "1548000000",
  "expire_time": "1548100000",
  "side": "borrow",
  "status": "loaned",
  "currency": "BTC",
  "rate": "0.002",
  "amount": "1.5",
  "days": 10,
  "auto_renew": true,
  "currency_pair": "ETH_BTC",
  "left": "0",
  "repaid": "0",
  "paid_interest": "0",
  "unpaid_interest": "0",
  "fee_rate": "0.18",
  "orig_id": "123424"
}

Responses

Status Meaning Description Schema
200 OK Order cancelled Loan

Repay a loan

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loans/12345/repayment'
query_param = ''
body='{"currency_pair":"ETH_BTC","currency":"ETH","mode":"partial","amount":"100"}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/margin/loans/12345/repayment"
query_param=""
body_param='{"currency_pair":"ETH_BTC","currency":"ETH","mode":"partial","amount":"100"}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /margin/loans/{loan_id}/repayment

Repay a loan

Body parameter

{
  "currency_pair": "ETH_BTC",
  "currency": "ETH",
  "mode": "partial",
  "amount": "100"
}

Parameters

Name In Type Required Description
body body object true none
» currency_pair body string true Currency pair
» currency body string true Loan currency
» mode body string true Repay mode. all - repay all; partial - repay only some portion
» amount body string false Repay amount. Required in partial mode
loan_id path string true Loan ID

Enumerated Values

Parameter Value
» mode all
» mode partial

Example responses

200 Response

{
  "id": "123435",
  "create_time": "1548000000",
  "expire_time": "1548100000",
  "side": "borrow",
  "status": "loaned",
  "currency": "BTC",
  "rate": "0.002",
  "amount": "1.5",
  "days": 10,
  "auto_renew": true,
  "currency_pair": "ETH_BTC",
  "left": "0",
  "repaid": "0",
  "paid_interest": "0",
  "unpaid_interest": "0",
  "fee_rate": "0.18",
  "orig_id": "123424"
}

Responses

Status Meaning Description Schema
200 OK Loan repaid Loan

List loan repayment records

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loans/12345/repayment'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/margin/loans/12345/repayment"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /margin/loans/{loan_id}/repayment

List loan repayment records

Parameters

Name In Type Required Description
loan_id path string true Loan ID

Example responses

200 Response

[
  {
    "id": "12342323",
    "create_time": "1578000000",
    "principal": "100",
    "interest": "2"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» id string Loan record ID
» create_time string Repayment time
» principal string Repaid principal
» interest string Repaid interest

List repayment records of specified loan

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loan_records'
query_param = 'loan_id=12345'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/margin/loan_records"
query_param="loan_id=12345"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /margin/loan_records

List repayment records of specified loan

Parameters

Name In Type Required Description
loan_id query string true Loan ID
status query string false Loan record status
page query integer false Page number
limit query integer false Maximum number of records returned in one list

Enumerated Values

Parameter Value
status loaned
status finished

Example responses

200 Response

[
  {
    "id": "122342323",
    "loan_id": "12840282",
    "create_time": "1548000000",
    "expire_time": "1548100000",
    "status": "loaned",
    "borrow_user_id": "******12",
    "currency": "BTC",
    "rate": "0.002",
    "amount": "1.5",
    "days": 10,
    "auto_renew": false,
    "repaid": "0",
    "paid_interest": "0",
    "unpaid_interest": "0"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [LoanRecord]

Get one single loan record

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loan_records/12345'
query_param = 'loan_id=12345'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/margin/loan_records/12345"
query_param="loan_id=12345"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /margin/loan_records/{loan_record_id}

Get one single loan record

Parameters

Name In Type Required Description
loan_id query string true Loan ID
loan_record_id path string true Loan record ID

Example responses

200 Response

{
  "id": "122342323",
  "loan_id": "12840282",
  "create_time": "1548000000",
  "expire_time": "1548100000",
  "status": "loaned",
  "borrow_user_id": "******12",
  "currency": "BTC",
  "rate": "0.002",
  "amount": "1.5",
  "days": 10,
  "auto_renew": false,
  "repaid": "0",
  "paid_interest": "0",
  "unpaid_interest": "0"
}

Responses

Status Meaning Description Schema
200 OK Detail retrieved LoanRecord

Modify a loan record

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/margin/loan_records/12345'
query_param = ''
body='{"currency":"BTC","side":"borrow","currency_pair":"BTC_USDT","auto_renew":false}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('PATCH', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('PATCH', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="PATCH"
url="/margin/loan_records/12345"
query_param=""
body_param='{"currency":"BTC","side":"borrow","currency_pair":"BTC_USDT","auto_renew":false}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

PATCH /margin/loan_records/{loan_record_id}

Modify a loan record

Only auto_renew modification is supported currently

Body parameter

{
  "currency": "BTC",
  "side": "borrow",
  "currency_pair": "BTC_USDT",
  "auto_renew": false
}

Parameters

Name In Type Required Description
body body object true none
» currency body string true Loan currency
» side body string true Loan side. Possible values are lend and borrow. For LoanRecord patching, only lend is supported
» auto_renew body boolean true Auto renew
» currency_pair body string false Currency pair. Required for borrowing side
» loan_id body string false Loan ID. Required for LoanRecord patching
loan_record_id path string true Loan record ID

Enumerated Values

Parameter Value
» side lend
» side borrow

Example responses

200 Response

{
  "id": "122342323",
  "loan_id": "12840282",
  "create_time": "1548000000",
  "expire_time": "1548100000",
  "status": "loaned",
  "borrow_user_id": "******12",
  "currency": "BTC",
  "rate": "0.002",
  "amount": "1.5",
  "days": 10,
  "auto_renew": false,
  "repaid": "0",
  "paid_interest": "0",
  "unpaid_interest": "0"
}

Responses

Status Meaning Description Schema
200 OK Loan record updated LoanRecord

Futures

永续合约

List all futures contracts

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/contracts'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/futures/btc/contracts \
  -H 'Accept: application/json'

GET /futures/{settle}/contracts

List all futures contracts

Parameters

Name In Type Required Description
settle path string true Settle currency

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

[
  {
    "name": "BTC_USD",
    "type": "inverse",
    "quanto_multiplier": "0",
    "mark_type": "index",
    "last_price": "4123",
    "mark_price": "4121.41",
    "index_price": "4121.5",
    "funding_next_apply": 1546588800,
    "funding_rate": "0.000333",
    "funding_interval": 28800,
    "funding_offset": 0,
    "interest_rate": "0.001",
    "order_price_round": "0.5",
    "mark_price_round": "0.01",
    "leverage_min": "1",
    "leverage_max": "100",
    "maintenance_rate": "0.005",
    "risk_limit_base": "10",
    "risk_limit_step": "10",
    "risk_limit_max": "50",
    "maker_fee_rate": "-0.00025",
    "taker_fee_rate": "0.00075",
    "ref_discount_rate": "0",
    "ref_rebate_rate": "0.2",
    "order_price_deviate": "1",
    "order_size_min": 1,
    "order_size_max": 1000000,
    "orders_limit": 50,
    "orderbook_id": 39635902,
    "trade_id": 6935987,
    "trade_size": 1992012909,
    "position_size": 4323221,
    "config_change_time": 1547540148,
    "in_delisting": false
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Contract]

Get a single contract

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/contracts/BTC_USD'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/futures/btc/contracts/BTC_USD \
  -H 'Accept: application/json'

GET /futures/{settle}/contracts/{contract}

Get a single contract

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "name": "BTC_USD",
  "type": "inverse",
  "quanto_multiplier": "0",
  "mark_type": "index",
  "last_price": "4123",
  "mark_price": "4121.41",
  "index_price": "4121.5",
  "funding_next_apply": 1546588800,
  "funding_rate": "0.000333",
  "funding_interval": 28800,
  "funding_offset": 0,
  "interest_rate": "0.001",
  "order_price_round": "0.5",
  "mark_price_round": "0.01",
  "leverage_min": "1",
  "leverage_max": "100",
  "maintenance_rate": "0.005",
  "risk_limit_base": "10",
  "risk_limit_step": "10",
  "risk_limit_max": "50",
  "maker_fee_rate": "-0.00025",
  "taker_fee_rate": "0.00075",
  "ref_discount_rate": "0",
  "ref_rebate_rate": "0.2",
  "order_price_deviate": "1",
  "order_size_min": 1,
  "order_size_max": 1000000,
  "orders_limit": 50,
  "orderbook_id": 39635902,
  "trade_id": 6935987,
  "trade_size": 1992012909,
  "position_size": 4323221,
  "config_change_time": 1547540148,
  "in_delisting": false
}

Responses

Status Meaning Description Schema
200 OK Contract information Contract

Futures order book

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/order_book'
query_param = 'contract=BTC_USD'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/futures/btc/order_book?contract=BTC_USD \
  -H 'Accept: application/json'

GET /futures/{settle}/order_book

Futures order book

Bids will be sorted by price from high to low, while asks sorted reversely

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string true Futures contract
interval query string false Order depth. 0 means no aggregation is applied. default to 0
limit query integer false Maximum number of order depth data in asks or bids

Enumerated Values

Parameter Value
settle btc
settle usdt
interval 0
interval 0.1
interval 0.01

Example responses

200 Response

{
  "asks": [
    {
      "p": "1.52",
      "s": 100
    },
    {
      "p": "1.53",
      "s": 40
    }
  ],
  "bids": [
    {
      "p": "1.17",
      "s": 150
    },
    {
      "p": "1.16",
      "s": 203
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Order book retrieved Inline

Response Schema

Status Code 200

Name Type Description
» asks array Asks order depth
»» futures_order_book_item object none
»»» p string Price
»»» s integer(int64) Size
»» bids array Bids order depth
»»» futures_order_book_item object none
»»»» p string Price
»»»» s integer(int64) Size

Futures trading history

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/trades'
query_param = 'contract=BTC_USD'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/futures/btc/trades?contract=BTC_USD \
  -H 'Accept: application/json'

GET /futures/{settle}/trades

Futures trading history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string true Futures contract
limit query integer false Maximum number of records returned in one list
last_id query string false Specify list staring point using the id of last record in previous list-query results
from query integer(int64) false Specify starting time in Unix seconds. If not specified, to and limit will be used to limit response items.
to query integer(int64) false Specify end time in Unix seconds, default to current time

Detailed descriptions

last_id: Specify list staring point using the id of last record in previous list-query results

This parameter is deprecated. Use from and to instead to limit time range

from: Specify starting time in Unix seconds. If not specified, to and limit will be used to limit response items. If items between from and to are more than limit, only limit number will be returned.

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

[
  {
    "id": 121234231,
    "create_time": 1514764800,
    "contract": "BTC_USD",
    "size": -100,
    "price": "100.123"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» id integer(int64) Trade ID
» create_time number Trading time
» contract string Futures contract
» size integer(int64) Trading size
» price string Trading price

Get futures candlesticks

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/candlesticks'
query_param = 'contract=BTC_USD'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/futures/btc/candlesticks?contract=BTC_USD \
  -H 'Accept: application/json'

GET /futures/{settle}/candlesticks

Get futures candlesticks

Return specified contract candlesticks. If prefix contract with mark_, the contract's mark price candlesticks are returned; if prefix with index_, index price candlesticks will be returned.

Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying from, to and interval

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string true Futures contract
from query integer(int64) false Start time of candlesticks, formatted in Unix timestamp in seconds.
to query integer(int64) false End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
limit query integer false Maximum recent data points returned. limit is conflicted with from and to. If either from or to is specified, request will be rejected.
interval query string false Interval time between data points

Detailed descriptions

from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default toto - 100 * interval if not specified

Enumerated Values

Parameter Value
settle btc
settle usdt
interval 10s
interval 1m
interval 5m
interval 15m
interval 30m
interval 1h
interval 4h
interval 8h
interval 1d
interval 7d

Example responses

200 Response

[
  {
    "t": 1539852480,
    "v": 97151,
    "c": "1.032",
    "h": "1.032",
    "l": "1.032",
    "o": "1.032"
  }
]

Responses

Status Meaning Description Schema
200 OK Successfully retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array [data point in every timestamp]
» None object data point in every timestamp
»» t number Unix timestamp in seconds
»» v integer(int64) size volume. Only returned if contract is not prefixed
»» c string Close price
»» h string Highest price
»» l string Lowest price
»» o string Open price

List futures tickers

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/tickers'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/futures/btc/tickers \
  -H 'Accept: application/json'

GET /futures/{settle}/tickers

List futures tickers

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string false Futures contract, return related data only if specified

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

[
  {
    "contract": "BTC_USD",
    "last": "6432",
    "low_24h": "6278",
    "high_24h": "6790",
    "change_percentage": "4.43",
    "total_size": "32323904",
    "volume_24h": "184040233284",
    "volume_24h_btc": "28613220",
    "volume_24h_usd": "184040233284",
    "volume_24h_base": "28613220",
    "volume_24h_quote": "184040233284",
    "volume_24h_settle": "28613220",
    "mark_price": "6534",
    "funding_rate": "0.0001",
    "funding_rate_indicative": "0.0001",
    "index_price": "6531"
  }
]

Responses

Status Meaning Description Schema
200 OK Successfully retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» contract string Futures contract
» last string Last trading price
» change_percentage string Change percentage.
» total_size string Contract total size
» low_24h string Lowest trading price in recent 24h
» high_24h string Highest trading price in recent 24h
» volume_24h string Trade size in recent 24h
» volume_24h_btc string Trade volumes in recent 24h in BTC(deprecated, use volume_24h_base, volume_24h_quote, volume_24h_settle instead)
» volume_24h_usd string Trade volumes in recent 24h in USD(deprecated, use volume_24h_base, volume_24h_quote, volume_24h_settle instead)
» volume_24h_base string Trade volume in recent 24h, in base currency
» volume_24h_quote string Trade volume in recent 24h, in quote currency
» volume_24h_settle string Trade volume in recent 24h, in settle currency
» mark_price string Recent mark price
» funding_rate string Funding rate
» funding_rate_indicative string Indicative Funding rate in next period
» index_price string Index price
» quanto_base_rate string Exchange rate of base currency and settlement currency in Quanto contract. Not existed in contract of other types

Funding rate history

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/funding_rate'
query_param = 'contract=BTC_USD'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/futures/btc/funding_rate?contract=BTC_USD \
  -H 'Accept: application/json'

GET /futures/{settle}/funding_rate

Funding rate history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string true Futures contract
limit query integer false Maximum number of records returned in one list

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

[
  {
    "t": 1543968000,
    "r": "0.000157"
  }
]

Responses

Status Meaning Description Schema
200 OK History retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» t integer(int64) Unix timestamp in seconds
» r string Funding rate

Futures insurance balance history

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/insurance'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/futures/btc/insurance \
  -H 'Accept: application/json'

GET /futures/{settle}/insurance

Futures insurance balance history

Parameters

Name In Type Required Description
settle path string true Settle currency
limit query integer false Maximum number of records returned in one list

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

[
  {
    "t": 1543968000,
    "b": "83.0031"
  }
]

Responses

Status Meaning Description Schema
200 OK Successfully retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» t integer(int64) Unix timestamp in seconds
» b string Insurance balance

Query futures account

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/accounts'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/accounts"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/accounts

Query futures account

Parameters

Name In Type Required Description
settle path string true Settle currency

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "total": "4.4516",
  "unrealised_pnl": "0",
  "available": "4.98",
  "order_margin": "0.1",
  "position_margin": "5.1",
  "point": "10000",
  "currency": "BTC"
}

Responses

Status Meaning Description Schema
200 OK List retrieved Inline

Response Schema

Status Code 200

Name Type Description
» total string Total assets, total = position_margin + order_margin + available
» unrealised_pnl string Unrealized PNL
» position_margin string Position margin
» order_margin string Order margin of unfinished orders
» available string Available balance to transfer out or trade
» point string POINT amount
» currency string Settle currency

Query account book

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/account_book'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/account_book"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/account_book

Query account book

Parameters

Name In Type Required Description
settle path string true Settle currency
limit query integer false Maximum number of records returned in one list
from query integer(int64) false Start timestamp
to query integer(int64) false End timestamp
type query string false Changing Type:

Detailed descriptions

type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate

Enumerated Values

Parameter Value
settle btc
settle usdt
type dnw
type pnl
type fee
type refr
type fund
type point_dnw
type point_fee
type point_refr

Example responses

200 Response

[
  {
    "time": 1547633726,
    "change": "0.000010152188",
    "balance": "4.59316525194",
    "text": "ETH_USD:6086261",
    "type": "fee"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» time number Change time
» change string Change amount
» balance string Balance after change
» type string Changing Type:
- dnw: Deposit & Withdraw
- pnl: Profit & Loss by reducing position
- fee: Trading fee
- refr: Referrer rebate
- fund: Funding
- point_dnw: POINT Deposit & Withdraw
- point_fee: POINT Trading fee
- point_refr: POINT Referrer rebate
» text string Comment

Enumerated Values

Property Value
type dnw
type pnl
type fee
type refr
type fund
type point_dnw
type point_fee
type point_refr

List all positions of a user

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/positions'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/positions"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/positions

List all positions of a user

Parameters

Name In Type Required Description
settle path string true Settle currency

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

[
  {
    "user": 10000,
    "contract": "BTC_USD",
    "size": -9440,
    "leverage": "0",
    "risk_limit": "100",
    "leverage_max": "100",
    "maintenance_rate": "0.005",
    "value": "2.497143098997",
    "margin": "4.431548146258",
    "entry_price": "3779.55",
    "liq_price": "99999999",
    "mark_price": "3780.32",
    "unrealised_pnl": "-0.000507486844",
    "realised_pnl": "0.045543982432",
    "history_pnl": "0",
    "last_close_pnl": "0",
    "realised_point": "0",
    "history_point": "0",
    "adl_ranking": 5,
    "pending_orders": 16,
    "close_order": {
      "id": 232323,
      "price": "3779",
      "is_liq": false
    }
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Position]

Get single position

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/positions/BTC_USD'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/positions/BTC_USD"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/positions/{contract}

Get single position

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "user": 10000,
  "contract": "BTC_USD",
  "size": -9440,
  "leverage": "0",
  "risk_limit": "100",
  "leverage_max": "100",
  "maintenance_rate": "0.005",
  "value": "2.497143098997",
  "margin": "4.431548146258",
  "entry_price": "3779.55",
  "liq_price": "99999999",
  "mark_price": "3780.32",
  "unrealised_pnl": "-0.000507486844",
  "realised_pnl": "0.045543982432",
  "history_pnl": "0",
  "last_close_pnl": "0",
  "realised_point": "0",
  "history_point": "0",
  "adl_ranking": 5,
  "pending_orders": 16,
  "close_order": {
    "id": 232323,
    "price": "3779",
    "is_liq": false
  }
}

Responses

Status Meaning Description Schema
200 OK Position information Position

Update position margin

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/positions/BTC_USD/margin'
query_param = 'change=0.01'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/futures/btc/positions/BTC_USD/margin"
query_param="change=0.01"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /futures/{settle}/positions/{contract}/margin

Update position margin

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract
change query string true Margin change. Use positive number to increase margin, negative number otherwise.

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "user": 10000,
  "contract": "BTC_USD",
  "size": -9440,
  "leverage": "0",
  "risk_limit": "100",
  "leverage_max": "100",
  "maintenance_rate": "0.005",
  "value": "2.497143098997",
  "margin": "4.431548146258",
  "entry_price": "3779.55",
  "liq_price": "99999999",
  "mark_price": "3780.32",
  "unrealised_pnl": "-0.000507486844",
  "realised_pnl": "0.045543982432",
  "history_pnl": "0",
  "last_close_pnl": "0",
  "realised_point": "0",
  "history_point": "0",
  "adl_ranking": 5,
  "pending_orders": 16,
  "close_order": {
    "id": 232323,
    "price": "3779",
    "is_liq": false
  }
}

Responses

Status Meaning Description Schema
200 OK Position information Position

Update position leverage

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/positions/BTC_USD/leverage'
query_param = 'leverage=10'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/futures/btc/positions/BTC_USD/leverage"
query_param="leverage=10"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /futures/{settle}/positions/{contract}/leverage

Update position leverage

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract
leverage query string true New position leverage

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "user": 10000,
  "contract": "BTC_USD",
  "size": -9440,
  "leverage": "0",
  "risk_limit": "100",
  "leverage_max": "100",
  "maintenance_rate": "0.005",
  "value": "2.497143098997",
  "margin": "4.431548146258",
  "entry_price": "3779.55",
  "liq_price": "99999999",
  "mark_price": "3780.32",
  "unrealised_pnl": "-0.000507486844",
  "realised_pnl": "0.045543982432",
  "history_pnl": "0",
  "last_close_pnl": "0",
  "realised_point": "0",
  "history_point": "0",
  "adl_ranking": 5,
  "pending_orders": 16,
  "close_order": {
    "id": 232323,
    "price": "3779",
    "is_liq": false
  }
}

Responses

Status Meaning Description Schema
200 OK Position information Position

Update position risk limit

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/positions/BTC_USD/risk_limit'
query_param = 'risk_limit=10'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/futures/btc/positions/BTC_USD/risk_limit"
query_param="risk_limit=10"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /futures/{settle}/positions/{contract}/risk_limit

Update position risk limit

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract
risk_limit query string true New position risk limit

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "user": 10000,
  "contract": "BTC_USD",
  "size": -9440,
  "leverage": "0",
  "risk_limit": "100",
  "leverage_max": "100",
  "maintenance_rate": "0.005",
  "value": "2.497143098997",
  "margin": "4.431548146258",
  "entry_price": "3779.55",
  "liq_price": "99999999",
  "mark_price": "3780.32",
  "unrealised_pnl": "-0.000507486844",
  "realised_pnl": "0.045543982432",
  "history_pnl": "0",
  "last_close_pnl": "0",
  "realised_point": "0",
  "history_point": "0",
  "adl_ranking": 5,
  "pending_orders": 16,
  "close_order": {
    "id": 232323,
    "price": "3779",
    "is_liq": false
  }
}

Responses

Status Meaning Description Schema
200 OK Position information Position

Create a futures order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/orders'
query_param = ''
body='{"contract":"BTC_USD","size":6024,"iceberg":0,"price":"3765","tif":"gtc","text":"t-my-custom-id"}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/futures/btc/orders"
query_param=""
body_param='{"contract":"BTC_USD","size":6024,"iceberg":0,"price":"3765","tif":"gtc","text":"t-my-custom-id"}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /futures/{settle}/orders

Create a futures order

Zero-fill order cannot be retrieved 60 seconds after cancellation

Body parameter

{
  "contract": "BTC_USD",
  "size": 6024,
  "iceberg": 0,
  "price": "3765",
  "tif": "gtc",
  "text": "t-my-custom-id"
}

Parameters

Name In Type Required Description
body body FuturesOrder true none
» contract body string true Futures contract
» size body integer(int64) false Order size. Specify positive number to make a bid, and negative number to ask
» iceberg body integer(int64) false Display size for iceberg order. 0 for non-iceberg. Note that you would pay the taker fee for the hidden size
» price body string false Order price. 0 for market order with tif set as ioc
» close body boolean false Set as true to close the position, with size set to 0
» reduce_only body boolean false Set as true to be reduce-only order
» tif body string false Time in force
» text body string false User defined information. If not empty, must follow the rules below:
settle path string true Settle currency

Detailed descriptions

» tif: Time in force

» text: User defined information. If not empty, must follow the rules below:

  1. prefixed with t-
  2. no longer than 28 bytes without t- prefix
  3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) Besides user defined information, reserved contents are listed below, denoting how the order is created:

Enumerated Values

Parameter Value
» tif gtc
» tif ioc
» tif poc
settle btc
settle usdt

Example responses

201 Response

{
  "id": 15675394,
  "user": 100000,
  "contract": "BTC_USD",
  "create_time": 1546569968,
  "size": 6024,
  "iceberg": 0,
  "left": 6024,
  "price": "3765",
  "fill_price": "0",
  "mkfr": "-0.00025",
  "tkfr": "0.00075",
  "tif": "gtc",
  "refu": 0,
  "is_reduce_only": false,
  "is_close": false,
  "is_liq": false,
  "text": "t-my-custom-id",
  "status": "finished",
  "finish_time": 1514764900,
  "finish_as": "cancelled"
}

Responses

Status Meaning Description Schema
201 Created Order details FuturesOrder

List futures orders

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/orders'
query_param = 'contract=BTC_USD&status=open'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/orders"
query_param="contract=BTC_USD&status=open"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/orders

List futures orders

Zero-fill order cannot be retrieved 60 seconds after cancellation

Parameters

Name In Type Required Description
contract query string true Futures contract
status query string true List orders based on status
limit query integer false Maximum number of records returned in one list
offset query integer false List offset, starting from 0
last_id query string false Specify list staring point using the id of last record in previous list-query results
count_total query integer false Whether to return total number matched. Default to 0(no return)
settle path string true Settle currency

Enumerated Values

Parameter Value
status open
status finished
count_total 0
count_total 1
settle btc
settle usdt

Example responses

200 Response

[
  {
    "id": 15675394,
    "user": 100000,
    "contract": "BTC_USD",
    "create_time": 1546569968,
    "size": 6024,
    "iceberg": 0,
    "left": 6024,
    "price": "3765",
    "fill_price": "0",
    "mkfr": "-0.00025",
    "tkfr": "0.00075",
    "tif": "gtc",
    "refu": 0,
    "is_reduce_only": false,
    "is_close": false,
    "is_liq": false,
    "text": "t-my-custom-id",
    "status": "finished",
    "finish_time": 1514764900,
    "finish_as": "cancelled"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [FuturesOrder]

Response Headers

Status Header Type Format Description
200 X-Pagination-Limit integer Request limit specified
200 X-Pagination-Offset integer Request offset specified
200 X-Pagination-Total integer Total number matched. Only returned on count_total set to 1

Cancel all open orders matched

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/orders'
query_param = 'contract=BTC_USD'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/futures/btc/orders"
query_param="contract=BTC_USD"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /futures/{settle}/orders

Cancel all open orders matched

Zero-fill order cannot be retrieved 60 seconds after cancellation

Parameters

Name In Type Required Description
contract query string true Futures contract
side query string false All bids or asks. Both included in not specified
settle path string true Settle currency

Enumerated Values

Parameter Value
side ask
side bid
settle btc
settle usdt

Example responses

200 Response

[
  {
    "id": 15675394,
    "user": 100000,
    "contract": "BTC_USD",
    "create_time": 1546569968,
    "size": 6024,
    "iceberg": 0,
    "left": 6024,
    "price": "3765",
    "fill_price": "0",
    "mkfr": "-0.00025",
    "tkfr": "0.00075",
    "tif": "gtc",
    "refu": 0,
    "is_reduce_only": false,
    "is_close": false,
    "is_liq": false,
    "text": "t-my-custom-id",
    "status": "finished",
    "finish_time": 1514764900,
    "finish_as": "cancelled"
  }
]

Responses

Status Meaning Description Schema
200 OK All orders matched cancelled [FuturesOrder]

Get a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/orders/12345'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/orders/12345"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/orders/{order_id}

Get a single order

Zero-fill order cannot be retrieved 60 seconds after cancellation

Parameters

Name In Type Required Description
settle path string true Settle currency
order_id path string true ID returned on order successfully being created

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "id": 15675394,
  "user": 100000,
  "contract": "BTC_USD",
  "create_time": 1546569968,
  "size": 6024,
  "iceberg": 0,
  "left": 6024,
  "price": "3765",
  "fill_price": "0",
  "mkfr": "-0.00025",
  "tkfr": "0.00075",
  "tif": "gtc",
  "refu": 0,
  "is_reduce_only": false,
  "is_close": false,
  "is_liq": false,
  "text": "t-my-custom-id",
  "status": "finished",
  "finish_time": 1514764900,
  "finish_as": "cancelled"
}

Responses

Status Meaning Description Schema
200 OK Order details FuturesOrder

Cancel a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/orders/12345'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/futures/btc/orders/12345"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /futures/{settle}/orders/{order_id}

Cancel a single order

Parameters

Name In Type Required Description
settle path string true Settle currency
order_id path string true ID returned on order successfully being created

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "id": 15675394,
  "user": 100000,
  "contract": "BTC_USD",
  "create_time": 1546569968,
  "size": 6024,
  "iceberg": 0,
  "left": 6024,
  "price": "3765",
  "fill_price": "0",
  "mkfr": "-0.00025",
  "tkfr": "0.00075",
  "tif": "gtc",
  "refu": 0,
  "is_reduce_only": false,
  "is_close": false,
  "is_liq": false,
  "text": "t-my-custom-id",
  "status": "finished",
  "finish_time": 1514764900,
  "finish_as": "cancelled"
}

Responses

Status Meaning Description Schema
200 OK Order details FuturesOrder

List personal trading history

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/my_trades'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/my_trades"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/my_trades

List personal trading history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string false Futures contract, return related data only if specified
order query integer false Futures order ID, return related data only if specified
limit query integer false Maximum number of records returned in one list
offset query integer false List offset, starting from 0
last_id query string false Specify list staring point using the id of last record in previous list-query results
count_total query integer false Whether to return total number matched. Default to 0(no return)

Enumerated Values

Parameter Value
settle btc
settle usdt
count_total 0
count_total 1

Example responses

200 Response

[
  {
    "id": 121234231,
    "create_time": 1514764800,
    "contract": "BTC_USD",
    "order_id": "21893289839",
    "size": 100,
    "price": "100.123",
    "role": "taker"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» id integer(int64) Trade ID
» create_time number Trading time
» contract string Futures contract
» order_id string Order ID related
» size integer(int64) Trading size
» price string Trading price
» role string Trade role. Available values are taker and maker

Enumerated Values

Property Value
role taker
role maker

Response Headers

Status Header Type Format Description
200 X-Pagination-Limit integer Request limit specified
200 X-Pagination-Offset integer Request offset specified
200 X-Pagination-Total integer Total number matched. Only returned on count_total set to 1

List position close history

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/position_close'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/position_close"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/position_close

List position close history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string false Futures contract, return related data only if specified
limit query integer false Maximum number of records returned in one list

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

[
  {
    "time": 1546487347,
    "pnl": "0.00013",
    "side": "long",
    "contract": "BTC_USD",
    "text": "web"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» time number Position close time
» contract string Futures contract
» side string Position side, long or short
» pnl string PNL
» text string Text of close order

Enumerated Values

Property Value
side long
side short

List liquidation history

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/liquidates'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/liquidates"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/liquidates

List liquidation history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string false Futures contract, return related data only if specified
limit query integer false Maximum number of records returned in one list
at query integer false Specify a liquidation timestamp

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

[
  {
    "time": 1548654951,
    "contract": "BTC_USD",
    "size": 600,
    "leverage": "25",
    "margin": "0.006705256878",
    "entry_price": "3536.123",
    "liq_price": "3421.54",
    "mark_price": "3420.27",
    "order_id": 317393847,
    "order_price": "3405",
    "fill_price": "3424",
    "left": 0
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» time integer(int64) Liquidation time
» contract string Futures contract
» leverage string Position leverage
» size integer(int64) Position size
» margin string Position margin
» entry_price string Average entry price
» liq_price string Liquidation price
» mark_price string Mark price
» order_id integer(int64) Liquidation order ID
» order_price string Liquidation order price
» fill_price string Liquidation order average taker price
» left integer(int64) Liquidation order maker size

Create a price-triggered order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/price_orders'
query_param = ''
body='{"initial":{"contract":"BTC_USD","size":100,"price":"5.03","close":false,"tif":"gtc","text":"web"},"trigger":{"strategy_type":0,"price_type":0,"price":"3000","rule":1,"expiration":86400}}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/futures/btc/price_orders"
query_param=""
body_param='{"initial":{"contract":"BTC_USD","size":100,"price":"5.03","close":false,"tif":"gtc","text":"web"},"trigger":{"strategy_type":0,"price_type":0,"price":"3000","rule":1,"expiration":86400}}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /futures/{settle}/price_orders

Create a price-triggered order

Body parameter

{
  "initial": {
    "contract": "BTC_USD",
    "size": 100,
    "price": "5.03",
    "close": false,
    "tif": "gtc",
    "text": "web"
  },
  "trigger": {
    "strategy_type": 0,
    "price_type": 0,
    "price": "3000",
    "rule": 1,
    "expiration": 86400
  }
}

Parameters

Name In Type Required Description
body body FuturesPriceTriggeredOrder true none
» initial body object true none
»» contract body string true Futures contract
»» size body integer(int64) false Order size. Positive size means to buy, while negative one means to sell. Set to 0 to close the position
»» price body string true Order price. Set to 0 to use market price
»» close body boolean false Set to true if trying to close the position
»» tif body string false Time in force. If using market price, only ioc is supported.
»» text body string false How the order is created. Possible values are: web, api and app
»» reduce_only body boolean false Set to true to create an reduce-only order
» trigger body object true none
»» strategy_type body integer false How the order will be triggered
»» price_type body integer false Price type. 0 - latest deal price, 1 - mark price, 2 - index price
»» price body string false Value of price on price triggered, or price gap on price gap triggered
»» rule body integer false Trigger condition type
»» expiration body integer false How many seconds will the order wait for the condition being triggered. Order will be cancelled on timed out
settle path string true Settle currency

Detailed descriptions

»» tif: Time in force. If using market price, only ioc is supported.

»» strategy_type: How the order will be triggered

»» rule: Trigger condition type

Enumerated Values

Parameter Value
»» tif gtc
»» tif ioc
»» strategy_type 0
»» strategy_type 1
»» price_type 0
»» price_type 1
»» price_type 2
»» rule 1
»» rule 2
settle btc
settle usdt

Example responses

201 Response

{
  "id": 1432329
}

Responses

Status Meaning Description Schema
201 Created Order created Inline

Response Schema

Status Code 201

TriggerOrderResponse

Name Type Description
» id integer(int64) Auto order ID

List all auto orders

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/price_orders'
query_param = 'status=open'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/price_orders"
query_param="status=open"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/price_orders

List all auto orders

Parameters

Name In Type Required Description
status query string true List orders based on status
contract query string false Futures contract, return related data only if specified
limit query integer false Maximum number of records returned in one list
offset query integer false List offset, starting from 0
settle path string true Settle currency

Enumerated Values

Parameter Value
status open
status finished
settle btc
settle usdt

Example responses

200 Response

[
  {
    "initial": {
      "contract": "BTC_USD",
      "size": 100,
      "price": "5.03",
      "tif": "gtc",
      "text": "web"
    },
    "trigger": {
      "strategy_type": 0,
      "price_type": 0,
      "price": "3000",
      "rule": 1,
      "expiration": 86400
    },
    "id": 1283293,
    "user": 1234,
    "create_time": 1514764800,
    "finish_time": 1514764900,
    "trade_id": 13566,
    "status": "finished",
    "finish_as": "cancelled",
    "reason": ""
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [FuturesPriceTriggeredOrder]

Cancel all open orders

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/price_orders'
query_param = 'contract=BTC_USD'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/futures/btc/price_orders"
query_param="contract=BTC_USD"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /futures/{settle}/price_orders

Cancel all open orders

Parameters

Name In Type Required Description
contract query string true Futures contract
settle path string true Settle currency

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

[
  {
    "initial": {
      "contract": "BTC_USD",
      "size": 100,
      "price": "5.03",
      "tif": "gtc",
      "text": "web"
    },
    "trigger": {
      "strategy_type": 0,
      "price_type": 0,
      "price": "3000",
      "rule": 1,
      "expiration": 86400
    },
    "id": 1283293,
    "user": 1234,
    "create_time": 1514764800,
    "finish_time": 1514764900,
    "trade_id": 13566,
    "status": "finished",
    "finish_as": "cancelled",
    "reason": ""
  }
]

Responses

Status Meaning Description Schema
200 OK Batch cancellation request accepted. Query order status by listing orders [FuturesPriceTriggeredOrder]

Get a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/price_orders/string'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/futures/btc/price_orders/string"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /futures/{settle}/price_orders/{order_id}

Get a single order

Parameters

Name In Type Required Description
settle path string true Settle currency
order_id path string true ID returned on order successfully being created

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "initial": {
    "contract": "BTC_USD",
    "size": 100,
    "price": "5.03",
    "tif": "gtc",
    "text": "web"
  },
  "trigger": {
    "strategy_type": 0,
    "price_type": 0,
    "price": "3000",
    "rule": 1,
    "expiration": 86400
  },
  "id": 1283293,
  "user": 1234,
  "create_time": 1514764800,
  "finish_time": 1514764900,
  "trade_id": 13566,
  "status": "finished",
  "finish_as": "cancelled",
  "reason": ""
}

Responses

Status Meaning Description Schema
200 OK Auto order detail FuturesPriceTriggeredOrder

Cancel a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/futures/btc/price_orders/string'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/futures/btc/price_orders/string"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /futures/{settle}/price_orders/{order_id}

Cancel a single order

Parameters

Name In Type Required Description
settle path string true Settle currency
order_id path string true ID returned on order successfully being created

Enumerated Values

Parameter Value
settle btc
settle usdt

Example responses

200 Response

{
  "initial": {
    "contract": "BTC_USD",
    "size": 100,
    "price": "5.03",
    "tif": "gtc",
    "text": "web"
  },
  "trigger": {
    "strategy_type": 0,
    "price_type": 0,
    "price": "3000",
    "rule": 1,
    "expiration": 86400
  },
  "id": 1283293,
  "user": 1234,
  "create_time": 1514764800,
  "finish_time": 1514764900,
  "trade_id": 13566,
  "status": "finished",
  "finish_as": "cancelled",
  "reason": ""
}

Responses

Status Meaning Description Schema
200 OK Auto order detail FuturesPriceTriggeredOrder

Delivery

Delivery contract

List all futures contracts

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/contracts'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/delivery/usdt/contracts \
  -H 'Accept: application/json'

GET /delivery/{settle}/contracts

List all futures contracts

Parameters

Name In Type Required Description
settle path string true Settle currency

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

[
  {
    "name": "BTC_USDT_WEEKLY_20200703",
    "underlying": "BTC_USDT",
    "cycle": "WEEKLY",
    "type": "direct",
    "quanto_multiplier": "0.0001",
    "mark_type": "index",
    "last_price": "9017",
    "mark_price": "9019",
    "index_price": "9005.3",
    "basis_rate": "0.185095",
    "basis_value": "13.7",
    "basis_impact_value": "100000",
    "settle_price": "0",
    "settle_price_interval": 60,
    "settle_price_duration": 1800,
    "settle_fee_rate": "0.0015",
    "expire_time": 1593763200,
    "order_price_round": "0.1",
    "mark_price_round": "0.1",
    "leverage_min": "1",
    "leverage_max": "100",
    "maintenance_rate": "1000000",
    "risk_limit_base": "140.726652109199",
    "risk_limit_step": "1000000",
    "risk_limit_max": "8000000",
    "maker_fee_rate": "-0.00025",
    "taker_fee_rate": "0.00075",
    "ref_discount_rate": "0",
    "ref_rebate_rate": "0.2",
    "order_price_deviate": "0.5",
    "order_size_min": 1,
    "order_size_max": 1000000,
    "orders_limit": 50,
    "orderbook_id": 63,
    "trade_id": 26,
    "trade_size": 435,
    "position_size": 130,
    "config_change_time": 1593158867,
    "in_delisting": false
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [DeliveryContract]

Get a single contract

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/contracts/BTC_USDT_WEEKLY_20200703'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/delivery/usdt/contracts/BTC_USDT_WEEKLY_20200703 \
  -H 'Accept: application/json'

GET /delivery/{settle}/contracts/{contract}

Get a single contract

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "name": "BTC_USDT_WEEKLY_20200703",
  "underlying": "BTC_USDT",
  "cycle": "WEEKLY",
  "type": "direct",
  "quanto_multiplier": "0.0001",
  "mark_type": "index",
  "last_price": "9017",
  "mark_price": "9019",
  "index_price": "9005.3",
  "basis_rate": "0.185095",
  "basis_value": "13.7",
  "basis_impact_value": "100000",
  "settle_price": "0",
  "settle_price_interval": 60,
  "settle_price_duration": 1800,
  "settle_fee_rate": "0.0015",
  "expire_time": 1593763200,
  "order_price_round": "0.1",
  "mark_price_round": "0.1",
  "leverage_min": "1",
  "leverage_max": "100",
  "maintenance_rate": "1000000",
  "risk_limit_base": "140.726652109199",
  "risk_limit_step": "1000000",
  "risk_limit_max": "8000000",
  "maker_fee_rate": "-0.00025",
  "taker_fee_rate": "0.00075",
  "ref_discount_rate": "0",
  "ref_rebate_rate": "0.2",
  "order_price_deviate": "0.5",
  "order_size_min": 1,
  "order_size_max": 1000000,
  "orders_limit": 50,
  "orderbook_id": 63,
  "trade_id": 26,
  "trade_size": 435,
  "position_size": 130,
  "config_change_time": 1593158867,
  "in_delisting": false
}

Responses

Status Meaning Description Schema
200 OK Contract information DeliveryContract

Futures order book

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/order_book'
query_param = 'contract=BTC_USDT_WEEKLY_20200703'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/delivery/usdt/order_book?contract=BTC_USDT_WEEKLY_20200703 \
  -H 'Accept: application/json'

GET /delivery/{settle}/order_book

Futures order book

Bids will be sorted by price from high to low, while asks sorted reversely

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string true Futures contract
interval query string false Order depth. 0 means no aggregation is applied. default to 0
limit query integer false Maximum number of order depth data in asks or bids

Enumerated Values

Parameter Value
settle usdt
interval 0
interval 0.1
interval 0.01

Example responses

200 Response

{
  "asks": [
    {
      "p": "1.52",
      "s": 100
    },
    {
      "p": "1.53",
      "s": 40
    }
  ],
  "bids": [
    {
      "p": "1.17",
      "s": 150
    },
    {
      "p": "1.16",
      "s": 203
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK Order book retrieved Inline

Response Schema

Status Code 200

Name Type Description
» asks array Asks order depth
»» futures_order_book_item object none
»»» p string Price
»»» s integer(int64) Size
»» bids array Bids order depth
»»» futures_order_book_item object none
»»»» p string Price
»»»» s integer(int64) Size

Futures trading history

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/trades'
query_param = 'contract=BTC_USDT_WEEKLY_20200703'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/delivery/usdt/trades?contract=BTC_USDT_WEEKLY_20200703 \
  -H 'Accept: application/json'

GET /delivery/{settle}/trades

Futures trading history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string true Futures contract
limit query integer false Maximum number of records returned in one list
last_id query string false Specify list staring point using the id of last record in previous list-query results
from query number false Specify starting time in Unix seconds. If not specified, to and limit will be used to limit response items.
to query number false Specify end time in Unix seconds, default to current time

Detailed descriptions

last_id: Specify list staring point using the id of last record in previous list-query results

This parameter is deprecated. Use from and to instead to limit time range

from: Specify starting time in Unix seconds. If not specified, to and limit will be used to limit response items. If items between from and to are more than limit, only limit number will be returned.

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

[
  {
    "id": 121234231,
    "create_time": 1514764800,
    "contract": "BTC_USD",
    "size": -100,
    "price": "100.123"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» id integer(int64) Trade ID
» create_time number Trading time
» contract string Futures contract
» size integer(int64) Trading size
» price string Trading price

Get futures candlesticks

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/candlesticks'
query_param = 'contract=BTC_USDT_WEEKLY_20200703'
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/delivery/usdt/candlesticks?contract=BTC_USDT_WEEKLY_20200703 \
  -H 'Accept: application/json'

GET /delivery/{settle}/candlesticks

Get futures candlesticks

Return specified contract candlesticks. If prefix contract with mark_, the contract's mark price candlesticks are returned; if prefix with index_, index price candlesticks will be returned.

Maximum of 2000 points are returned in one query. Be sure not to exceed the limit when specifying from, to and interval

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string true Futures contract
from query number false Start time of candlesticks, formatted in Unix timestamp in seconds.
to query number false End time of candlesticks, formatted in Unix timestamp in seconds. Default to current time
limit query integer false Maximum recent data points returned. limit is conflicted with from and to. If either from or to is specified, request will be rejected.
interval query string false Interval time between data points

Detailed descriptions

from: Start time of candlesticks, formatted in Unix timestamp in seconds. Default toto - 100 * interval if not specified

Enumerated Values

Parameter Value
settle usdt
interval 10s
interval 1m
interval 5m
interval 15m
interval 30m
interval 1h
interval 4h
interval 8h
interval 1d
interval 7d

Example responses

200 Response

[
  {
    "t": 1539852480,
    "v": 97151,
    "c": "1.032",
    "h": "1.032",
    "l": "1.032",
    "o": "1.032"
  }
]

Responses

Status Meaning Description Schema
200 OK Successfully retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array [data point in every timestamp]
» None object data point in every timestamp
»» t number Unix timestamp in seconds
»» v integer(int64) size volume. Only returned if contract is not prefixed
»» c string Close price
»» h string Highest price
»» l string Lowest price
»» o string Open price

List futures tickers

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/tickers'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/delivery/usdt/tickers \
  -H 'Accept: application/json'

GET /delivery/{settle}/tickers

List futures tickers

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string false Futures contract

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

[
  {
    "contract": "BTC_USD",
    "last": "6432",
    "low_24h": "6278",
    "high_24h": "6790",
    "change_percentage": "4.43",
    "total_size": "32323904",
    "volume_24h": "184040233284",
    "volume_24h_btc": "28613220",
    "volume_24h_usd": "184040233284",
    "volume_24h_base": "28613220",
    "volume_24h_quote": "184040233284",
    "volume_24h_settle": "28613220",
    "mark_price": "6534",
    "funding_rate": "0.0001",
    "funding_rate_indicative": "0.0001",
    "index_price": "6531"
  }
]

Responses

Status Meaning Description Schema
200 OK Successfully retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» contract string Futures contract
» last string Last trading price
» change_percentage string Change percentage.
» total_size string Contract total size
» low_24h string Lowest trading price in recent 24h
» high_24h string Highest trading price in recent 24h
» volume_24h string Trade size in recent 24h
» volume_24h_btc string Trade volumes in recent 24h in BTC(deprecated, use volume_24h_base, volume_24h_quote, volume_24h_settle instead)
» volume_24h_usd string Trade volumes in recent 24h in USD(deprecated, use volume_24h_base, volume_24h_quote, volume_24h_settle instead)
» volume_24h_base string Trade volume in recent 24h, in base currency
» volume_24h_quote string Trade volume in recent 24h, in quote currency
» volume_24h_settle string Trade volume in recent 24h, in settle currency
» mark_price string Recent mark price
» funding_rate string Funding rate
» funding_rate_indicative string Indicative Funding rate in next period
» index_price string Index price
» quanto_base_rate string Exchange rate of base currency and settlement currency in Quanto contract. Not existed in contract of other types

Futures insurance balance history

Code samples

# coding: utf-8
import requests

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/insurance'
query_param = ''
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())


curl -X GET https://api.gateio.ws/api/v4/delivery/usdt/insurance \
  -H 'Accept: application/json'

GET /delivery/{settle}/insurance

Futures insurance balance history

Parameters

Name In Type Required Description
settle path string true Settle currency
limit query integer false Maximum number of records returned in one list

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

[
  {
    "t": 1543968000,
    "b": "83.0031"
  }
]

Responses

Status Meaning Description Schema
200 OK Successfully retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» t integer(int64) Unix timestamp in seconds
» b string Insurance balance

Query futures account

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/accounts'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/accounts"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/accounts

Query futures account

Parameters

Name In Type Required Description
settle path string true Settle currency

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "total": "4.4516",
  "unrealised_pnl": "0",
  "available": "4.98",
  "order_margin": "0.1",
  "position_margin": "5.1",
  "point": "10000",
  "currency": "BTC"
}

Responses

Status Meaning Description Schema
200 OK List retrieved Inline

Response Schema

Status Code 200

Name Type Description
» total string Total assets, total = position_margin + order_margin + available
» unrealised_pnl string Unrealized PNL
» position_margin string Position margin
» order_margin string Order margin of unfinished orders
» available string Available balance to transfer out or trade
» point string POINT amount
» currency string Settle currency

Query account book

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/account_book'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/account_book"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/account_book

Query account book

Parameters

Name In Type Required Description
settle path string true Settle currency
limit query integer false Maximum number of records returned in one list
from query integer(int64) false Start timestamp
to query integer(int64) false End timestamp
type query string false Changing Type:

Detailed descriptions

type: Changing Type: - dnw: Deposit & Withdraw - pnl: Profit & Loss by reducing position - fee: Trading fee - refr: Referrer rebate - fund: Funding - point_dnw: POINT Deposit & Withdraw - point_fee: POINT Trading fee - point_refr: POINT Referrer rebate

Enumerated Values

Parameter Value
settle usdt
type dnw
type pnl
type fee
type refr
type fund
type point_dnw
type point_fee
type point_refr

Example responses

200 Response

[
  {
    "time": 1547633726,
    "change": "0.000010152188",
    "balance": "4.59316525194",
    "text": "ETH_USD:6086261",
    "type": "fee"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» time number Change time
» change string Change amount
» balance string Balance after change
» type string Changing Type:
- dnw: Deposit & Withdraw
- pnl: Profit & Loss by reducing position
- fee: Trading fee
- refr: Referrer rebate
- fund: Funding
- point_dnw: POINT Deposit & Withdraw
- point_fee: POINT Trading fee
- point_refr: POINT Referrer rebate
» text string Comment

Enumerated Values

Property Value
type dnw
type pnl
type fee
type refr
type fund
type point_dnw
type point_fee
type point_refr

List all positions of a user

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/positions'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/positions"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/positions

List all positions of a user

Parameters

Name In Type Required Description
settle path string true Settle currency

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

[
  {
    "user": 10000,
    "contract": "BTC_USD",
    "size": -9440,
    "leverage": "0",
    "risk_limit": "100",
    "leverage_max": "100",
    "maintenance_rate": "0.005",
    "value": "2.497143098997",
    "margin": "4.431548146258",
    "entry_price": "3779.55",
    "liq_price": "99999999",
    "mark_price": "3780.32",
    "unrealised_pnl": "-0.000507486844",
    "realised_pnl": "0.045543982432",
    "history_pnl": "0",
    "last_close_pnl": "0",
    "realised_point": "0",
    "history_point": "0",
    "adl_ranking": 5,
    "pending_orders": 16,
    "close_order": {
      "id": 232323,
      "price": "3779",
      "is_liq": false
    }
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Position]

Get single position

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/positions/BTC_USDT_WEEKLY_20200703'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/positions/BTC_USDT_WEEKLY_20200703"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/positions/{contract}

Get single position

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "user": 10000,
  "contract": "BTC_USD",
  "size": -9440,
  "leverage": "0",
  "risk_limit": "100",
  "leverage_max": "100",
  "maintenance_rate": "0.005",
  "value": "2.497143098997",
  "margin": "4.431548146258",
  "entry_price": "3779.55",
  "liq_price": "99999999",
  "mark_price": "3780.32",
  "unrealised_pnl": "-0.000507486844",
  "realised_pnl": "0.045543982432",
  "history_pnl": "0",
  "last_close_pnl": "0",
  "realised_point": "0",
  "history_point": "0",
  "adl_ranking": 5,
  "pending_orders": 16,
  "close_order": {
    "id": 232323,
    "price": "3779",
    "is_liq": false
  }
}

Responses

Status Meaning Description Schema
200 OK Position information Position

Update position margin

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/positions/BTC_USDT_WEEKLY_20200703/margin'
query_param = 'change=0.01'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/delivery/usdt/positions/BTC_USDT_WEEKLY_20200703/margin"
query_param="change=0.01"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /delivery/{settle}/positions/{contract}/margin

Update position margin

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract
change query string true Margin change. Use positive number to increase margin, negative number otherwise.

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "user": 10000,
  "contract": "BTC_USD",
  "size": -9440,
  "leverage": "0",
  "risk_limit": "100",
  "leverage_max": "100",
  "maintenance_rate": "0.005",
  "value": "2.497143098997",
  "margin": "4.431548146258",
  "entry_price": "3779.55",
  "liq_price": "99999999",
  "mark_price": "3780.32",
  "unrealised_pnl": "-0.000507486844",
  "realised_pnl": "0.045543982432",
  "history_pnl": "0",
  "last_close_pnl": "0",
  "realised_point": "0",
  "history_point": "0",
  "adl_ranking": 5,
  "pending_orders": 16,
  "close_order": {
    "id": 232323,
    "price": "3779",
    "is_liq": false
  }
}

Responses

Status Meaning Description Schema
200 OK Position information Position

Update position leverage

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/positions/BTC_USDT_WEEKLY_20200703/leverage'
query_param = 'leverage=10'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/delivery/usdt/positions/BTC_USDT_WEEKLY_20200703/leverage"
query_param="leverage=10"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /delivery/{settle}/positions/{contract}/leverage

Update position leverage

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract
leverage query string true New position leverage

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "user": 10000,
  "contract": "BTC_USD",
  "size": -9440,
  "leverage": "0",
  "risk_limit": "100",
  "leverage_max": "100",
  "maintenance_rate": "0.005",
  "value": "2.497143098997",
  "margin": "4.431548146258",
  "entry_price": "3779.55",
  "liq_price": "99999999",
  "mark_price": "3780.32",
  "unrealised_pnl": "-0.000507486844",
  "realised_pnl": "0.045543982432",
  "history_pnl": "0",
  "last_close_pnl": "0",
  "realised_point": "0",
  "history_point": "0",
  "adl_ranking": 5,
  "pending_orders": 16,
  "close_order": {
    "id": 232323,
    "price": "3779",
    "is_liq": false
  }
}

Responses

Status Meaning Description Schema
200 OK Position information Position

Update position risk limit

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/positions/BTC_USDT_WEEKLY_20200703/risk_limit'
query_param = 'risk_limit=10'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/delivery/usdt/positions/BTC_USDT_WEEKLY_20200703/risk_limit"
query_param="risk_limit=10"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /delivery/{settle}/positions/{contract}/risk_limit

Update position risk limit

Parameters

Name In Type Required Description
settle path string true Settle currency
contract path string true Futures contract
risk_limit query string true New position risk limit

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "user": 10000,
  "contract": "BTC_USD",
  "size": -9440,
  "leverage": "0",
  "risk_limit": "100",
  "leverage_max": "100",
  "maintenance_rate": "0.005",
  "value": "2.497143098997",
  "margin": "4.431548146258",
  "entry_price": "3779.55",
  "liq_price": "99999999",
  "mark_price": "3780.32",
  "unrealised_pnl": "-0.000507486844",
  "realised_pnl": "0.045543982432",
  "history_pnl": "0",
  "last_close_pnl": "0",
  "realised_point": "0",
  "history_point": "0",
  "adl_ranking": 5,
  "pending_orders": 16,
  "close_order": {
    "id": 232323,
    "price": "3779",
    "is_liq": false
  }
}

Responses

Status Meaning Description Schema
200 OK Position information Position

Create a futures order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/orders'
query_param = ''
body='{"contract":"BTC_USD","size":6024,"iceberg":0,"price":"3765","tif":"gtc","text":"t-my-custom-id"}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/delivery/usdt/orders"
query_param=""
body_param='{"contract":"BTC_USD","size":6024,"iceberg":0,"price":"3765","tif":"gtc","text":"t-my-custom-id"}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /delivery/{settle}/orders

Create a futures order

Zero-fill order cannot be retrieved 60 seconds after cancellation

Body parameter

{
  "contract": "BTC_USD",
  "size": 6024,
  "iceberg": 0,
  "price": "3765",
  "tif": "gtc",
  "text": "t-my-custom-id"
}

Parameters

Name In Type Required Description
body body FuturesOrder true none
» contract body string true Futures contract
» size body integer(int64) false Order size. Specify positive number to make a bid, and negative number to ask
» iceberg body integer(int64) false Display size for iceberg order. 0 for non-iceberg. Note that you would pay the taker fee for the hidden size
» price body string false Order price. 0 for market order with tif set as ioc
» close body boolean false Set as true to close the position, with size set to 0
» reduce_only body boolean false Set as true to be reduce-only order
» tif body string false Time in force
» text body string false User defined information. If not empty, must follow the rules below:
settle path string true Settle currency

Detailed descriptions

» tif: Time in force

» text: User defined information. If not empty, must follow the rules below:

  1. prefixed with t-
  2. no longer than 28 bytes without t- prefix
  3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.) Besides user defined information, reserved contents are listed below, denoting how the order is created:

Enumerated Values

Parameter Value
» tif gtc
» tif ioc
» tif poc
settle usdt

Example responses

201 Response

{
  "id": 15675394,
  "user": 100000,
  "contract": "BTC_USD",
  "create_time": 1546569968,
  "size": 6024,
  "iceberg": 0,
  "left": 6024,
  "price": "3765",
  "fill_price": "0",
  "mkfr": "-0.00025",
  "tkfr": "0.00075",
  "tif": "gtc",
  "refu": 0,
  "is_reduce_only": false,
  "is_close": false,
  "is_liq": false,
  "text": "t-my-custom-id",
  "status": "finished",
  "finish_time": 1514764900,
  "finish_as": "cancelled"
}

Responses

Status Meaning Description Schema
201 Created Order details FuturesOrder

List futures orders

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/orders'
query_param = 'status=open'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/orders"
query_param="status=open"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/orders

List futures orders

Zero-fill order cannot be retrieved 60 seconds after cancellation

Parameters

Name In Type Required Description
contract query string false Futures contract
status query string true List orders based on status
limit query integer false Maximum number of records returned in one list
offset query integer false List offset, starting from 0
last_id query string false Specify list staring point using the id of last record in previous list-query results
count_total query integer false Whether to return total number matched. Default to 0(no return)
settle path string true Settle currency

Enumerated Values

Parameter Value
status open
status finished
count_total 0
count_total 1
settle usdt

Example responses

200 Response

[
  {
    "id": 15675394,
    "user": 100000,
    "contract": "BTC_USD",
    "create_time": 1546569968,
    "size": 6024,
    "iceberg": 0,
    "left": 6024,
    "price": "3765",
    "fill_price": "0",
    "mkfr": "-0.00025",
    "tkfr": "0.00075",
    "tif": "gtc",
    "refu": 0,
    "is_reduce_only": false,
    "is_close": false,
    "is_liq": false,
    "text": "t-my-custom-id",
    "status": "finished",
    "finish_time": 1514764900,
    "finish_as": "cancelled"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [FuturesOrder]

Response Headers

Status Header Type Format Description
200 X-Pagination-Limit integer Request limit specified
200 X-Pagination-Offset integer Request offset specified
200 X-Pagination-Total integer Total number matched. Only returned on count_total set to 1

Cancel all open orders matched

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/orders'
query_param = 'contract=BTC_USDT_WEEKLY_20200703'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/delivery/usdt/orders"
query_param="contract=BTC_USDT_WEEKLY_20200703"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /delivery/{settle}/orders

Cancel all open orders matched

Zero-fill order cannot be retrieved 60 seconds after cancellation

Parameters

Name In Type Required Description
contract query string true Futures contract
side query string false All bids or asks. Both included in not specified
settle path string true Settle currency

Enumerated Values

Parameter Value
side ask
side bid
settle usdt

Example responses

200 Response

[
  {
    "id": 15675394,
    "user": 100000,
    "contract": "BTC_USD",
    "create_time": 1546569968,
    "size": 6024,
    "iceberg": 0,
    "left": 6024,
    "price": "3765",
    "fill_price": "0",
    "mkfr": "-0.00025",
    "tkfr": "0.00075",
    "tif": "gtc",
    "refu": 0,
    "is_reduce_only": false,
    "is_close": false,
    "is_liq": false,
    "text": "t-my-custom-id",
    "status": "finished",
    "finish_time": 1514764900,
    "finish_as": "cancelled"
  }
]

Responses

Status Meaning Description Schema
200 OK All orders matched cancelled [FuturesOrder]

Get a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/orders/12345'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/orders/12345"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/orders/{order_id}

Get a single order

Zero-fill order cannot be retrieved 60 seconds after cancellation

Parameters

Name In Type Required Description
settle path string true Settle currency
order_id path string true ID returned on order successfully being created

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "id": 15675394,
  "user": 100000,
  "contract": "BTC_USD",
  "create_time": 1546569968,
  "size": 6024,
  "iceberg": 0,
  "left": 6024,
  "price": "3765",
  "fill_price": "0",
  "mkfr": "-0.00025",
  "tkfr": "0.00075",
  "tif": "gtc",
  "refu": 0,
  "is_reduce_only": false,
  "is_close": false,
  "is_liq": false,
  "text": "t-my-custom-id",
  "status": "finished",
  "finish_time": 1514764900,
  "finish_as": "cancelled"
}

Responses

Status Meaning Description Schema
200 OK Order details FuturesOrder

Cancel a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/orders/12345'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/delivery/usdt/orders/12345"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /delivery/{settle}/orders/{order_id}

Cancel a single order

Parameters

Name In Type Required Description
settle path string true Settle currency
order_id path string true ID returned on order successfully being created

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "id": 15675394,
  "user": 100000,
  "contract": "BTC_USD",
  "create_time": 1546569968,
  "size": 6024,
  "iceberg": 0,
  "left": 6024,
  "price": "3765",
  "fill_price": "0",
  "mkfr": "-0.00025",
  "tkfr": "0.00075",
  "tif": "gtc",
  "refu": 0,
  "is_reduce_only": false,
  "is_close": false,
  "is_liq": false,
  "text": "t-my-custom-id",
  "status": "finished",
  "finish_time": 1514764900,
  "finish_as": "cancelled"
}

Responses

Status Meaning Description Schema
200 OK Order details FuturesOrder

List personal trading history

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/my_trades'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/my_trades"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/my_trades

List personal trading history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string false Futures contract
order query integer false Futures order ID, return related data only if specified
limit query integer false Maximum number of records returned in one list
offset query integer false List offset, starting from 0
last_id query string false Specify list staring point using the id of last record in previous list-query results
count_total query integer false Whether to return total number matched. Default to 0(no return)

Enumerated Values

Parameter Value
settle usdt
count_total 0
count_total 1

Example responses

200 Response

[
  {
    "id": 121234231,
    "create_time": 1514764800,
    "contract": "BTC_USD",
    "order_id": "21893289839",
    "size": 100,
    "price": "100.123",
    "role": "taker"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» id integer(int64) Trade ID
» create_time number Trading time
» contract string Futures contract
» order_id string Order ID related
» size integer(int64) Trading size
» price string Trading price
» role string Trade role. Available values are taker and maker

Enumerated Values

Property Value
role taker
role maker

Response Headers

Status Header Type Format Description
200 X-Pagination-Limit integer Request limit specified
200 X-Pagination-Offset integer Request offset specified
200 X-Pagination-Total integer Total number matched. Only returned on count_total set to 1

List position close history

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/position_close'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/position_close"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/position_close

List position close history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string false Futures contract
limit query integer false Maximum number of records returned in one list

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

[
  {
    "time": 1546487347,
    "pnl": "0.00013",
    "side": "long",
    "contract": "BTC_USD",
    "text": "web"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» time number Position close time
» contract string Futures contract
» side string Position side, long or short
» pnl string PNL
» text string Text of close order

Enumerated Values

Property Value
side long
side short

List liquidation history

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/liquidates'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/liquidates"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/liquidates

List liquidation history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string false Futures contract
limit query integer false Maximum number of records returned in one list
at query integer false Specify a liquidation timestamp

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

[
  {
    "time": 1548654951,
    "contract": "BTC_USD",
    "size": 600,
    "leverage": "25",
    "margin": "0.006705256878",
    "entry_price": "3536.123",
    "liq_price": "3421.54",
    "mark_price": "3420.27",
    "order_id": 317393847,
    "order_price": "3405",
    "fill_price": "3424",
    "left": 0
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
None array none
» time integer(int64) Liquidation time
» contract string Futures contract
» leverage string Position leverage
» size integer(int64) Position size
» margin string Position margin
» entry_price string Average entry price
» liq_price string Liquidation price
» mark_price string Mark price
» order_id integer(int64) Liquidation order ID
» order_price string Liquidation order price
» fill_price string Liquidation order average taker price
» left integer(int64) Liquidation order maker size

List settlement history

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/settlements'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/settlements"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/settlements

List settlement history

Parameters

Name In Type Required Description
settle path string true Settle currency
contract query string false Futures contract
limit query integer false Maximum number of records returned in one list
at query integer false Specify a settlement timestamp

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

[
  {
    "time": 1548654951,
    "contract": "BTC_USD",
    "size": 600,
    "leverage": "25",
    "margin": "0.006705256878",
    "entry_price": "3536.123",
    "settle_price": "3421.54",
    "profit": "-6.87498",
    "fee": "0.03079386"
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [Inline]

Response Schema

Status Code 200

Name Type Description
» time integer(int64) Liquidation time
» contract string Futures contract
» leverage string Position leverage
» size integer(int64) Position size
» margin string Position margin
» entry_price string Average entry price
» settle_price string Settled price
» profit string Profit
» fee string Fee deducted

Create a price-triggered order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/price_orders'
query_param = ''
body='{"initial":{"contract":"BTC_USD","size":100,"price":"5.03","close":false,"tif":"gtc","text":"web"},"trigger":{"strategy_type":0,"price_type":0,"price":"3000","rule":1,"expiration":86400}}'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('POST', prefix + url, query_param, body)
headers.update(sign_headers)
r = requests.request('POST', host + prefix + url, headers=headers, data=body)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="POST"
url="/delivery/usdt/price_orders"
query_param=""
body_param='{"initial":{"contract":"BTC_USD","size":100,"price":"5.03","close":false,"tif":"gtc","text":"web"},"trigger":{"strategy_type":0,"price_type":0,"price":"3000","rule":1,"expiration":86400}}'
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url -d "$body_param" -H "Content-Type: application/json" \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

POST /delivery/{settle}/price_orders

Create a price-triggered order

Body parameter

{
  "initial": {
    "contract": "BTC_USD",
    "size": 100,
    "price": "5.03",
    "close": false,
    "tif": "gtc",
    "text": "web"
  },
  "trigger": {
    "strategy_type": 0,
    "price_type": 0,
    "price": "3000",
    "rule": 1,
    "expiration": 86400
  }
}

Parameters

Name In Type Required Description
body body FuturesPriceTriggeredOrder true none
» initial body object true none
»» contract body string true Futures contract
»» size body integer(int64) false Order size. Positive size means to buy, while negative one means to sell. Set to 0 to close the position
»» price body string true Order price. Set to 0 to use market price
»» close body boolean false Set to true if trying to close the position
»» tif body string false Time in force. If using market price, only ioc is supported.
»» text body string false How the order is created. Possible values are: web, api and app
»» reduce_only body boolean false Set to true to create an reduce-only order
» trigger body object true none
»» strategy_type body integer false How the order will be triggered
»» price_type body integer false Price type. 0 - latest deal price, 1 - mark price, 2 - index price
»» price body string false Value of price on price triggered, or price gap on price gap triggered
»» rule body integer false Trigger condition type
»» expiration body integer false How many seconds will the order wait for the condition being triggered. Order will be cancelled on timed out
settle path string true Settle currency

Detailed descriptions

»» tif: Time in force. If using market price, only ioc is supported.

»» strategy_type: How the order will be triggered

»» rule: Trigger condition type

Enumerated Values

Parameter Value
»» tif gtc
»» tif ioc
»» strategy_type 0
»» strategy_type 1
»» price_type 0
»» price_type 1
»» price_type 2
»» rule 1
»» rule 2
settle usdt

Example responses

201 Response

{
  "id": 1432329
}

Responses

Status Meaning Description Schema
201 Created Order created Inline

Response Schema

Status Code 201

TriggerOrderResponse

Name Type Description
» id integer(int64) Auto order ID

List all auto orders

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/price_orders'
query_param = 'status=open'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/price_orders"
query_param="status=open"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/price_orders

List all auto orders

Parameters

Name In Type Required Description
status query string true List orders based on status
contract query string false Futures contract, return related data only if specified
limit query integer false Maximum number of records returned in one list
offset query integer false List offset, starting from 0
settle path string true Settle currency

Enumerated Values

Parameter Value
status open
status finished
settle usdt

Example responses

200 Response

[
  {
    "initial": {
      "contract": "BTC_USD",
      "size": 100,
      "price": "5.03",
      "tif": "gtc",
      "text": "web"
    },
    "trigger": {
      "strategy_type": 0,
      "price_type": 0,
      "price": "3000",
      "rule": 1,
      "expiration": 86400
    },
    "id": 1283293,
    "user": 1234,
    "create_time": 1514764800,
    "finish_time": 1514764900,
    "trade_id": 13566,
    "status": "finished",
    "finish_as": "cancelled",
    "reason": ""
  }
]

Responses

Status Meaning Description Schema
200 OK List retrieved [FuturesPriceTriggeredOrder]

Cancel all open orders

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/price_orders'
query_param = 'contract=BTC_USD'
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url + "?" + query_param, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/delivery/usdt/price_orders"
query_param="contract=BTC_USD"
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url?$query_param"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /delivery/{settle}/price_orders

Cancel all open orders

Parameters

Name In Type Required Description
contract query string true Futures contract
settle path string true Settle currency

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

[
  {
    "initial": {
      "contract": "BTC_USD",
      "size": 100,
      "price": "5.03",
      "tif": "gtc",
      "text": "web"
    },
    "trigger": {
      "strategy_type": 0,
      "price_type": 0,
      "price": "3000",
      "rule": 1,
      "expiration": 86400
    },
    "id": 1283293,
    "user": 1234,
    "create_time": 1514764800,
    "finish_time": 1514764900,
    "trade_id": 13566,
    "status": "finished",
    "finish_as": "cancelled",
    "reason": ""
  }
]

Responses

Status Meaning Description Schema
200 OK Batch cancellation request accepted. Query order status by listing orders [FuturesPriceTriggeredOrder]

Get a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/price_orders/string'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('GET', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('GET', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="GET"
url="/delivery/usdt/price_orders/string"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

GET /delivery/{settle}/price_orders/{order_id}

Get a single order

Parameters

Name In Type Required Description
settle path string true Settle currency
order_id path string true ID returned on order successfully being created

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "initial": {
    "contract": "BTC_USD",
    "size": 100,
    "price": "5.03",
    "tif": "gtc",
    "text": "web"
  },
  "trigger": {
    "strategy_type": 0,
    "price_type": 0,
    "price": "3000",
    "rule": 1,
    "expiration": 86400
  },
  "id": 1283293,
  "user": 1234,
  "create_time": 1514764800,
  "finish_time": 1514764900,
  "trade_id": 13566,
  "status": "finished",
  "finish_as": "cancelled",
  "reason": ""
}

Responses

Status Meaning Description Schema
200 OK Auto order detail FuturesPriceTriggeredOrder

Cancel a single order

Code samples

# coding: utf-8
import requests
import time
import hashlib
import hmac

host = "https://api.gateio.ws"
prefix = "/api/v4"
headers = {'Accept': 'application/json', 'Content-Type': 'application/json'}

url = '/delivery/usdt/price_orders/string'
query_param = ''
# for `gen_sign` implementation, refer to section `Authentication` above
sign_headers = gen_sign('DELETE', prefix + url, query_param)
headers.update(sign_headers)
r = requests.request('DELETE', host + prefix + url, headers=headers)
print(r.json())

key="YOUR_API_KEY"
secret="YOUR_API_SECRET"
host="https://api.gateio.ws"
prefix="/api/v4"
method="DELETE"
url="/delivery/usdt/price_orders/string"
query_param=""
body_param=''
timestamp=$(date +%s)
body_hash=$(printf $body_param | openssl sha512 | awk '{print $NF}')
sign_string="$method\n$prefix$url\n$query_param\n$body_hash\n$timestamp"
sign=$(printf $sign_string | openssl sha512 -hmac "$secret" | awk '{print $NF}')

full_url="$host$prefix$url"
curl -X $method $full_url \
    -H "Timestamp: $timestamp" -H "KEY: $key" -H "SIGN: $sign"

DELETE /delivery/{settle}/price_orders/{order_id}

Cancel a single order

Parameters

Name In Type Required Description
settle path string true Settle currency
order_id path string true ID returned on order successfully being created

Enumerated Values

Parameter Value
settle usdt

Example responses

200 Response

{
  "initial": {
    "contract": "BTC_USD",
    "size": 100,
    "price": "5.03",
    "tif": "gtc",
    "text": "web"
  },
  "trigger": {
    "strategy_type": 0,
    "price_type": 0,
    "price": "3000",
    "rule": 1,
    "expiration": 86400
  },
  "id": 1283293,
  "user": 1234,
  "create_time": 1514764800,
  "finish_time": 1514764900,
  "trade_id": 13566,
  "status": "finished",
  "finish_as": "cancelled",
  "reason": ""
}

Responses

Status Meaning Description Schema
200 OK Auto order detail FuturesPriceTriggeredOrder

Schemas

CurrencyPair

{
  "id": "string",
  "base": "string",
  "quote": "string",
  "fee": "string",
  "min_base_amount": "string",
  "min_quote_amount": "string",
  "amount_precision": 0,
  "precision": 0,
  "trade_status": "untradable"
}

Spot currency pair

Properties

Name Type Required Restrictions Description
id string false none Currency pair
base string false none Base currency
quote string false none Quote currency
fee string false none Trading fee
min_base_amount string false none Minimum amount of base currency to trade, null means no limit
min_quote_amount string false none Minimum amount of quote currency to trade, null means no limit
amount_precision integer false none Amount scale
precision integer false none Price scale
trade_status string false none How currency pair can be traded

- untradable: cannot be bought or sold
- buyable: can be bought
- sellable: can be sold
- tradable: can be bought or sold

Enumerated Values

Property Value
trade_status untradable
trade_status buyable
trade_status sellable
trade_status tradable

Order

{
  "id": "string",
  "text": "string",
  "create_time": "string",
  "update_time": "string",
  "status": "open",
  "currency_pair": "string",
  "type": "limit",
  "account": "spot",
  "side": "buy",
  "amount": "string",
  "price": "string",
  "time_in_force": "gtc",
  "auto_borrow": true,
  "left": "string",
  "fill_price": "string",
  "filled_total": "string",
  "fee": "string",
  "fee_currency": "string",
  "point_fee": "string",
  "gt_fee": "string",
  "gt_discount": true,
  "rebated_fee": "string",
  "rebated_fee_currency": "string"
}

Spot order details

Properties

Name Type Required Restrictions Description
id string false read-only Order ID
text string false none User defined information. If not empty, must follow the rules below:

1. prefixed with t-
2. no longer than 28 bytes without t- prefix
3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.)
create_time string false read-only Order creation time
update_time string false read-only Order last modification time
status string false read-only Order status

- open: to be filled
- closed: filled
- cancelled: cancelled
currency_pair string true none Currency pair
type string false none Order type. limit - limit order
account string false none Account type. spot - use spot account; margin - use margin account
side string true none Order side
amount string true none Trade amount
price string true none Order price
time_in_force string false none Time in force

- gtc: GoodTillCancelled
- ioc: ImmediateOrCancelled, taker only
- poc: PendingOrCancelled, makes a post-only order that always enjoys a maker fee
auto_borrow boolean false write-only Used in margin trading(i.e. account is margin) to allow automatic loan of insufficient part if balance is not enough.
left string false read-only Amount left to fill
fill_price string false read-only Total filled in quote currency. Deprecated in favor of filled_total
filled_total string false read-only Total filled in quote currency
fee string false read-only Fee deducted
fee_currency string false read-only Fee currency unit
point_fee string false read-only Point used to deduct fee
gt_fee string false read-only GT used to deduct fee
gt_discount boolean false read-only Whether GT fee discount is used
rebated_fee string false read-only Rebated fee
rebated_fee_currency string false read-only Rebated fee currency unit

Enumerated Values

Property Value
status open
status closed
status cancelled
type limit
account spot
account margin
side buy
side sell
time_in_force gtc
time_in_force ioc
time_in_force poc

Loan

{
  "id": "string",
  "create_time": "string",
  "expire_time": "string",
  "status": "open",
  "side": "lend",
  "currency": "string",
  "rate": "string",
  "amount": "string",
  "days": 0,
  "auto_renew": false,
  "currency_pair": "string",
  "left": "string",
  "repaid": "string",
  "paid_interest": "string",
  "unpaid_interest": "string",
  "fee_rate": "string",
  "orig_id": "string"
}

Margin loan details

Properties

Name Type Required Restrictions Description
id string false read-only Loan ID
create_time string false read-only Creation time
expire_time string false read-only Repay time of the loan. No value will be returned for lending loan
status string false read-only Loan status

open - not fully loaned
loaned - all loaned out for lending loan; loaned in for borrowing side
finished - loan is finished, either being all repaid or cancelled by the lender
auto_repaid - automatically repaid by the system
side string true none Loan side
currency string true none Loan currency
rate string false none Loan rate. Only rates in [0.0002, 0.002] are supported.

Not required in lending. Market rate calculated from recent rates will be used if not set
amount string true none Loan amount
days integer true none Loan days
auto_renew boolean false none Auto renew the loan on expiration
currency_pair string false none Currency pair. Required for borrowing side
left string false read-only Amount not lending out
repaid string false read-only Repaid amount
paid_interest string false read-only Repaid interest
unpaid_interest string false read-only Interest not repaid
fee_rate string false none Loan fee rate
orig_id string false none Original loan ID if the loan is auto-renewed. Equal to id if not

Enumerated Values

Property Value
status open
status loaned
status finished
status auto_repaid
side lend
side borrow

LoanRecord

{
  "id": "string",
  "loan_id": "string",
  "create_time": "string",
  "expire_time": "string",
  "status": "loaned",
  "borrow_user_id": "string",
  "currency": "string",
  "rate": "string",
  "amount": "string",
  "days": 0,
  "auto_renew": false,
  "repaid": "string",
  "paid_interest": "string",
  "unpaid_interest": "string"
}

Margin loaned record details

Properties

Name Type Required Restrictions Description
id string false none Loan record ID
loan_id string false none Loan ID the record belongs to
create_time string false none Loan time
expire_time string false none Expiration time
status string false none Loan record status
borrow_user_id string false none Garbled user ID
currency string false none Loan currency
rate string false none Loan rate
amount string false none Loan amount
days integer false none Loan days
auto_renew boolean false none Whether the record will auto renew on expiration
repaid string false none Repaid amount
paid_interest string false read-only Repaid interest
unpaid_interest string false read-only Interest not repaid

Enumerated Values

Property Value
status loaned
status finished

Contract

{
  "name": "string",
  "type": "inverse",
  "quanto_multiplier": "string",
  "leverage_min": "string",
  "leverage_max": "string",
  "maintenance_rate": "string",
  "mark_type": "internal",
  "mark_price": "string",
  "index_price": "string",
  "last_price": "string",
  "maker_fee_rate": "string",
  "taker_fee_rate": "string",
  "order_price_round": "string",
  "mark_price_round": "string",
  "funding_rate": "string",
  "funding_interval": 0,
  "funding_next_apply": 0,
  "risk_limit_base": "string",
  "risk_limit_step": "string",
  "risk_limit_max": "string",
  "order_size_min": 0,
  "order_size_max": 0,
  "order_price_deviate": "string",
  "ref_discount_rate": "string",
  "ref_rebate_rate": "string",
  "orderbook_id": 0,
  "trade_id": 0,
  "trade_size": 0,
  "position_size": 0,
  "config_change_time": 0,
  "in_delisting": true
}

Futures contract details

Properties

Name Type Required Restrictions Description
name string false none Futures contract
type string false none Futures contract type
quanto_multiplier string false none Multiplier used in converting from invoicing to settlement currency in quanto futures
leverage_min string false none Minimum leverage
leverage_max string false none Maximum leverage
maintenance_rate string false none Maintenance rate of margin
mark_type string false none Mark price type, internal - based on internal trading, index - based on external index price
mark_price string false none Current mark price
index_price string false none Current index price
last_price string false none Last trading price
maker_fee_rate string false none Maker fee rate, where negative means rebate
taker_fee_rate string false none Taker fee rate
order_price_round string false none Minimum order price increment
mark_price_round string false none Minimum mark price increment
funding_rate string false none Current funding rate
funding_interval integer false none Funding application interval, unit in seconds
funding_next_apply number false none Next funding time
risk_limit_base string false none Risk limit base
risk_limit_step string false none Step of adjusting risk limit
risk_limit_max string false none Maximum risk limit the contract allowed
order_size_min integer(int64) false none Minimum order size the contract allowed
order_size_max integer(int64) false none Maximum order size the contract allowed
order_price_deviate string false none deviation between order price and current index price. If price of an order is denoted as order_price, it must meet the following condition:

abs(order_price - mark_price) <= mark_price * order_price_deviate
ref_discount_rate string false none Referral fee rate discount
ref_rebate_rate string false none Referrer commission rate
orderbook_id integer(int64) false none Current orderbook ID
trade_id integer(int64) false none Current trade ID
trade_size integer(int64) false none Historical accumulation trade size
position_size integer(int64) false none Current total long position size
config_change_time number false none Configuration's last changed time
in_delisting boolean false none Contract is delisting

Enumerated Values

Property Value
type inverse
type direct
mark_type internal
mark_type index

Position

{
  "user": 0,
  "contract": "string",
  "size": 0,
  "leverage": "string",
  "risk_limit": "string",
  "leverage_max": "string",
  "maintenance_rate": "string",
  "value": "string",
  "margin": "string",
  "entry_price": "string",
  "liq_price": "string",
  "mark_price": "string",
  "unrealised_pnl": "string",
  "realised_pnl": "string",
  "history_pnl": "string",
  "last_close_pnl": "string",
  "realised_point": "string",
  "history_point": "string",
  "adl_ranking": 0,
  "pending_orders": 0,
  "close_order": {
    "id": 0,
    "price": "string",
    "is_liq": true
  }
}

Futures position details

Properties

Name Type Required Restrictions Description
user integer(int64) false read-only User ID
contract string false read-only Futures contract
size integer(int64) false read-only Position size
leverage string false none Position leverage. 0 means cross margin; positive number means isolated margin
risk_limit string false none Position risk limit
leverage_max string false read-only Maximum leverage under current risk limit
maintenance_rate string false read-only Maintenance rate under current risk limit
value string false read-only Position value calculated in settlement currency
margin string false none Position margin
entry_price string false read-only Entry price
liq_price string false read-only Liquidation price
mark_price string false read-only Current mark price
unrealised_pnl string false read-only Unrealized PNL
realised_pnl string false read-only Realized PNL
history_pnl string false read-only History realized PNL
last_close_pnl string false read-only PNL of last position close
realised_point string false read-only Realized POINT PNL
history_point string false read-only History realized POINT PNL
adl_ranking integer false read-only ADL ranking, range from 1 to 5
pending_orders integer false read-only Current open orders
close_order object false read-only Current close order if any, or null
» id integer(int64) false none Close order ID
» price string false none Close order price
» is_liq boolean false none Is the close order from liquidation

FuturesOrder

{
  "id": 0,
  "user": 0,
  "create_time": 0,
  "finish_time": 0,
  "finish_as": "filled",
  "status": "open",
  "contract": "string",
  "size": 0,
  "iceberg": 0,
  "price": "string",
  "close": false,
  "is_close": true,
  "reduce_only": false,
  "is_reduce_only": true,
  "is_liq": true,
  "tif": "gtc",
  "left": 0,
  "fill_price": "string",
  "text": "string",
  "tkfr": "string",
  "mkfr": "string",
  "refu": 0
}

Futures order details

Properties

Name Type Required Restrictions Description
id integer(int64) false read-only Futures order ID
user integer false read-only User ID
create_time number false read-only Order creation time
finish_time number false read-only Order finished time. Not returned if order is open
finish_as string false read-only How the order is finished.

- filled: all filled
- cancelled: manually cancelled
- liquidated: cancelled because of liquidation
- ioc: time in force is IOC, finish immediately
- auto_deleveraged: finished by ADL
- reduce_only: cancelled because of increasing position while reduce-only set
status string false read-only Order status

- open: waiting to be traded
- finished: finished
contract string true none Futures contract
size integer(int64) false none Order size. Specify positive number to make a bid, and negative number to ask
iceberg integer(int64) false none Display size for iceberg order. 0 for non-iceberg. Note that you would pay the taker fee for the hidden size
price string false none Order price. 0 for market order with tif set as ioc
close boolean false write-only Set as true to close the position, with size set to 0
is_close boolean false read-only Is the order to close position
reduce_only boolean false write-only Set as true to be reduce-only order
is_reduce_only boolean false read-only Is the order reduce-only
is_liq boolean false read-only Is the order for liquidation
tif string false none Time in force

- gtc: GoodTillCancelled
- ioc: ImmediateOrCancelled, taker only
- poc: PendingOrCancelled, reduce-only
left integer(int64) false read-only Size left to be traded
fill_price string false read-only Fill price of the order
text string false none User defined information. If not empty, must follow the rules below:

1. prefixed with t-
2. no longer than 28 bytes without t- prefix
3. can only include 0-9, A-Z, a-z, underscore(_), hyphen(-) or dot(.)
Besides user defined information, reserved contents are listed below, denoting how the order is created:

- web: from web
- api: from API
- app: from mobile phones
- auto_deleveraging: from ADL
- liquidation: from liquidation
- insurance: from insurance
tkfr string false read-only Taker fee
mkfr string false read-only Maker fee
refu integer false read-only Reference user ID

Enumerated Values

Property Value
finish_as filled
finish_as cancelled
finish_as liquidated
finish_as ioc
finish_as auto_deleveraged
finish_as reduce_only
status open
status finished
tif gtc
tif ioc
tif poc

FuturesPriceTriggeredOrder

{
  "initial": {
    "contract": "string",
    "size": 0,
    "price": "string",
    "close": false,
    "tif": "gtc",
    "text": "string",
    "reduce_only": false,
    "is_reduce_only": true,
    "is_close": true
  },
  "trigger": {
    "strategy_type": 0,
    "price_type": 0,
    "price": "string",
    "rule": 1,
    "expiration": 0
  },
  "id": 0,
  "user": 0,
  "create_time": 0,
  "finish_time": 0,
  "trade_id": 0,
  "status": "open",
  "finish_as": "cancelled",
  "reason": "string"
}

Futures order details

Properties

Name Type Required Restrictions Description
initial object true none none
» contract string true none Futures contract
» size integer(int64) false none Order size. Positive size means to buy, while negative one means to sell. Set to 0 to close the position
» price string true none Order price. Set to 0 to use market price
» close boolean false write-only Set to true if trying to close the position
» tif string false none Time in force. If using market price, only ioc is supported.

- gtc: GoodTillCancelled
- ioc: ImmediateOrCancelled
» text string false none How the order is created. Possible values are: web, api and app
» reduce_only boolean false none Set to true to create an reduce-only order
» is_reduce_only boolean false read-only Is the order reduce-only
» is_close boolean false read-only Is the order to close position
trigger object true none none
» strategy_type integer false none How the order will be triggered

- 0: by price, which means order will be triggered on price condition satisfied
- 1: by price gap, which means order will be triggered on gap of recent two prices of specified price_type satisfied.
Only 0 is supported currently
» price_type integer false none Price type. 0 - latest deal price, 1 - mark price, 2 - index price
» price string false none Value of price on price triggered, or price gap on price gap triggered
» rule integer false none Trigger condition type

- 1: calculated price based on strategy_type and price_type >= price
- 2: calculated price based on strategy_type and price_type <= price
» expiration integer false none How many seconds will the order wait for the condition being triggered. Order will be cancelled on timed out
id integer(int64) false read-only Auto order ID
user integer false read-only User ID
create_time number false read-only Creation time
finish_time number false read-only Finished time
trade_id integer(int64) false read-only ID of the newly created order on condition triggered
status string false read-only Order status.
finish_as string false read-only How order is finished
reason string false read-only Extra messages of how order is finished

Enumerated Values

Property Value
tif gtc
tif ioc
strategy_type 0
strategy_type 1
price_type 0
price_type 1
price_type 2
rule 1
rule 2
status open
status finished
finish_as cancelled
finish_as succeeded
finish_as failed
finish_as expired

DeliveryContract

{
  "name": "string",
  "underling": "string",
  "cycle": "WEEKLY",
  "type": "inverse",
  "quanto_multiplier": "string",
  "leverage_min": "string",
  "leverage_max": "string",
  "maintenance_rate": "string",
  "mark_type": "internal",
  "mark_price": "string",
  "index_price": "string",
  "last_price": "string",
  "maker_fee_rate": "string",
  "taker_fee_rate": "string",
  "order_price_round": "string",
  "mark_price_round": "string",
  "basis_rate": "string",
  "basis_value": "string",
  "basis_impact_value": "string",
  "settle_price": "string",
  "settle_price_interval": 0,
  "settle_price_duration": 0,
  "expire_time": 0,
  "risk_limit_base": "string",
  "risk_limit_step": "string",
  "risk_limit_max": "string",
  "order_size_min": 0,
  "order_size_max": 0,
  "order_price_deviate": "string",
  "ref_discount_rate": "string",
  "ref_rebate_rate": "string",
  "orderbook_id": 0,
  "trade_id": 0,
  "trade_size": 0,
  "position_size": 0,
  "config_change_time": 0,
  "in_delisting": true
}

Futures contract details

Properties

Name Type Required Restrictions Description
name string false none Futures contract
underling string false none Underlying
cycle string false none Cycle type, e.g. WEEKLY, QUARTERLY
type string false none Futures contract type
quanto_multiplier string false none Multiplier used in converting from invoicing to settlement currency in quanto futures
leverage_min string false none Minimum leverage
leverage_max string false none Maximum leverage
maintenance_rate string false none Maintenance rate of margin
mark_type string false none Mark price type, internal - based on internal trading, index - based on external index price
mark_price string false none Current mark price
index_price string false none Current index price
last_price string false none Last trading price
maker_fee_rate string false none Maker fee rate, where negative means rebate
taker_fee_rate string false none Taker fee rate
order_price_round string false none Minimum order price increment
mark_price_round string false none Minimum mark price increment
basis_rate string false none Fair basis rate
basis_value string false none Fair basis value
basis_impact_value string false none Funding used for calculating impact bid, ask price
settle_price string false none Settle price
settle_price_interval integer false none Settle price update interval
settle_price_duration integer false none Settle price update duration in seconds
expire_time integer(int64) false none Contract expiry timestamp
risk_limit_base string false none Risk limit base
risk_limit_step string false none Step of adjusting risk limit
risk_limit_max string false none Maximum risk limit the contract allowed
order_size_min integer(int64) false none Minimum order size the contract allowed
order_size_max integer(int64) false none Maximum order size the contract allowed
order_price_deviate string false none deviation between order price and current index price. If price of an order is denoted as order_price, it must meet the following condition:

abs(order_price - mark_price) <= mark_price * order_price_deviate
ref_discount_rate string false none Referral fee rate discount
ref_rebate_rate string false none Referrer commission rate
orderbook_id integer(int64) false none Current orderbook ID
trade_id integer(int64) false none Current trade ID
trade_size integer(int64) false none Historical accumulation trade size
position_size integer(int64) false none Current total long position size
config_change_time number false none Configuration's last changed time
in_delisting boolean false none Contract is delisting

Enumerated Values

Property Value
cycle WEEKLY
cycle BI-WEEKLY
cycle QUARTERLY
cycle BI-QUARTERLY
type inverse
type direct
mark_type internal
mark_type index