Overview
Welcome to the Coincall API! You can use our API to access Coincall Open API endpoints.
General Information
- Some endpoints will require an API Key to access. Please refer to this page to setup API Key.
- Base endpoint for REST: https://api.coincall.com
- While setting API Key, it is recommended to set IP access whitelist for security.
- Never share your API Key/Secret with anyone.
- The default permission of newly created API is read-only.
- Endpoint returns a JSON object.
- All time and timestamp related fields are in milliseconds.
Working with Endpoints
- For
GET
endpoints, parameters must be sent as aquery string
. - For
POST
endpoint, the parameters must be sent in therequest body
with content typeapplication/json
. - Parameters may be sent in any order.
- Because the API system is asynchronous, it is normal and expected that there will be a delay in the returned data.
Rate Limits
Endpoint | Rate Limit | Rule |
---|---|---|
Get Public Configuration | 10 / 2s | per IP address and product |
Get Funding Rate | 10 / 2s | per IP address |
Get Position / Open Orders | 5 / 1s | per User ID |
Get Historical Order / Transactions | 4 / 1s | per User ID |
Get Account Information | 2 / 1s | per User ID |
Get Orderbook | 30 / 2s | per User ID |
Place Order | 30 / 2s | per User ID |
Cancel Order | 30 / 2s | per User ID |
Authentication
API Resources
If you have any API related issues, please contact api@coincall.com
.
Generating API Keys
Create an API Key on the website before signing any requests. After creating an APIKey, keep the following information safe:
- APIKey
- APISecret
The system returns randomly-generated APIKeys and APISecrets. We cannot recover the APISecrets if you have lost it. You will need to create a new set of APIKey.
ApiKeys and apiSecret are case sensitive.
There are two permissions below that can be associated with an API key. One or more permission can be assigned to any key.
Read-Only - Can request and view public info such as public configurations.
Trade - Can place and cancel orders, and request and view account info such as bills and history.
Endpoint Security Type
- Each endpoint has a security type that determines how you will interact with it.
- Security type is stated next to the NAME of the endpoint. If no security type is stated, assume the security type is
NONE
.
Security Type | Description |
---|---|
NONE | Endpoint can be accessed freely. |
SIGNED | Requires valid API-Key and Signed. |
Making Requests
All private REST requests must contain the following headers:
X-CC-APIKEY
The API Key as a String.sign
The Base64-encoded signature (see Signing Messages subsection for details).ts
The timestamp of your request .e.g : 1688436087184X-REQ-TS-DIFF
sent to specify the number of milliseconds afterts
the request is valid for. IfX-REQ-TS-DIFF
is not sent, it defaults to 5000.
Request bodies should have content type application/json
and be in valid JSON format.
if (timestamp < (serverTime + 1000) && (serverTime - timestamp) <= X-REQ-TS-DIFF) {
// process request
} else {
// reject request
}
Serious trading is about timing.
Networks can be unstable and unreliable, which can lead to requests taking varying amounts of time to reach the servers. With X-REQ-TS-DIFF
, you can specify that the request must be processed within a certain number of milliseconds or be rejected by the server.
Signature
Sign Procedures:
- Add
?
after request uri path, separate each parameter with a&
which represents Parameters concatenation, sort them alphabetically. (If no prameter here, can only add?
after request uri path) - Create a prehash string of
method + uri + &uuid=your_api_key&ts=your_timestamp&x-req-ts-diff=your_ts_diff
(where+
represents String concatenation, if no prameter here, please usemethod + uri + uuid=your_api_key&ts=your_timestamp&x-req-ts-diff=your_ts_diff
instead). - Sign the prehash string with the apiSecret using the HMAC SHA256.
- Encode the signature in the Base64 format.
- The
sign
should be UPPER.
Example:
your_prehash_string=POST/open/futures/leverage/set/v1?leverage=1&symbol=BTCUSD&uuid=xdtHWn32rsuDQConutzl9JDZB+Y1leitFl356YHrmts=&ts=1688436087184&x-req-ts-diff=3000
sign=hmac.new(your_api_secret.encode('utf-8'), your_prehash_string.encode('utf-8'), hashlib.sha256).hexdigest()
The timestamp value is the same as the ts
header with UNIX millisecond timestamp of when the request was created and sent, e.g. 1688436087184
The request method
should be in UPPERCASE: e.g. GET
and POST
.
The uri
is the path of requesting an endpoint, separate each parameter with a &
, ?
represents Parameters concatenation.
Example: /open/futures/leverage/set/v1?leverage=1&symbol=BTCUSD
Your API Secret is generated when you create an APIKey.
Field Type Enumeration
Name | Product | Note |
---|---|---|
type | options | Option order type: 1 CALL, 2 PUT |
tradeSide | options/futures/websocket | Trade side: 1 BUY, 2 SELL |
tradeType | options/futures/websocket | Trade type: 1 LIMIT, 2 MARKET, 3 POST_ONLY, 4 STOP_LIMIT, 5 STOP_MARKET |
reduceOnly | options/futures/websocket | Reduce only: 0 FALSE, 1 TRUE |
state | options/websocket | Order status: -10 ILLEGAL, -1 PRE, 0 NEW, 1 FILLED, 2 PARTIALLY_FILLED, 3 CANCELED, 4 PRE_CANCEL, 5 CANCELING, 6 INVALID, 10 CANCEL_BY_EXERCISE |
state | futures/websocket | Order status: -2 WAITING_EFFECT, -1 PRE, 0 NEW, 1 FILLED, 2 PARTIALLY_FILLED, 3 CANCELED, 4 PRE_CANCEL, 5 CANCELING, 6 INVALID |
isTaker | options/futures/websocket | Filled by taker side: 0 FALSE 1 TRUE |
period | websocket | granularity of K-line: m1 1minute, m5 5minutes, m15 15minutes, m30 30minutes, h1 1hour, h4 4hours, d1 1day, w1 1week, mn1 1month, quarter 3months |
Error Information
{
"code": -40004,
"msg": "Invalid symbol."
}
All endpoints return error payload:
Specific error codes and messages defined in Error Codes
Market Maker Program
High-caliber trading teams are welcomed to work with Coincall as market makers in providing a liquid, fair, and orderly platform to all users. Coincall market makers could enjoy favourable fees in return for meeting the market making obligations.
Prerequisites (Satisfy any condition):
- Monthly trading volume ≥5,000,000 USD on major exchanges
- Qualified Market Maker on other exchange
Interested parties could drop us an email at mm@coincall.com
with the below details:
- Your account email
- Contact details (additional to your account email)
- A screenshot of your maker trading volume (such as 30 days trading volume or VIP status)
- Specify the product line you would like to provide liquidity for (you may choose more than one)
- Futures
- Options
Remarks:
Market making obligations and trading fees will be shared to successful parties only.
Public Endpoints
Check Server Time
Test connectivity to the Rest API and get the current server time.
Response:
{
"code":0,
"msg":null,
"i18nArgs":null,
"data":{
"serverTime":1687250525704 // Server time
}
}
HTTP Request
GET https://api.coincall.com/time
Parameter
Null
Get Public Configurations
Get trading-related configuration
Response:
{
"code":0,
"msg":"Success",
"i18nArgs":null,
"data":{
// Options configuration
"optionConfig":{
"BTCUSD":{
"symbol":"BTCUSD", // Symbol
"takerFee":0.0004, // Taker fee
"maxOrderNumber":200, // Maximum number of open orders
"multiplier":0.01, // Multiplier
"settle":"USD", // Settlement currency
"priceDecimal":2, // Decimal of price
"limitMaxQty":1000, // Maximum value of quantity for limit order
"tickDecimal":1, // Decimal of tick
"tickSize":0.1, // Tick size
"greeksDecimal":5, // Decimal of greeks
"makerFee":0.0003, // Maker fee
"marketMaxQty":100, // Maximum value of quantity for market order
"qtyDecimal":2, // Decimal of quantity
"maxPositionQty":1000, // Maximum quantity of position
"base":"BTC" // Base token
}
},
"futuresConfig":{
"BTCUSD":{
"symbol":"BTCUSD", // Symbol
"positionQty":100000000, // Maximum quantity of position
"takerFee":0.0006, // Taker fee
"maxOrderNumber":200, // Maximum number of open orders
"settle":"USD", // Settlement currency
"priceDecimal":1, // price of Decimal
"limitMaxQty":1000, // Maximum value of quantity for limit order
"tickDecimal":1, // Decimal of tick
"tickSize":0.1, // Tick size
"makerFee":0.0002, // Maker fee
"triggerLimit":20,
"marketMaxQty":120,// Maximum value of quantity for market order
"qtyDecimal":3, // Decimal of quantity
"base":"BTC", // Base token
"minQty":0.001 // Minimum value of quantity
}
}
}
}
HTTP Request
GET https://api.coincall.com/open/public/config/v1
Parameter
Null
Get Funding Rate
Get real-time funding rate
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data": [
{
"symbol": "BTCUSD",// Symbol
"rate": "-0.00500000",// Funding rate
"contractId": "1",// Contract ID
"ts": 1687250525704 // Timestamp
}
]
}
HTTP Request
GET https://api.coincall.com/open/public/fundingRate/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
symbol | string | BTCUSD,ETHUSD | false | Contract name (if not passed, all will be taken. Multiple can be taken separated by commas) |
User Account Related
Get User Info(SIGNED)
Get user information
Response:
{
"code":0,
"msg":"Success",
"i18nArgs":null,
"data":{
"name":"xxxx",
"email":"xxxx",
"userId":123456
}
}
HTTP Request
GET https://api.coincall.com/open/user/info/v1
Parameter
Null
Get Account Summary(SIGNED)
Get account summary
Response:
{
"code":0,// Status code
"msg":"Success",// Message
"i18nArgs":null,
"data":{
"accountId":123456,// Account ID
"coin":"USD",
"coinIconUrl":"xxxx",
"coinDesc":"USD Stablecoins",
"coinView":"USD",
"equityAmount":100000,// Total assets value in account
"availableBalance":99999.16966405,// Available balance
"canWithdrawAmount":99999.16966405,// Maximum amount can be withdrawn
"marginMode":1,// Margin mode (1 SM 2 PM)
"marginBalance":100000,// Margin balance
"unrealizedAmount":0,// Total unrealized P/L of the account
"imAmount":0,// Total initial margin of account
"mmAmount":0,// Total maintenance margin of the account
"delta":null,
"chainType":null,
"btcValue":3.6848964,
"dollarValue":100000,
"decimal":8
}
}
HTTP Request
GET https://api.coincall.com/open/account/summary/v1
Parameter
Null
Options Endpoint
Get Option Instruments(SIGNED)
Get all option instruments information.
Response:
{
"code": 0,
"msg": "Success",
"i18nArgs": null,
"data": [{
"baseCurrency": "BTC",
"expirationTimestamp": 1694678400000,
"strike": 22500.0,
"symbolName": "BTCUSD-14SEP23-22500-C",
"isActive": true,
"minQty": 0.01,
"tickSize": 0.1
}, {
"baseCurrency": "BTC",
"expirationTimestamp": 1694678400000,
"strike": 22500.0,
"symbolName": "BTCUSD-14SEP23-22500-P",
"isActive": true,
"minQty": 0.01,
"tickSize": 0.1
}, {
"baseCurrency": "BTC",
"expirationTimestamp": 1694678400000,
"strike": 23000.0,
"symbolName": "BTCUSD-14SEP23-23000-C",
"isActive": true,
"minQty": 0.01,
"tickSize": 0.1
}, {
"baseCurrency": "BTC",
"expirationTimestamp": 1694678400000,
"strike": 23000.0,
"symbolName": "BTCUSD-14SEP23-23000-P",
"isActive": true,
"minQty": 0.01,
"tickSize": 0.1
}]
}
HTTP Request
GET https://api.coincall.com/open/option/getInstruments/{}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
baseCurrency | string | BTC | true | option base currency |
Get Option Chain(SIGNED)
Get option chain
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data": [{
"strike": 22000.00000000,// Strike price
"callOption": {
"optionId": 1584505132356345856,// Option ID
"index": "BTCUSD",// Underlying symbol
"symbol": "BTCUSD-26OCT22-22000-C",// Option symbol name
"baseToken":"BTC",// Base token
"displayName":"BTC-31MAY23-30000-C",// display name
"endTime": 1666771200000,// Time of expiration
"strike": 22000.00000000,// Strike price
"lastPrice": 0,// Last price
"markPrice": 0.0,// Mark price
"volume": 0,// Trade volume
"openInterest": 0,// Open interest
"ask": 0,// Best ask price
"askIv": 0.0,// Best ask IV
"askSize": 0,// Best ask size
"bid": 0,// Best bid price
"bidIv": 0.0,// Best bid IV
"bidSize": 0,// Best bid size
"markIv": 0.0,// Mark price IV
"type": 1,// Option type
"lastPriceIv": 1.7976931348623157E308,// Last price IV
"underlyingPrice": 20278.25,// Price of the underlying
"breakeven": 30000,// Break-even Point
"changeRate": -1.0000,// Price change in percentage
"changePrice": -6.10000000,// Price change in value
"userPosition":0,// User Holdings in position
"delta": 0.0,// greeks delta
"gamma": 0.0,// greeks gamma
"vega": 0.0,// greeks vega
"theta": 0.0,// greeks theta
"rho":0 // greeks rho
},
"putOption": {
"optionId": 1668166500983382054,
"underlying": "BTCUSD",
"symbol": "BTCUSD-15JUN23-26000-P",
"baseToken": "BTC",
"displayName": "BTC-15JUN23-26000-P",
"endTime": 1686816000000,
"strike": 26000.00000000,
"lastPrice": 989.9,
"markPrice": 1138.22770000,
"volume": 8.95000000,
"openInterest": 7.38000000,
"ask": 0,
"askIv": 0.01,
"askSize": 0,
"bid": 658.6,
"bidIv": 0.01,
"bidSize": 10.35,
"markIv": 0.6292,
"type": 2,
"lastPriceIv": 1.0E-4,
"underlyingPrice": 24861.7723,
"breakeven": 24861.77230000,
"changeRate": 0.2271,
"changePrice": 199.53688859,
"userPosition": 0,
"delta": -1.0,
"gamma": 0.0,
"vega": 0.0,
"theta": 0.0,
"rho": -0.02421
}
}]
}
HTTP Request
GET https://api.coincall.com/open/option/get/v1/{index}?endTime={endTime}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
endTime | long | 1666771200000 | true | Expiration time(timestamp) |
index | string | BTCUSD | true | Underlying symbol |
Get Option Details(SIGNED)
Get option details
Response:
{
"code": 0,// Status code
"msg": "Success",
"i18nArgs": null,
"data": {
"optionId": 1584505132293431296,// Option ID
"symbol": "BTCUSD-26OCT22-20000-P",// Option name
"index":"BTCUSD",// Underlying Asset Name
"displayName":"BTC-31MAY23-24000-C",// display name
"endTime": 1666771200000,// Time of expiration
"remainTime": 13565073,// Time remain until expiration
"strike": 20000.00000000,// Strike price
"markPrice": 10.231632230252217,// Mark price
"underlyingPrice":27181.6936,// Underlying price
"volume": 1.00000000,// Trade volume
"volumeUsd": 1.00000000,// Trade value
"openInterest": 0,// Open interest
"lastPrice": 10.231632230252217,// Last price
"premium": 0,// Premium
"changeRate": 2.87,// Price change in percentage
"changePrice":null,// Price change in value
"iv": 0.58,// Implied volatility
"multiplier":0.01,// Contract Multiplier
"type": 2,// Option type
"indexPrice": 20239.96000000,// Index price
"price24hHigh": 0,// Highest price in 24hrs
"price24hLow": 0,// Lowest price in 24hrs
"volumeUsd24h": 0,// USD volume in 24hrs
"price24hOpen": 18215.964000000,// Open price on UTC 00:00:00
"volume24h": 0,// Trade volume in 24hrs
"breakeven":27171.65,// Break-even Point
"delta": -0.10808987585883545,// greeks delta
"gamma": 0.0009475995953294489,// greeks gamma
"vega": 0.7794498985827641,// greeks vega
"theta": 0.0,// greeks theta
"rho": -0.009454405809863273// greeks rho
}
}
HTTP Request
GET https://api.coincall.com/open/option/detail/v1/{}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
symbol | string | BTCUSD-24MAY22-48000-P | true | option symbol name |
Get OrderBook(SIGNED)
Get option order book for 100 depth
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data": {
"optionName": "BTCUSD-26OCT22-15000-C",// Option name
"displayName": null,
"strike": 15000,// Strike price
"bids": [{
"size": "0.5",// Size
"price": "5251"// Price
}],
"asks": [{
"size": "1",// Size
"price": "8888"// Price
}]
}
}
HTTP Request
GET https://api.coincall.com/open/option/order/orderbook/v1/{}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
symbol | string | BTCUSD-26OCT22-15000-C | true | Option Name |
Get Last Trade(SIGNED)
Get option last trade
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data": [
{
"symbol": "BTCUSD-26OCT22-20000-P",// Option symbol name
"displayName":"BTC-26OCT22-20000-P",// Option display name
"price": "10.3",// Trade price
"qty": "1",// Trade Quantity
"time": 1666757622819,// Trade time
"tradeSide": 2// Trade side
}
]
}
HTTP Request
GET https://api.coincall.com/open/option/trade/lasttrade/v1/{}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
symbol | string | BTCUSD-6JUN23-24000-C | true | Option Name |
Get Positions(SIGNED)
Get All option positions
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data": [{
"id": 1584736851047620608,// ID
"positionId": 1584736851047620609,// Position ID
"updateTime": 1666665682934,// Update time
"orderId": 1584736036348895232,// Order ID
"userId": 1536933707941347382,// User ID
"value": 11294.2000000000000000,// Position Value
"qty": 1.00000000,// Position Quantity
"initMargin": 0,// Initial Margin
"maintMargin": 0,// Maintnance Margin
"avgPrice": 11294.20000000,// Average Price
"markPrice": 12260.310000000001,// Mark price
"upnl": 966.11000000000100000000,// unRealized PnL
"roi": 8.55403659,// Return on investment
"rspl": 0E-8, // Realized PnL
"symbol": "BTCUSD-25NOV22-8000-C",// Option symbol name
"displayName": "BTC-25NOV22-8000-C",// Display name
"tradeSide": 1,// Trade Side 1 BUY 2 SELL
"lockQty": 0,// Lock Quantity
"indexPrice": 12.22, // Index price
"delta": 1.0,// greeks delta
"gamma": 0.0,// greeks gamma
"vega": 0.0,// greeks vega
"theta": 0.0,// greeks theta
"rho": 6.610892947742262,// greeks rho
"baseToken": "BTC",// Base token
"quoteToken": "USD" // Quote token
}]
}
HTTP Request
GET https://api.coincall.com/open/option/position/get/v1
Parameter
Null
Place Order(SIGNED)
Place an option order
Response:
{
"code":0,
"msg":"Success",
"i18nArgs":null,
"data":1663820914095300608 // Order id
}
HTTP Request
POST https://api.coincall.com/open/option/order/create/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
clientOrderId | long | 123123123 | false | client order id |
tradeSide | number | 1 | true | Trade Side, 1 BUY 2 SELL |
tradeType | number | 1 | true | Trade Type, 1 LIMIT 2 MARKET 3 POST_ONLY |
symbol | string | BTCUSD-26OCT22-15000-C | true | Option name |
qty | number | 0.5 | true | Quantity |
price | number | 19000.01 | false | Price, required for limit orders |
Cancel Order(SIGNED)
Cancel an option order
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data":"success"
}
HTTP Request
POST https://api.coincall.com/open/option/order/cancel/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
orderId | number | 1663820914095300608 | false | order id |
clientOrderId | number | 123123123 | false | client order id |
Notice:
orderId and clientOrderId, one of the two parameters must be entered.
Cancel Orders(SIGNED)
Cancel option orders by symbol
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data": null
}
HTTP Request
GET https://api.coincall.com/open/option/order/cancelOpenOrders/{version}/{symbol}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
version | string | v1 | true | version, only v1 for now |
symbol | string | BTCUSD | true | Option index symbol name |
Get Open Orders(SIGNED)
Get option open orders
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data": {
"list":[
{
"id": 1665910350698258432,// ID
"orderId": 1665910350698258432,// Order ID
"clientOrderId": 123123123,// Client order id
"symbol": "BTCUSD-6JUN23-24000-C",// Option symbol name
"displayName":"BTC-6JUN23-24000-C",// Option display name
"qty": 0.5,// Order Quantity
"remainQty":0.5,// Unfilled Quantity
"fillQty": 0,// Filled Quantity
"price": 2095.6,// Price
"avgPrice": null,// Average price
"initMargin": 1047.8,// Initial Margin
"tradeSide": 1,// Trade side
"tradeType": 1,// Trade type
"createTime": 1666667584739,// Time of the order created
"reduceOnly": 0, // Reduce only
"indexPrice": 25782.815 // Index Price
}
],
"pageTotal":1,// Total Page Count
"total":1 // Total Data Count
}
}
HTTP Request
GET https://api.coincall.com/open/option/order/pending/v1/{}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
page | number | 1 | false | Page number, default is 1 |
pageSize | number | 20 | false | Number of items per page, default is 20, maximum value is 500 |
currency | string | BTC | false | Filter data for a specific currency |
Get Order Info(SIGNED)
Get an order information by orderId or clientOrderId
Response:
{
"code": 0, // Status code
"msg": "success", //Message
"i18nArgs": null,
"data":{
{
"orderId": 1665910350698258432,// Order ID
"clientOrderId": 123123123,// Client order id
"symbol": "BTCUSD-6JUN23-24000-C",// Option symbol name
"displayName":"BTC-6JUN23-24000-C",// Option display name
"qty": 0.5,// Order Quantity
"remainQty":0.5,// Unfilled Quantity
"fillQty": 0,// Filled Quantity
"price": 2095.6,// Price
"avgPrice": null,// Average price
"tradeSide": 1,// Trade side
"tradeType": 1,// Trade type
"createTime": 1666667584739,// Time of the order created
"reduceOnly": 0, // Reduce only
"fee": 0, // transaction fee(accumulated)
"updateTime": 1685326195118,
"state": 0 // order status
}
}
}
HTTP Request
GET https://api.coincall.com/open/option/order/singleQuery/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
orderId | number | 111 | false | query string |
clientOrderId | number | 123123123 | false | client order id |
Notice:
orderId and clientOrderId, one of the two parameters must be entered.
Get Order Details(SIGNED)
Get Option Order History
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs":null,
"data":{
"list":[
{
"orderId": 1665650442392174592, // Order ID
"clientOrderId": 1665650442392174592,// Client order id
"symbol": "BTCUSD-25NOV22-8000-C", // Option symbol name
"displayName": "BTC-25NOV22-8000-C", // Display name
"qty": 1.00000000, // Order Quantity
"fillQty": 1.00000000, // Filled Quantity
"price": 0.49110000, // Order Price
"avgPrice": 0.49110000, // Average price
"fee":0.22, // fee
"rpnl":0.22, // Realized PnL
"tradeSide": 1, // Trade side
"tradeType": 1, // Trade type
"createTime": 1666667584739,// Time of the order created
"state": 1, // Order status
"reduceOnly": 0 // Reduce only
}
],
"hasNext": false, // Whether there is a next page
"hasPre": false // Whether there is a previous page
}
}
HTTP Request
GET https://api.coincall.com/open/option/order/history/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
pageSize | number | 20 | true | Number of items per page, default is 20, maximum value is 500 |
fromId | number | 123123123 | false | Minimum orderId, can be obtained from the result field of the previous page when paging |
startTime | number | 1686308840388 | false | Start time of the history, default is the current time pushed forward by 24 hours |
endTime | number | 1686308840388 | false | End time of the history |
Get Transaction Details(SIGNED)
Get option transaction history
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data": {
"list": [
{
"id": 1584745240079241216,// ID
"optionId": null,// Option ID
"symbol":"BTCUSD-2JUN23-18000-C",// Option symbol name
"displayName":"BTC-2JUN23-18000-C",// Option display name
"tradeSide": 1,// Trade side
"tradeType": 1,// Trade type
"price": 951.00000000,// Price
"qty": 2.00000000,// Quantity
"iv": 0.5606,// Implied Volatility
"markPrice": 1419.5139928388217,// Mark price
"indexPrice": 20247.0,// Index price
"orderId": 1584744827800133632,// Order ID
"tradeId": 1584745239911469056,// Trade ID
"fee": 0.00190200,// Fees
"time": 1666667683034,// Transaction time
"reduceOnly":0, // Reduce only
"isTaker":0 // Filled by taker side
}
],
"hasNext": true, // Whether there is a next page
"hasPre": false // Whether there is a previous page
}
}
HTTP Request
GET https://api.coincall.com/open/option/trade/history/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
pageSize | number | 20 | false | Number of items per page, default is 20, maximum value is 500 |
fromId | number | 123123123 | false | Minimum tradeId, can be obtained from the result field of the previous page when paging |
startTime | number | 1686308840388 | false | Start time of the history |
endTime | number | 1686308840388 | false | End time of the history |
Futures Endpoint
Get Symbol Information(SIGNED)
Get futures symbol
Response:
{
"code": 0,// Status code
"msg": "success",// Message
"i18nArgs": null,
"data": [{
"contractId": 1,// Contract ID
"symbol": "BTCUSD",// Symbol
"symbolName":"BTC/USD",// Symbol name
"displayName":"BTC-PERP",// Symbol display name
"baseToken":"BTC",// Base Token
"quoteToken":"USD",// Quote Token
"price": 25614.7,// Price
"changeRate": -0.003,// Price change in percentage
"changePrice":-78.2,// Price change in value
"markPrice": 25661.25861712,// Mark price
"indexPrice": 25754.025,// Index Price
"price24hHigh": 27065.7,// Highest price in 24hrs
"price24hLow": 18000,// Lowest price in 24hrs
"volumeUsd24h": 3846213875.0958,// USD volume in 24hrs
"volume24h": 147370.135,// Volume in 24hrs
"ts": 20201116024818,// Timestamp
"price24hOpen":25692.9,// Open price on UTC 00:00:00
"hasOption":true,// Whether there are options
"sortIdx":null // Sort Field
}]
}
HTTP Request
GET https://api.coincall.com/open/futures/market/symbol/v1
Parameter
Null
Get OrderBook(SIGNED)
Get futures order book for 100 depth
Response:
{
"code": 0,// Status code
"msg": "success",//Message
"i18nArgs": null,
"data": {
"symbol": "BTCUSD",// Symbol
"bids": [{
"size": "0.001",// Size
"price": "18801"// Price
}],
"asks": [{
"size": "0.992",// Size
"price": "18898"// Price
}]
}
}
HTTP Request
GET https://api.coincall.com/open/futures/order/orderbook/v1/{}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
symbol | string | BTCUSD | true | Symbol name |
Get Last Trade(SIGNED)
Get futures last trade
Response:
{
"code": 0,// Status code
"msg": "success",//Message
"i18nArgs": null,
"data": [{
"symbol": "BTCUSD",// Symbol
"price": "18898",// Price
"qty": "0.001",// Quantity
"time": 1666754916559,// Time of the transaction
"tradeSide": 1 // Trade side
}]
}
HTTP Request
GET https://api.coincall.com/open/futures/trade/lasttrade/v1/{}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
symbol | string | BTCUSD | true | Symbol name |
Get leverage(SIGNED)
Get current futrues leverage
Response:
{
"code": 0,// Status code
"msg": "success",
"i18nArgs": null,
"data": {
"userId": 123,// User ID
"symbol": "BTCUSD",// Symbol
"currentLeverage": 5 // Current leverage
}
}
HTTP Request
GET https://api.coincall.com/open/futures/leverage/current/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
symbol | string | BTCUSD | true | Symbol name |
Set Leverage(SIGNED)
Set futures leverage
Response:
{
"code": 0,// Status code
"msg": "success",//Message
"i18nArgs": null,
"data": null
}
HTTP Request
POST https://api.coincall.com/open/futures/leverage/set/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
symbol | string | BTCUSD | true | Symbol name |
leverage | number | 10 | true | leverage for this symbol |
Get Positions(SIGNED)
Get futures positions
Response:
{
"code": 0,// Status code
"msg": "success",//Message
"i18nArgs": null,
"data": [
{
"id": 1584467417583730700,// ID
"positionId": 1584467417583730700,// Position ID
"updateTime": 1666602220413,// Update time
"userId": 1536933707941347300,// User ID
"value": 176.7825,// Value of Position
"qty": 0.009,// Quantity
"initMargin": 35.3565,// Initial margin
"maintMargin": 1.767825,// Maintnance margin
"avgPrice": 19642.5,// Average price
"markPrice": 18900.38311437,// Mark price
"elp": null,// Estimated liquidation price
"roi": -0.03778118,// ROI
"upnl": -6.67905197067,// Unrealized Pnl
"symbol": "BTCUSD",//symbol
"displayName": "BTC-PERP",// Display name
"tradeSide": 1,// Trade side
"leverage": 5,// Leverage
"delta": 0.009,// Position delta
"baseToken": "BTC", // Base token
"quoteToken": "USD" // Quote token
}]
}
HTTP Request
GET https://api.coincall.com/open/futures/position/get/v1
Parameter
Null
Place Order(SIGNED)
Place a futures order
Response:
{
"code": 0,// Status code
"msg": "success",//Message
"i18nArgs": null,
"data": 1673571411341475840 // Order id
}
HTTP Request
POST https://api.coincall.com/open/futures/order/create/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
clientOrderId | long | 123123123 | false | client order id |
symbol | string | BTCUSD | true | Futures Symbol |
price | number | 19000.01 | false | Price, required for limit orders |
qty | number | 0.5 | true | Quantity |
tradeSide | number | 1 | true | Trade Side, 1 BUY 2 SELL |
tradeType | number | 1 | true | Trade Type, 1 LIMIT 2 MARKET 3 POST_ONLY |
Cancel Order(SIGNED)
Cancel a futures order
Response:
{
"code": 0,// Status code
"msg": "success",//Message
"i18nArgs": null,
"data": null
}
HTTP Request
POST https://api.coincall.com/open/futures/order/cancel/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
orderId | number | 111 | true | query string |
clientOrderId | number | 123123123 | false | client order id |
Notice:
orderId and clientOrderId, one of the two parameters must be entered.
Cancel Orders(SIGNED)
Cancel futures orders by symbol
Response:
{
"code": 0,// Status code
"msg": "Success",// Message
"i18nArgs": null,
"data": null
}
HTTP Request
GET https://api.coincall.com/open/futures/order/cancelOpenOrders/{version}/{symbol}
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
version | string | v1 | true | version, only v1 for now |
symbol | string | BTCUSD | true | Futures symbol name |
Get Open Orders(SIGNED)
Get open orders
Response:
{
"code": 0, // Status code
"msg": "success", //Message
"i18nArgs": null,
"data":{
"list":[
{
"id": 1663004711982333952,// ID
"clientOrderId":1000200000, // Client order id
"orderId": 1663004711982333952, // Order id
"symbol": "BTCUSD",// Futures symbol name
"displayName": "BTC-PERP", // Futures display name
"qty": 1.00000000, // Order Quantity
"remainQty": 1.00000000, // Unfilled Quantity
"fillQty": 0E-8, // Filled Quantity
"price": 500.00000000, // Price
"avgPrice": 0E-8, // Average price
"initMargin": 166.66666667, // Initial Margin
"tradeSide": 1, // Trade side
"tradeType": 1, // Trade type
"createTime": 1685326195118,// Time of the order created
"reduceOnly": 0, //Reduce only
"leverage": 3, // Leverage
"expression": null, // Conditional Expression (GE -- Greater than or equal to, LE -- Less than or equal to)
"triggerPrice": null // Trigger Price
}
],
"pageTotal":1,// Total Page Count
"total":1 // Total Data Count
}
}
HTTP Request
GET https://api.coincall.com/open/futures/order/pending/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
page | number | 1 | false | Page number, default is 1 |
pageSize | number | 20 | false | Number of items per page, default is 20 |
symbol | string | BTCUSD | false | Filter data for a specific symbol |
Get Order Info(SIGNED)
Get an order information by orderId or clientOrderId
Response:
{
"code": 0, // Status code
"msg": "success", //Message
"i18nArgs": null,
"data":{
{
"clientOrderId":1000200000, // Client order id
"orderId": 1663004711982333952, // Order id
"symbol": "BTCUSD",// Futures symbol name
"displayName": "BTC-PERP", // Futures display name
"qty": 1.00000000, // Order Quantity
"remainQty": 1.00000000, // Unfilled Quantity
"fillQty": 0E-8, // Filled Quantity
"price": 500.00000000, // Price
"avgPrice": 0E-8, // Average price
"tradeSide": 1, // Trade side
"tradeType": 1, // Trade type
"createTime": 1685326195118,// Time of the order created
"reduceOnly": 0, //Reduce only
"leverage": 3, // Leverage
"fee": 0, // transaction fee(accumulated)
"updateTime": 1685326195118,
"state": 0 // order status
}
}
}
HTTP Request
GET https://api.coincall.com/open/futures/order/singleQuery/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
orderId | number | 111 | false | query string |
clientOrderId | number | 123123123 | false | client order id |
Notice:
orderId and clientOrderId, one of the two parameters must be entered.
Get Order Details(SIGNED)
Get futures order history
Response:
{
"code": 0,// Status code
"msg": "success",//Message
"i18nArgs": null,
"data": {
"list": [{
"clientOrderId":1000200000, // Client order id
"orderId": 1665650442392174592, // Order id
"symbol": "XRPUSD",// Futures symbol name
"displayName": "XRP-PERP",// Futures display name
"qty": 1.00000000, // Order Quantity
"fillQty": 1.00000000, // Filled Quantity
"price": 0.49110000, // Price
"avgPrice": 0.49110000, // Average price
"fee": 0.00039288, // Order transaction fee
"rpnl": 0E-8, // Realized Pnl
"tradeSide": 2, // Trade side
"tradeType": 1, // Trade type
"createTime": 1685956986404,// Time of the order created
"state": 1, //Order Status
"reduceOnly": 0, // Reduce only
"leverage": 3, //Lleverage
"expression": null, // Conditional Expression (GE -- Greater than or equal to, LE -- Less than or equal to)
"triggerPrice": null // Trigger Price
}],
"hasNext": false, // Whether there is a next page
"hasPre": false // Whether there is a previous page
}
}
HTTP Request
GET https://api.coincall.com/open/futures/order/history/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
pageSize | number | 10 | true | Number of items per page |
fromId | number | 123123123 | false | Minimum orderId, can be obtained from the result field of the previous page when paging |
startTime | number | 1686308840388 | false | Start time of the history, default is the current time pushed forward by 24 hours |
endTime | number | 1686308840388 | false | End time of the history |
Get Transaction details(SIGNED)
Get futrues transaction history
Response:
{
"code": 0,// Status code
"msg": "success",//Message
"i18nArgs": null,
"data": {
"list": [{
"id": 1574775822713806849,// ID
"contractId": null,// Contract ID
"symbol": "ETHUSD",// Symbol
"displayName": "ETH-PERP",// Display name
"tradeSide": 1,// Trade side
"tradeType": 1,// Trade type
"price": 1389.00000000,// Price
"qty": 1.00000000,// Quantity
"markPrice": null,// Mark price
"indexPrice": 1389.26000000,// Index Price
"orderId": 1574775820017352705,// Order ID
"tradeId": 1574775820805869568,// Trade ID
"fee": 0.13890000,// Fees
"time": 1664290788701,// Time of the transaction
"leverage": 5, // Leverage
"isTaker": 1 // Filled by taker side, 1 Taker 0 FALSE
}],
"hasNext": true, // Whether there is a next page
"hasPre": false // Whether there is a previous page
}
}
HTTP Request
GET https://api.coincall.com/open/futures/trade/history/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
pageSize | number | 10 | false | Quantity per page |
fromId | number | 123123123 | false | Minimum orderId, can be obtained from the result field of the previous page when paging |
startTime | number | 1686308840388 | false | Start time of the history |
endTime | number | 1686308840388 | false | End time of the history |
Options WebSocket
# Sample code
import hashlib
import hmac
import time
import websocket
import json
import threading
# API INFO
api_key = "YOUR_API_KEY"
api_sec = "YOUR_API_SECRET"
def on_open(ws):
print("WebSocket connection opened.")
# Send a subscribe message after the connection opened.
ws.send(json.dumps({ "action":"subscribe", "dataType":"orderBook", "payload":{ "symbol":"BTCUSD-27MAY23-26000-C" } }))
def on_close(ws):
print("WebSocket connection closed.")
def on_error(ws, error):
print(f'WebSocket error: {error}')
def on_message(ws, message):
data = json.loads(message)
print(data)
def get_signed_header(ts):
verb='GET'
uri = '/users/self/verify'
auth = verb + uri + '?uuid=' + api_key + '&ts=' + str(ts)
signature = hmac.new(api_sec.encode('utf-8'), auth.encode('utf-8'), hashlib.sha256).hexdigest()
signature = signature.upper()
return signature
ts = int(time.time()*1000)
sign = get_signed_header(ts)
socket = 'wss://ws.coincall.com/options?code=10&uuid=' + api_key +'&ts='+ str(ts) +'&sign=' + sign + '&apiKey=' + api_key
ws = websocket.WebSocketApp(socket, on_open=on_open, on_close=on_close, on_error=on_error, on_message=on_message)
def run():
ws.run_forever()
ws_thread = threading.Thread(target=run)
ws_thread.start()
while True:
# Wait for the WebSocket connection to be established
if ws.sock and ws.sock.connected:
# Send heartbeat
msg = {"action":"heartbeat"}
ws.send(json.dumps(msg))
time.sleep(3)
else:
# If the WebSocket connection is not established, wait 3 seconds
time.sleep(3)
WSS interface for options:
wss://ws.coincall.com/options
- Connection example:
wss://ws.coincall.com/options?code=10&uuid=65905c2be07f49e79ac26aca4b0b3988&ts=1687326076897&sign=CF58E8C7BE6C10EF7D8A65F3D0538F7D6C73182C6AFCA26D2CBE2318E085E494&apiKey=7PvIEreC1g5Kd17S7Ei1mEd3ppyuoixhqlzqM0Rqfhw=
- Connection example:
Value of Connection Parameters
Name | Required | Note |
---|---|---|
code | true | 10, build connection |
uuid | false | Custom id by user |
ts | true | Timestamp, 1687326076897 |
sign | true | Signature |
apiKey | true | your api key |
sign: signature string, the signature algorithm is as follows:
First concatenate method + uri + ?uuid=your_api_key&ts=your_timestamp
(where +
represents String concatenation), then use HMAC SHA256 method to encrypt the concatenated string with apiSecret
, and then perform Base64 encoding.
method
: always GET
.
uri
: always /users/self/verify
Data Abbreviations
Please refer to the following field abbreviations for data fields in the futures request/response:
Name | Note |
---|---|
c | code, Operations for Request Protocol Execution |
rc | responseCode, Status of the Response Protocol |
d | data, Request/Response payload |
p | position, Subscription Data Page Location |
s | symbol |
high | high, The highest price |
low | low, The lowest price |
pe | period, granularity of K-line |
v | volume |
close | close price |
open | open price |
ts | timestamp |
uv | tradeValue |
rt | rt, remian timestamp |
mp | markPrice |
lp | lastPrice |
ip | indexPrice |
delta | delta |
iv | Implied Volatility |
theta | theta |
cp | changePrice, Price change in value |
pr0 | price24hOpen, Open price on UTC 00:00:00 |
cr | changeRate, Price change in percentage |
uv24 | volumeUsd24h, USD volume in 24hrs |
v24 | volume24h, Volume in 24hrs |
oi | openInterest |
up | underlyingPrice |
gamma | gamma |
vega | vega |
biv | bidIv, Best bid IV |
aiv | askIv, Best ask IV |
bs | bidSize, Best bid size |
as | askSize, Best ask size |
ask | ask, Best ask price |
bid | bid, Best bid price |
pr | price, last price |
sz | size |
sd | tradeSide |
q | qty, quantity |
fq | fill qty |
mm | pmMmAmount, maintenanceMargin in PM |
ab | available balance |
e | equityAmount |
mb | marginBalance |
btcv | btc value |
wb | canWithdrawPmAmount |
upnl | Unrealized Pnl |
ap | average proce |
coid | clientOrderId |
os | order status |
im | initialMargin in PM |
dv | Value in dollar |
oid | orderId |
si | trade side |
ty | trade type |
uid | userId |
ct | createTime |
ro | reduceOnly |
tid | trade ID |
rq | remainQty, Unfilled Quantity |
mpr | match price |
mq | match quantity |
le | leverage |
it | isTaker |
cq | canceled quantity |
HeartBeat
{ "action":"heartbeat" }
Payload:
{
"c":11,
"rc":1 // 1 Success
}
K-line Data
{ "action":"subscribe", "dataType":"kline", "payload":{ "symbol":"BTCUSD-27MAY23-24000-P", "period":"h1" } }
Payload:
{
"dt": 2,
"c": 20,
"d": {
"high": 4056.40850000, // The highest price
"s": "BTCUSD-4JUL23-27000-C", // symbol
"low": 4056.40850000, // The lowest price
"pe": "m1", // period
"v": 0, // volume
"close": 4056.40850000, // close price
"open": 4056.40850000, // open price
"ts": 1688449080000 // timestamp
}
}
Pricing Information
{ "action":"subscribe", "dataType":"bsInfo", "payload":{ "symbol":"BTCUSD-27MAY23-23500-C" } }
Payload:
{
"dt": 3,
"c": 20,
"d": {
"uv": 30783000.00000000, // tradeValue
"rt": 2081914160, // remian timestamp
"mp": 834.28262809, // markPrice
"lp": 834.29106136, // last price
"ip": 31059.68000000, // indexprice
"delta": 0.34898, // delta
"h": 783.67149194, // price24hHigh, Highest price in 24hrs
"l": 665.61113639, // price24hLow, Lowest price in 24hrs
"iv": 0.4728, // Implied Volatility
"theta": -29.14546, // theta
"cp": -64.84120504, // changePrice, Price change in value
"pr0": 899.13226640, // price24hOpen, Open price on UTC 00:00:00
"cr": -0.0721, // changeRate, Price change in percentage
"s": "BTCUSD-28JUL23-33000-C", // symbol
"uv24": 30783000.00000000, // volumeUsd24h, USD volume in 24hrs
"v": 1000.00000000, // volume
"v24": 1000.00000000, // volume24h, Volume in 24hrs
"oi": 1000.00000000, // openInterest
"up": 31248.97, // underlyingPrice
"gamma": 0.00010, // gamma
"vega": 29.70793, // vega
"ts": 1688449285840 // timestamp
}
}
Option Chain Data
{ "action":"subscribe", "dataType":"tOption", "payload":{ "symbol":"BTCUSD", "end":1685174400000 } }
Payload:
{
"dt": 4,
"c": 20,
"d": [{
"mp": 4038.58550000, // markPrice
"lp": 4038.58550000, // last price
"delta": 1.00000, // delta
"theta": 0.00000, // theta
"cp": -124.21240000, // changePrice, Price change in value
"biv": 0.01, // bidIv, Best bid IV
"aiv": 0.01, // askIv, Best ask IV
"cr": -0.0298, // changeRate, Price change in percentage
"bs": 0.2, // bidSize, Best bid size
"as": 0, // askSize, Best ask size
"s": "BTCUSD-4JUL23-27000-C", // symbol
"v": 1.00000000, // volume
"ask": 0, // ask, Best ask price
"v24": 1.00000000, // volume24h, Volume in 24hrs
"oi": 1.00000000, // openInterest
"upv": 0,
"up": 31038.5855, // underlyingPrice
"bid": 1, // bid, Best bid price
"gamma": 0.00000, // gamma
"vega": 0.00000, // vega
"ts": 1688452774463 // timestamp
}]
}
OrderBook
{ "action":"subscribe", "dataType":"orderBook", "payload":{ "symbol":"BTCUSD-27MAY23-26000-C" } }
Message channel for the 100 best ask/bid full data. After subscription, when there are changes in the order book, the system will push the real-time ticker symbol information to you
Payload:
{
"dt": 5,
"c": 20,
"d": {
"s": "BTCUSD-4JUL23-27000-C", // symbol
"asks": [{
"pr": "4038.58", // price
"sz": "1" // size
}],
"bids": [{
"pr": "1",
"sz": "0.2"
}],
"ts": 1688453641701 // timestamp
}
}
Last Trades
{ "action":"subscribe", "dataType":"lastTrade", "payload":{ "symbol":"BTCUSD-27MAY23-26000-C" } }
Payload:
{
"dt": 6,
"c": 20,
"d": [{
"q": "1", // qty, quantity
"sd": 1, // tradeSide
"pr": "2757.03", // price
"s": "BTCUSD-4JUL23-27000-C", // symbol
"ts": 1688454356810 // timestamp
}]
}
Real-Time Account Margin
{ "action":"subscribe", "dataType":"accountBalance" }
Payload:
{
"dt": 7,
"c": 20,
"d": {
"mm": 26223.65036916, // pmMmAmount maintenanceMargin in PM
"ab": 100028273.92018174, // available balance
"dv": 100176235.63450066, // Value in dollar
"im": 165648.38520366, // pmImAmount initialMargin in PM
"uid": 8095892901, // userid
"e": 100176235.63450066, // equityAmount
"mb": 100193971.94053756, // marginBalance
"delta": "0",
"btcv": 3231.69996885, // btc value
"wb": 100028273.92018174, // canWithdrawPmAmount
"upnl": 109575.94802862 // unrealizedAmount
}
}
Orders
{ "action":"subscribe", "dataType":"order" }
Payload:
Status: 0 NEW
{
"dt": 11,
"c": 20,
"d": {
"coid":1000200000, // Client order id
"oid": 1663004711982333952, // Order id
"uid": "8095151726", // User id
"s": "BTCUSD",// Futures symbol name
"q": "1", // Order Quantity
"pr": "500", // Price
"si": 1, // Trade side > si
"ty": 1, // Trade type > ty
"ct": 1685326195118,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, //Reduce only
"le": 3, // Leverage
"os": 0 //Status NEW
}
}
Status: 1 FILLED
{
"dt": 11,
"c": 20,
"d": {
"oid": 1665910350698258432,// Order ID
"coid": 123123123,// Client order id
"uid": "8095151726", // User id
"s": "BTCUSD-6JUN23-24000-C",// Option symbol name
"rq":"0.5",// Unfilled Quantity
"fq": "0",// Filled Quantity
"q": "0.5",// Order Quantity
"pr": "2095.6",// Price
"mpr": "499", // filled price in this trade
"mq": "0.5", // filled quantity in this trade
"ap": "2095.6",// Average price
"si": 1,// Trade side
"ty": 1,// Trade type
"ct": 1666667584739,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, // Reduce only
"it": 0, // Taker or Maker, 1 TRUE 0 FALSE
"os": 1 // FILLED
}
}
Status: 2 PARTIALLY_FILLED
{
"dt": 11,
"c": 20,
"d": {
"oid": 1665910350698258432,// Order ID
"coid": 123123123,// Client order id
"uid": "8095151726", // User id
"s": "BTCUSD-6JUN23-24000-C",// Option symbol name
"rq":"0.5",// Unfilled Quantity
"fq": "0",// Filled Quantity(accumulated)
"q": "0.5",// Order Quantity
"pr": "2095.6",// Price
"mpr": "499", // filled price in this trade
"mq": "0.5", // filled quantity in this trade
"ap": "2095.6",// Average filled price(accumulated)
"si": 1,// Trade side
"ty": 1,// Trade type
"ct": 1666667584739,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, // Reduce only
"it": 0, // Taker or Maker, 1 TRUE 0 FALSE
"os": 2 // PARTIALLY_FILLED
}
}
Status: 3 CANCELED, 10 CANCEL_BY_EXERCISE
{
"dt": 11,
"c": 20,
"d": {
"oid": 1665910350698258432,// Order ID
"coid": 123123123,// Client order id
"uid": "8095151726", // User id
"s": "BTCUSD-6JUN23-24000-C",// Option symbol name
"cq": "0.5", // Canceled Quantity
"fq": "0",// Filled Quantity(accumulated)
"q": "0.5",// Order Quantity
"pr": "2095.6",// Price
"ap": "2095.6",// Average filled price(accumulated)
"si": 1,// Trade side
"ty": 1,// Trade type
"ct": 1666667584739,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, // Reduce only
"os": 3 // 3 CANCELED, 10 CANCEL_BY_EXERCISE
}
}
Status: 6 INVALID
{
"dt": 11,
"c": 20,
"d": {
"oid": 1665910350698258432,// Order ID
"coid": 123123123,// Client order id
"uid": "8095151726", // User id
"s": "BTCUSD-6JUN23-24000-C",// Option symbol name
"rq":0.5,// Unfilled Quantity
"q": 0.5,// Order Quantity
"fq": 0,// Filled Quantity(accumulated)
"pr": 2095.6,// Price
"ap": 2095.6,// Average filled price(accumulated)
"si": 1,// Trade side
"ty": 1,// Trade type
"ct": 1666667584739,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, // Reduce only
"os": 6 // INVALID
}
}
Positions
{ "action":"subscribe", "dataType":"position", "payload":{ "symbol":"BTCUSD-4JUL23-27000-C" } }
Payload:
{
"dt": 12,
"c": 20,
"d": {
"q": "1", // quantity
"ap": "4274.79", // average price
"im": "0", // Im initMargin
"mm": "0", // Mm maintMargin
"s": "BTCUSD-4JUL23-27000-C", // symbol
"si": "1", // order side
"uid": "8095151726", // user id
"upnl": "-42.79" // Unrealized Pnl
}
}
Futures WebSocket
# Sample code
import hashlib
import hmac
import time
import websocket
import json
import threading
# API INFO
api_key = "YOUR_API_KEY"
api_sec = "YOUR_API_SECRET"
def on_open(ws):
print("WebSocket connection opened.")
# Send a subscribe message after the connection opened.
ws.send(json.dumps({ "action":"subscribe", "dataType":"spotPrice", "payload":{ "symbol":"BTCUSD" } }))
def on_close(ws):
print("WebSocket connection closed.")
def on_error(ws, error):
print(f'WebSocket error: {error}')
def on_message(ws, message):
data = json.loads(message)
print(data)
def get_signed_header(ts):
verb='GET'
uri = '/users/self/verify'
auth = verb + uri + '?uuid=' + api_key + '&ts=' + str(ts)
signature = hmac.new(api_sec.encode('utf-8'), auth.encode('utf-8'), hashlib.sha256).hexdigest()
signature = signature.upper()
return signature
ts = int(time.time()*1000)
sign = get_signed_header(ts)
socket = 'wss://ws.coincall.com/futures?code=10&uuid=' + api_key +'&ts='+ str(ts) +'&sign=' + sign + '&apiKey=' + api_key
ws = websocket.WebSocketApp(socket, on_open=on_open, on_close=on_close, on_error=on_error, on_message=on_message)
def run():
ws.run_forever()
ws_thread = threading.Thread(target=run)
ws_thread.start()
while True:
# Wait for the WebSocket connection to be established
if ws.sock and ws.sock.connected:
# Send heartbeat
msg = {"action":"heartbeat"}
ws.send(json.dumps(msg))
time.sleep(3)
else:
# If the WebSocket connection is not established, wait 3 seconds
time.sleep(3)
WSS interface for futures:
wss://ws.coincall.com/futures
- Connection example:
wss://ws.coincall.com/futures?code=10&uuid=65905c2be07f49e79ac26aca4b0b3988&ts=1687326076897&sign=CF58E8C7BE6C10EF7D8A65F3D0538F7D6C73182C6AFCA26D2CBE2318E085E494&apiKey=7PvIEreC1g5Kd17S7Ei1mEd3ppyuoixhqlzqM0Rqfhw=
- Connection example:
Value of Connection Parameters
Name | Required | Note |
---|---|---|
code | true | 10, build connection |
uuid | false | Custom id by user |
ts | true | Timestamp, 1687326076897 |
sign | true | Signature |
apiKey | true | your api key |
sign: signature string, the signature algorithm is as follows:
First concatenate method + uri + ?uuid=your_api_key&ts=your_timestamp
(where +
represents String concatenation), then use HMAC SHA256 method to encrypt the concatenated string with apiSecret
, and then perform Base64 encoding.
method
: always GET
.
uri
: always /users/self/verify
Data Abbreviations
Please refer to the following field abbreviations for data fields in the futures request/response:
Name | Note |
---|---|
c | code, Operations for Request Protocol Execution |
rc | response code, Status of the Response Protocol |
d | data, Request/Response payload |
p | position, Subscription Data Page Location |
s | symbol |
pr | price |
mp | mark Price |
ip | index Price |
h | price24hHigh, Highest price in 24hrs |
l | price24hLow, Lowest price in 24hrs |
cp | changePrice, Price change in value |
cr | changeRate, Price change in percentage |
pr0 | price24hOpen, Open price on UTC 00:00:00 |
uv24 | volumeUsd24h, USD volume in 24hrs |
v24 | volume24h, Volume in 24hrs |
high | high, The highest price |
low | low, The lowest price |
pe | period, granularity of K-line |
v | volume |
close | close price |
open | open price |
ts | timestamp |
sz | size |
sd | tradeSide, buy or sell |
q | qty, quantity |
fq | filled quantity |
ap | avgPrice, average price |
coid | clientOrderId |
os | order status |
im | initial Margin |
oid | orderId |
si | trade side |
ty | trade type |
uid | userId |
elp | estimated Liquidation Price |
mm | maintenance Margin |
upnl | Unrealized Pnl |
dt | dataType, websocket channels |
ct | createTime |
ro | reduceOnly |
tid | trade ID |
rq | remainQty, Unfilled Quantity |
mpr | match price |
mq | match quantity |
le | leverage |
it | isTaker |
cq | canceled quantity |
HeartBeat
{ "action":"heartbeat" }
Payload:
{
"c":11,
"rc":1 // 1 Success
}
Index Price
{ "action":"subscribe", "dataType":"spotPrice", "payload":{ "symbol":"BTCUSD" } }
Payload:
{
"dt": 30,
"c": 20,
"d": {
"pr": 1.1752, // last price
"mp": 1.17521086, // mark Price
"ip": 1.17550000, // index Price
"h": 1.18070000, // price24hHigh, Highest price in 24hrs
"l": 1.12120000, // price24hLow, Lowest price in 24hrs
"cp": 0.02410000, // changePrice, Price change in value
"cr": 0.0209, // Price change in percentage
"pr0": 1.05768, // price24hOpen, Open price on UTC 00:00:00
"s": "ARBUSD", // symbol
"uv24": 320076.05815000, // volumeUsd24h, USD volume in 24hrs
"v24": 278226.50000000 // volume24h, Volume in 24hrs
}
}
K-line Data
{ "action":"subscribe", "dataType":"kline", "payload":{ "symbol":"BTCUSD", "period":"h1" } }
Value of period
Key | Note |
---|---|
m1 | 1 minute |
m5 | 5 minutes |
m15 | 15 minutes |
m30 | 30 minutes |
h1 | 1 hour |
h4 | 4 hours |
d1 | 1 day |
w1 | 1 week |
mn1 | 1 month |
quarter | 3 months |
Payload:
{
"dt": 31,
"c": 20,
"d": {
"high": 30831.73000000, // The highest price
"s": "BTCUSD", // symbol
"low": 30831.73000000, // The lowest price
"pe": "m1", // period, granularity of K-line
"v": 1.00000000, // volume
"close": 30831.73000000, // close price
"open": 30831.73000000, // open price
"ts": 1688383680000 // timestamp
}
}
OrderBook
{ "action":"subscribe", "dataType":"orderBook", "payload":{ "symbol":"BTCUSD" } }
Message channel for the 100 best ask/bid full data. After subscription, when there are changes in the order book, the system will push the real-time ticker symbol information to you
Payload:
{
"dt": 32,
"c": 20,
"d": {
"s": "BTCUSD", // symbol
"asks": [{
"pr": "30831.73", // price
"sz": "180.30200000" // size
}, {
"pr": "40000",
"sz": "0.40000000 "
}],
"bids": [{
"pr": "1",
"sz": "1 "
}],
"ts": 1688384138863 // timestamp
}
}
Last Trades
{ "action":"subscribe", "dataType":"lastTrade", "payload":{ "symbol":"BTCUSD" } }
Payload:
{
"dt": 33,
"c": 20,
"d": [{
"q": "1", // qty quantity
"sd": 1, // tradeSide
"pr": "30831.73000000", // price
"s": "BTCUSD", // symbol
"ts": 1688436545891 // timestamp
}, {
"q": "83.11100000",
"sd": 1,
"pr": "30139.37000000",
"s": "BTCUSD",
"ts": 1688370059868
}]
}
Orders
{ "action":"subscribe", "dataType":"order" }
Payload:
Status: 0 NEW
{
"dt": 35,
"c": 20,
"d": {
"coid":1000200000, // Client order id
"oid": 1663004711982333952, // Order id
"uid": "8095151726", // User id
"s": "BTCUSD",// Futures symbol name
"q": "1", // Order Quantity
"pr": "500", // Price
"si": 1, // Trade side > si
"ty": 1, // Trade type > ty
"ct": 1685326195118,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, //Reduce only
"le": 3, // Leverage
"os": 0 //Status NEW
}
}
Status: 1 FILLED
{
"dt": 35,
"c": 20,
"d": {
"coid":1000200000, // Client order id
"oid": 1663004711982333952, // Order id
"uid": "8095151726", // User id
"s": "BTCUSD",// Futures symbol name
"q": "1", // Order Quantity
"fq": "1", // Filled Quantity(accumulated)
"rq": "0", // Unfilled Quantity
"pr": "500", // Order Price
"mpr": "499", // filled price in this trade
"mq": "0.5", // filled quantity in this trade
"ap": "0", // Average filled price(accumulated)
"si": 1, // Trade side
"ty": 1, // Trade type
"ct": 1685326195118,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, //Reduce only
"le": 3, // Leverage
"it": 0, // Taker or Maker, 1 TRUE 0 FALSE
"os": 1 // FILLED
}
}
Status: 2 PARTIALLY_FILLED
{
"dt": 35,
"c": 20,
"d": {
"coid":1000200000, // Client order id
"oid": 1663004711982333952, // Order id
"uid": "8095151726", // User id
"s": "BTCUSD",// Futures symbol name
"q": "1", // Order Quantity
"fq": "0.5", // Filled Quantity(accumulated)
"rq": "0.5", // Unfilled Quantity
"pr": "500", // Price
"mpr": "499", // filled price in this trade
"mq": "0.5", // filled quantity in this trade
"ap": "0", // Average filled price(accumulated)
"si": 1, // Trade side
"ty": 1, // Trade type
"ct": 1685326195118,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, //Reduce only
"le": 3, // Leverage
"it": 0, // Taker or Maker, 1 TRUE 0 FALSE
"os": 2 // PARTIALLY_FILLED
}
}
Status: 3 CANCELED
{
"dt": 35,
"c": 20,
"d": {
"coid":1000200000, // Client order id
"oid": 1663004711982333952, // Order id
"uid": "8095151726", // User id
"s": "BTCUSD",// Futures symbol name
"q": "1", // Order Quantity
"fq": "0.5", // Filled Quantity(accumulated)
"cq": "0.5", // Canceled Quantity
"pr": "500", // Price
"ap": "0", // Average filled price(accumulated)
"si": 1, // Trade side
"ty": 1, // Trade type
"ct": 1685326195118,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, // Reduce only
"le": 3, // Leverage
"os": 3 // CANCELED
}
}
Status: 6 INVALID
{
"dt": 35,
"c": 20,
"d": {
"coid":1000200000, // Client order id
"oid": 1663004711982333952, // Order id
"uid": "8095151726", // User id
"s": "BTCUSD",// Futures symbol name
"q": "1", // Order Quantity
"fq": "0.5", // Filled Quantity(accumulated)
"rq": "0.5", // Unfilled Quantity
"pr": "500", // Price
"ap": "0", // Average filled price(accumulated)
"si": 1, // Trade side
"ty": 1, // Trade type
"ct": 1685326195118,// Time of the order created
"ts": 1685326195118,// Time of this event
"ro": 0, // Reduce only
"le": 3, // Leverage
"os": 6 // INVALID
}
}
Positions
{ "action":"subscribe", "dataType":"position" }
Payload:
{
"dt": 36,
"c": 20,
"d": {
"q": "4", // filled quantity
"ap": "0.3435", // average price
"elp": "-20963.68918261", // Elp estimated Liquidation Price
"im": "0.458", // initMargin
"mm": "0.04122", // maintMargin
"mp": "0.3435", // mark price
"s": "FTMUSD", // symbol
"si": "1", // order side
"uid": "8095151726", // user id
"upnl": "0" // Unrealized Pnl
}
}
Referrals
Referrals Record(SIGNED)
Get referrals record
Response:
{
"code": 0,
"msg": null,
"data": {
"list": [
{
"inviteeUserId": 9804700, // User ID of invitee
"level": 0, // 0 user, 1 sub-agent
"commissions": 0, // Commission earned from this user himself and his invitees
"verification": 0, // 0 false, 1 true
"deposit": 0, // 0 false, 1 true
"futures": 1, // 0 false, 1 true
"options": 0, // 0 false, 1 true
"regTime": 1675845379145 // Time of registration (ms)
}
],
"pageTotal": 2,
"total": 14
}
}
HTTP Request
GET https://api.coincall.com/open/referral/sub/v1
Parameter
Name | Type | Value | Required | Note |
---|---|---|---|---|
subAgentId | integer | 9905700 | false | |
page | integer | 1,2,3 | false |
Notice
subAgentId
UID of the sub-agent; if it is not passed, it will return all invitees, and if it is passed, it will return the invitees of the user and the user itself.
This parameter only used for sub agent, please make sure your account type is a sub agent for coincall, or you will get an error code:10004.
Error Codes
The Coincall API uses the following error codes:
Codes | Description |
---|---|
0 | Success |
500 | Internal servererror |
2015 | User does not exist. |
2016 | Public key not exist |
2017 | Private key not exist |
4002 | Token expired. |
4003 | Token auth fail. |
4004 | Token kicke out. |
4005 | Duplicate request. |
4006 | This country or region is not supported |
7001 | No Permission. |
10000 | Try again later |
10001 | This operation is not allowed |
10002 | Result api system error |
10003 | Result api resquest illegal |
10004 | Parameter illegal |
10005 | Parameter error |
10006 | Sign illegal |
10007 | Token is error |
10008 | IP illegal |
10009 | Request method not support |
10010 | Param illegal |
10101 | Result header build error |
10102 | Query exception |
10103 | System inner error |
10104 | Params is null |
10105 | Params is blank |
10106 | Param long is blank |
10107 | Param integer is blank |
10108 | Params type error |
10500 | Incorrect or expired email verification code. |
10501 | Incorrect 2FA code. |
10502 | Please enter email verification code. |
10503 | Please enter 2FA code. |
10504 | You are not able to withdraw funds because of the abnormal status of this account. |
10505 | Invalid email address. |
10506 | Please enter your password |
10507 | Must be at least 8 characters . |
10508 | Invalid email address. |
10509 | Please enter your password |
10510 | Must be at least 8 characters . |
10511 | Must not exceed 32 characters. |
10512 | Must contain at least one number (0-9). |
10513 | Must contain at least one special character (!@#$%^&*). |
10514 | The passwords do not match. |
10515 | Please enter correct referral code. |
10516 | Please select a country or region. |
10517 | Please agree to the Terms of Service . |
10518 | Incorrect or expired email verification code. |
10519 | Account blocked |
10520 | Invalid account or password, 5-n attempts remaining. |
10521 | Your account has been restricted to log in. |
10522 | Please enter the email verification code |
10523 | Please enter the 2FA code |
10524 | Incorrect 2FA code. |
10525 | Position the piece in its slot |
10526 | Please enter 2FA code |
10527 | Incorrect the 2FA code. |
10528 | Incorrect password. |
10529 | Insufficient available balance. |
10530 | Please enter price |
10531 | Order price is higher than the maximum limit {0}. |
10532 | Order price is lower than the minimum limit {0}. |
10533 | Please enter amount |
10534 | Order size exceeds the maximum limit per order. |
10535 | The number of orders exceeds the maximum limit. |
10536 | Insufficient open positions. |
10537 | Order cancellation failed. |
10538 | Order IV is higher than the maximum limit 500%. |
10539 | Order IV is lower than the minimum limit 50%. |
10540 | Order has expired. |
10541 | The number of stop orders exceeds the maximum limit. |
10542 | Please enter stop price |
10543 | Please enable the 2FA code . |
10544 | Only 10 APIKeys can be created per account. |
10545 | Must not exceed 128 characters. |
10546 | Please enter a name. |
10547 | This name is already used. |
10548 | Each APIKey can bind up to 20 IP addresses. |
10549 | Invalid IP address. |
10550 | Please enter email verification code. |
10551 | The IP address is not in whitelist. |
10552 | Operation failed. |
10553 | The server is under maintenance, please try again later. |
10554 | You are not authorized to execute this request. |
10555 | API frozen |
10556 | APIKey does not match current environment. |
10557 | Timestamp request expired. |
10560 | Invalid CC-ACCESS-KEY. |
10561 | Invalid CC-ACCESS-TIMESTAMP. |
10562 | Invalid signature. |
10563 | Invalid authorization. |
10564 | Invalid request method. |
10565 | Endpoint request timeout |
10566 | API is offline or unavailable. |
10567 | Invalid content_type. |
10568 | Account does not exist. |
10569 | User ID cannot be empty. |
10570 | Parameter {0} cannot be empty. |
10571 | Parameter {0} does not match parameter {1}. |
10572 | Parameter {0} count exceeds the limit |
10573 | Parameter {0} error. |
10574 | Instrument ID does not exist. |
10575 | Either client order ID or order ID is required. |
10576 | Duplicated order ID. |
10577 | Duplicated client order ID. |
10578 | Token does not exist. |
10579 | Index does not exist. |
10580 | Instrument ID does not match instrument type. |
10581 | Position does not exist. |
10582 | Order timed out, please try again later. |
10583 | Cancellation timed out, please try again later. |
10584 | Order does not exist. |
10585 | Either order status or order ID is required. |
10586 | Channel subscription failed. |
10587 | Login failed. |
10588 | Please log in. |
10589 | Invalid request. |
10590 | Invalid args. |
10591 | Invalid url path. |
10592 | The {0} does not exist. |
10593 | Invalid op {0} |
10594 | Wrong passphrase |
10595 | Token subscription amount exceeds the limit |
10596 | Internal system error. |
10597 | Maximum receive of friends is XX%. |
10598 | The number of referral links exceeds the maximum limit. |
10599 | Please enter your name/date of birth/address |
10600 | Name contains numbers or symbols. |
10601 | Please select the type of address proof. |
10602 | Please upload the file |
10603 | File is too large, upload failed. |
10604 | The format of this file is not supported. |
10605 | Operation is too frequent. |
10606 | The number of exports this month exceeds the maximum limit. |
10607 | File not exists |
10608 | File expired |
10609 | You are not able to trade temporarily because the contract is abnormal. |
20000 | Coin not exist |
20001 | Account not found |
20002 | Coin not support |
20003 | User not found |
20004 | Please enable the 2FA code. |
20005 | Please select withdrawal coin. |
20006 | Please select withdrawal network. |
20007 | Please enter withdrawal address. |
20008 | Withdrawal network does not match the withdrawal address. |
20009 | Please enter an amount. |
20010 | Insufficient withdrawable balance. |
20011 | Exceed the 24 hours limit of withdrawal. |
20012 | Minimum withdrawal amount is 20 USDC. |
20013 | You are not able to withdraw funds within 24 hours after changing the password. |
20014 | Send code fail |
20015 | User not exist |
20016 | Sub user not allowed withdraw |
20018 | User withdraw restricted |
20020 | Not found withdraw record |
20021 | Not your withdraw record |
20022 | Not supported cancel, now is processing or completed |
20023 | not supported cancel, now is processing |
20024 | Account create fail |
20025 | Account update fail |
20027 | Target mode equals origin mode |
20028 | Option pending order exsist |
20029 | Option hold position exsist |
20030 | Future pending order exsist |
20031 | Future hold position exsist |
20032 | You need to transfer remainning funds to main account or other sub accounts |
20033 | Send code fail |
20034 | Start time and end time range exceeds three months |
30000 | User illegal |
30001 | Token illegal |
30002 | Check fail |
30003 | Google verification code is wrong |
30004 | Verification code is wrong |
40001 | User is freezed |
40002 | User over login max times |
40003 | Operate code timeout |
40004 | Token error |
40005 | Too many failed attempts, and your account has been locked |
40006 | Error fund transfer type, transfer sub account's parent user wrong |
40007 | Error fund transfer type, transfer to user must be sub account |
40008 | Transfer trade type is invalid |
40009 | Transfer amount exceeds can withdraw balance amount |
40010 | Error fund transfer type, transfer from user must be sub account |
40011 | Sub account size limit |
40012 | User name already used |
40013 | Email already used |
40014 | Sub account id error |
40015 | Referral not found |
40016 | Invite commission rate add invitee commission rate not equals referral total commission rate |
40017 | Company info is exist |
40018 | Age less than 18 |
40019 | Company info not exist |
40020 | Jumio workflow not exist error |
40021 | Age format is error |
40022 | Kyc user status error |
40023 | Kyc user check error |
40024 | Upgrade error |
40025 | Check rate error |
40026 | Get temp url error |
40027 | Two grade auth error |
40028 | One grade step1 save error |
40029 | One grade save error |
40030 | Jumio user reference change |
40031 | Kyc processing |
40032 | Jumio status not exist |
40033 | Jumio status enum is not exist |
40034 | Option not exist |
40035 | Price illegal |
40036 | Volume illegal |
40037 | IM more than 100% |
40038 | You are not able to adjust leverage due to existing open positions or pending orders in the account. |
40039 | The price exceeds the maximum limit {0} |
40040 | File size limit |
40041 | Upload file frequently |
40042 | File type is unknow |
40043 | File type is error |