API documentation

Our python wrapper of the APIs can be found here: https://github.com/coinut/coinut_api

APIs that require no authentication

Tick

Request
GET https://coinut.com/api/tick/{asset}
Reply
{"timestamp": 1423645692104470, "symbol": "BTCUSD", "tick": "221.162058"}

Assets

Request
POST https://coinut.com/api/assets
with payload
{
  "deriv_type" : "VANILLA_OPTION"
}
Reply
["BTCUSD", "BTCCNY", "BTCEUR"]
deriv_type may be one of the following
  • VANILLA_OPTION
  • BINARY_OPTION

Expiry time

Request
POST https://coinut.com/api/expiry_time
with payload
{
  "deriv_type" : "VANILLA_OPTION"
  "asset": "BTCUSD"
}
Reply
[1423656000, 1423670400, 1423684800, 1423699200, 1423713600, 1423728000]

Strike prices

Request
POST https://coinut.com/api/strike_prices
with payload
{
  "deriv_type" : "VANILLA_OPTION",
  "asset": "BTCUSD",
  "expiry_time": 1423656000
}
Reply
["2.00000000", "4.00000000", "6.00000000", "8.00000000", "10.00000000",...]

Orderbook

Request
POST https://coinut.com/api/orderbook
with payload
{
  "deriv_type": "VANILLA_OPTION",
  "asset": "BTCUSD",
  "expiry_time": 1423656000,
  "strike": "250",
  "put_call": "CALL"
}
Reply
{
  "ask":[],
  "bid":[
    {
      "amount":10,
      "price":"0.10000000"
    },
    {
      "amount":120,
      "price":"0.00300000"
    },
    {
      "amount":20,
      "price":"0.00100000"
    }
  ]
}

APIs that require authentication

The following API requests need to be authenticated. To authenticate, you need to put your username and signature in the HTTP header part:
X-USER: < your username >
X-SIGNATURE: HMAC-SHA256(< your api key>, payload)
Your API key can be found on the Profile page, and you should never disclose it to anyone else. To verify your HMAC-SHA256 function, check this example
HMAC-SHA256('bb8a56ceabe7e247fe0b32205e6fce26aac5', 'coinut') = 'ac9315dccd191d097a36c7db5b2d633091c0034708c2b1cb340ae8aaccd79830'
The payloads for APIs that require authentication are JSON dictionaries. For your security, we strongly suggest that you put a nonce field in the dictionary with a random string value.

Balance

Request
POST https://coinut.com/api/balance
with payload
{
  "nonce":"4fafd1e4bc1249e798aebb398d58e4e8"
}
Reply
{
  "margin":"2.00200000",
  "balance":"111.14315000",
  "free_margin":"109.14115"
}

Open new orders

Request
POST https://coinut.com/api/new_orders
with payload
{
  "nonce": "a4a1633d4d174ff69b3d141f5b23bb6d", 
  "orders": [
    {
      "put_call": "CALL", 
      "expiry_time": 1423713600, 
      "asset": "BTCUSD", 
      "strike": "230", 
      "amount": 5, 
      "price": "0.005", 
      "open_close": "OPEN", 
      "type": "LIMIT", 
      "deriv_type": "BINARY_OPTION", 
      "side": "BUY"
    }, 
    {
      "put_call": "CALL", 
      "expiry_time": 1423742400, 
      "asset": "BTCUSD", 
      "strike": "250", 
      "amount": 5, 
      "price": "0.5", 
      "open_close": "OPEN", 
      "type": "LIMIT", 
      "deriv_type": "VANILLA_OPTION", 
      "side": "BUY"
    }
  ]
}
Reply
[
  {
    "status": "ORDER_OPEN", 
    "put_call": "CALL", 
    "expiry_time": 1423713600, 
    "timestamp": 1423664086, 
    "price": "0.00500000", 
    "open_close": "OPEN", 
    "deriv_type": "BINARY_OPTION", 
    "side": "BUY", 
    "amount": 5, 
    "asset": "BTCUSD", 
    "strike": "230.00000000", 
    "type": "LIMIT", 
    "id": "c674382ba3234242e00a627075c15aa0aa32"
  }, 
  {
    "status": "ORDER_OPEN", 
    "put_call": "CALL", 
    "expiry_time": 1423742400, 
    "timestamp": 1423664086, 
    "price": "0.50000000", 
    "open_close": "OPEN", 
    "deriv_type": "VANILLA_OPTION", 
    "side": "BUY", 
    "amount": 5, 
    "asset": "BTCUSD", 
    "strike": "250.00000000", 
    "type": "LIMIT", 
    "id": "f266110ba7fe224bd409b970ab501d7f0cfc"
  }
]
  • To open new positions, open_close needs to be OPEN
  • type can be either LIMIT or MARKET.
  • status can be one of the following:
    • ORDER_OPEN
    • ORDER_FAILED
    • ORDER_INVALID
    • ORDER_NOT_ENOUGH_BALANCE
  • Once an order is partially filled, it will be canceled, and a new order with a different id with the remaining unfilled amount will be generated. The origin_id of the new order records the original order's id.
  • Orders cannot be changed. To change an order, you need to cancel it and then submit a new order.

List all open orders

Request
POST https://coinut.com/api/orders
with payload
{
  "nonce":"e2477f94acfc0246f80b488082aa9f77963c"
}
Reply
[
  {
    "status": "ORDER_OPEN", 
    "put_call": "CALL", 
    "expiry_time": 1423713600, 
    "timestamp": 1423664303, 
    "price": "0.00500000", 
    "open_close": "OPEN", 
    "deriv_type": "BINARY_OPTION", 
    "side": "BUY", 
    "amount": 5, 
    "asset": "BTCUSD", 
    "strike": "230.00000000", 
    "type": "LIMIT", 
    "id": "ce29f99ea62ac2423b0bc4a0a4f71598bde7"
  }, 
  {
    "status": "ORDER_OPEN", 
    "put_call": "CALL", 
    "expiry_time": 1423742400, 
    "timestamp": 1423664303, 
    "price": "0.50000000", 
    "open_close": "OPEN", 
    "deriv_type": "VANILLA_OPTION", 
    "side": "BUY", 
    "amount": 5, 
    "asset": "BTCUSD", 
    "strike": "250.00000000", 
    "type": "LIMIT", 
    "id": "f6475b2aa3d64247e50854c0ad76cbb92b38"
  }, 
  {
    "status": "ORDER_OPEN", 
    "put_call": "CALL", 
    "expiry_time": 1423670400, 
    "timestamp": 1423664297, 
    "price": "0.30000000", 
    "open_close": "OPEN", 
    "deriv_type": "VANILLA_OPTION", 
    "side": "BUY", 
    "amount": 1, 
    "asset": "BTCUSD", 
    "strike": "224.00000000", 
    "type": "LIMIT", 
    "id": "1ec68900a751b245b00be3d052abb75b6c91"
  }
]

Cancel orders

Request
POST https://coinut.com/api/cancel_orders
with payload
{
  "nonce": "481a017c8d9a47c1afeee8fae21d1f5e", 
  "order_ids": [
    "54780bdaa0a2624f33097150174e292e3201",
    "b0d82ef9a440924a210821b0d9c42fc1a20a",  
  ]
}
Reply
[
  {
    "status":"ORDER_CANCELED",
    "put_call":"CALL",
    "expiry_time":1423713600,
    "timestamp":1423664430,
    "price":"0.00500000",
    "open_close":"OPEN",
    "deriv_type":"BINARY_OPTION",
    "side":"BUY",
    "amount":5,
    "asset":"BTCUSD",
    "strike":"230.00000000",
    "type":"LIMIT",
    "id":"54780bdaa0a2624f33097150174e292e3201"
  },
  {
    "status":"ORDER_CANCELED",
    "put_call":"CALL",
    "expiry_time":1423742400,
    "timestamp":1423664430,
    "price":"0.50000000",
    "open_close":"OPEN",
    "deriv_type":"VANILLA_OPTION",
    "side":"BUY",
    "amount":5,
    "asset":"BTCUSD",
    "strike":"250.00000000",
    "type":"LIMIT",
    "id":"b0d82ef9a440924a210821b0d9c42fc1a20a"
  }
]

List all open positions

Request
POST https://coinut.com/api/positions
with payload
{
  "nonce":"5a352144a2c9b24675098310b7ef9c720ede"
}
Reply
[
  {
    "status": "POSITION_OPEN", 
    "put_call": "CALL", 
    "close_time": 0, 
    "expiry_time": 1423670400, 
    "open_time": 1423664943, 
    "timestamp": 1423664943, 
    "price": "0.05000000", 
    "deriv_type": "VANILLA_OPTION", 
    "side": "BUY", 
    "amount": 1, 
    "asset": "BTCUSD", 
    "strike": "222.00000000", 
    "close_price": "0.00000000", 
    "id": "b5ae7d46ab1fc24e5b08ab505e803ac15aba"
  }
]

Close Positions

Positions can be closed using either market or limit orders.

Request
POST https://coinut.com/api/new_orders
with payload
{
  "nonce": "67b2d13d34ac4df1aeb3a1e816050c7a", 
  "orders": [
    {
      "price": "0.005", 
      "amount": 1, 
      "open_close": "CLOSE", 
      "type": "LIMIT", 
      "close_position_id": "b5ae7d46ab1fc24e5b08ab505e803ac15aba"
    }
  ]
}
Reply
[
  {
    "status": "ORDER_OPEN", 
    "put_call": "CALL", 
    "close_position_id": "b5ae7d46ab1fc24e5b08ab505e803ac15aba", 
    "expiry_time": 1423670400, 
    "timestamp": 1423669025, 
    "price": "0.00500000", 
    "open_close": "CLOSE", 
    "deriv_type": "VANILLA_OPTION", 
    "side": "SELL", 
    "amount": 1, 
    "asset": "BTCUSD", 
    "strike": "222.00000000", 
    "type": "LIMIT", 
    "id": "c32be23da5c0b248b308d210d4cce3809200"
  }
]

History Positions

Request a list of closed positions Request
POST https://coinut.com/api/history_positions
with payload
{
  "nonce":"67b2d13d34ac4df1aeb3a1e816050c7a",
  "start_timestamp":0,
  "end_timestamp":1423697392
}
Reply
[
  {
    "status": "POSITION_CLOSED", 
    "put_call": "CALL", 
    "close_time": 1418284847, 
    "expiry_time": 1418284800, 
    "open_time": 1418283462, 
    "timestamp": 1418284847, 
    "price": "0.00077000", 
    "deriv_type": "BINARY_OPTION", 
    "side": "SELL", 
    "amount": 1,
    "underlying_price": "358.87123703",     
    "asset": "BTCUSD", 
    "strike": "356.00000000", 
    "close_price": "0.00000000", 
    "id": "fff315a9a4044247dd0838e05d704e3a4ca5"
  }, 
  {
    "status": "POSITION_CLOSED", 
    "put_call": "CALL", 
    "close_time": 1418284898, 
    "expiry_time": 1418284800, 
    "open_time": 1418281951, 
    "timestamp": 1418284899, 
    "price": "0.00967000", 
    "deriv_type": "BINARY_OPTION", 
    "side": "SELL", 
    "amount": 1,
    "underlying_price": "358.87123703", 
    "asset": "BTCUSD", 
    "strike": "352.00000000", 
    "close_price": "0.00000000", 
    "id": "fff93185a16c5240290b5aa06916ae1398cc"
  }
]

If a position is exercised, underlying_price indicates the price of the underlying asset at the time of expiration. If it is closed by a close order, close_price is the price at which the position is closed.

Errors

If a request fails, an error message will be returned
{ "error" : "AUTHENTICATION ERROR" }
Possible errors are:
  • AUTHENTICATION ERROR
  • SYNTAX ERROR
  • INVALID REQUEST
  • INVALID ASSET
  • SERVER ERROR
  • UNKNOWN ERROR
Please also make sure your requests are within 4 Mb. Requests larger than that will receive a 413 HTTP error.