NAV Navbar
ruby python go
  • API
  • Authentication
  • Private
  • Public
  • Websocket Feed
  • FIX API
  • API

    Welcome to the CoinFalcon API documentation.

    Here you will find everything you need to working with the CoinFalcon API. To get started, go to your applications page in your account settings to generate your key and secret.

    Status codes

    Status code Reason
    200 Successful response
    400 Bad Request – Invalid request format
    401 Unauthorized – Authentication error
    403 Forbidden – You do not have access to the requested resource
    404 Not Found
    429 Too Many Requests
    500 Internal Server Error – We had a problem with our server

    Limits

    When a rate limit is exceeded, a status of 429 API rate limit exceeded for IP will be returned.

    PUBLIC ENDPOINTS

    We throttle public endpoints by IP: 3 requests per second.

    PRIVATE ENDPOINTS

    We throttle private endpoints by user ID: 3 requests per second.

    Authentication

    Headers

    All private REST requests must contain the following headers:

    CF-API-KEY The api key as a string.

    CF-API-TIMESTAMP A timestamp for your request, 10 digital.

    CF-API-SIGNATURE The signature for your request (see Signing a Message).

    All request bodies should have content type application/json and be valid JSON.

    Signing a message

    To generate a signature, use this code, the get_signature method:

    require 'awesome_print'
    require 'rest-client'
    require 'json'
    require 'pry'
    
    class CoinfalconExchange
      def initialize(key, secret)
        @key = key
        @secret = secret
        @end_point = 'https://coinfalcon.com/api/v1/'
      end
    
      def headers(request_path, body, method)
        timestamp = Time.now.to_i
        signature = get_signature(timestamp, request_path, body, method)
        ap signature
        {
            "CF-API-KEY" => @key,
            "CF-API-TIMESTAMP" => timestamp,
            "CF-API-SIGNATURE" => signature
        }
      end
    
      def get_signature(timestamp, request_path='', body={}, method='GET')
        # Example for get
        # request_path = '/api/v1/user/orders'
        # timestamp = 1513411769
        # method = 'GET'
        # payload = '1513411769|GET|/api/v1/user/orders'
    
        # Example for post
        # request_path = '/api/v1/user/orders'
        # timestamp = 1513411657
        # method = 'POST'
        # body {market: 'IOT-BTC', operation_type: 'market_order', order_type: 'buy', size: '1'}
        # payload = '1513411657|POST|/api/v1/user/orders|{"market":"IOT-BTC","operation_type":"market_order","order_type":"buy","size":"1"}'
    
        if method == 'GET'
          payload = [timestamp, method, request_path].join("|")
        else
          body = URI.unescape(body.to_json) if body.is_a?(Hash)
          payload = [timestamp, method, request_path, body].join("|")
        end
    
        puts payload
        # create a sha256 hmac with the secret
        OpenSSL::HMAC.hexdigest('sha256', @secret, payload)
      end
    
      def accounts
        url = @end_point + "user/accounts"
        result = RestClient.get(url, headers(URI(url).request_uri, {}, 'GET'))
        JSON.parse(result.body)
      end
    
      def orderbook(market)
        url = @end_point + "markets/#{market}/orders"
        JSON.parse(RestClient.get(url).body)
      end
    
      def my_orders
        url = @end_point + "user/orders"
        result = RestClient.get(url, headers(URI(url).request_uri, {}, 'GET'))
        JSON.parse(result.body)
      end
    
      def my_trades
    
      end
    
      def create_order(body)
        url = @end_point + "user/orders"
        result = RestClient.post(url, body,headers(URI(url).request_uri, body, 'POST'))
        JSON.parse(result.body)
      end
    
      def order(id)
        url = @end_point + "user/orders/#{id}"
        result = RestClient.get(url, headers(URI(url).request_uri, {}, 'GET'))
        JSON.parse(result.body)
      end
    
      def cancel_order(id)
        url = @end_point + "user/orders/#{id}"
        begin
          result = RestClient.delete(url, headers(URI(url).request_uri, {}, 'DELETE'))
          JSON.parse(result.body)
        rescue RestClient::ExceptionWithResponse => e
          JSON.parse(e.response.body)
        end
      end
    
      def deposit_address(currency)
        url = @end_point + "account/deposit_address?currency=#{currency}"
        result = RestClient.get(url, headers(URI(url).request_uri, {}, 'GET'))
        JSON.parse(result.body)
      end
    
      def deposits(query = {})
        url = @end_point + "account/deposits?#{URI.encode_www_form(query)}".chomp('?')
        result = RestClient.get(url, headers(URI(url).request_uri, {}, 'GET'))
        JSON.parse(result.body)
      end
    
      def deposit(id)
        url = @end_point + "account/deposit/#{id}"
        result = RestClient.get(url, headers(URI(url).request_uri, {}, 'GET'))
        JSON.parse(result.body)
      end
    
      def create_withdrawal(body)
        url = @end_point + "account/withdraw"
        result = RestClient.post(url, body,headers(URI(url).request_uri, body, 'POST'))
        JSON.parse(result.body)
      end
    
      def withdrawals(query = {})
        url = @end_point + "account/withdrawals?#{URI.encode_www_form(query)}".chomp('?')
        result = RestClient.get(url, headers(URI(url).request_uri, {}, 'GET'))
        JSON.parse(result.body)
      end
    
      def withdrawal(id)
        url = @end_point + "account/withdrawal?id=#{id}"
        result = RestClient.get(url, headers(URI(url).request_uri, {}, 'GET'))
        JSON.parse(result.body)
      end
    
      def cancel_withdrawal(id)
        url = @end_point + "account/withdrawals/#{id}"
        result = RestClient.delete(url, headers(URI(url).request_uri, {}, 'DELETE'))
        JSON.parse(result.body)
      end
    
    end
    
    #staging
    #client = CoinfalconExchange.new('70b23c92-51df-413d-8d2d-73504d85e2df', '0b63546f-983e-48ac-bed7-10e4d4a0dfed')
    
    #development
    client = CoinfalconExchange.new('3b47b2f1-059f-4091-8cd6-50c7d7a3413d', 'cbac30d1-f014-4758-8250-699659f13772')
    
    # ap client.orderbook('IOT-BTC')
    # ap client.my_orders
    # ap client.accounts
    #result = client.create_order({market: 'BTC-EUR', operation_type: 'market_order', order_type: 'sell', size: '0.01'})
    #ap result
    #ap client.order(result['data']['id'])
    #ap client.cancel_order(result['data']['id'])
    # ap client.deposit_address('btc')
    #result = client.create_withdrawal({amount: '0.001', address: 'mszGuGEdvkRsnFaTymW9LHiMan1qcPH4wn', currency: 'btc'})
    # ap client.withdrawal('9b25877a-35ae-4812-8d89-953ed4c55094')
    # ap client.withdrawals(currency: 'btc', status: 'completed')
    #ap result
    #ap client.cancel_withdrawal(result['data']['id'])
    # ap client.deposits(currency: 'btc', status: 'completed')
    # ap client.deposit('e30a3ac8-33b1-46ed-8f54-1112417de581')
    
    # -*- coding: utf-8 -*-
    
    import hashlib
    import requests
    import urllib
    import urllib.parse
    import json
    import hmac
    import time
    
    class Coinfalcon():
    
        def __init__(self, key, secret):
            self.key = key
            self.secret = secret
            #self.endpoint = 'https://coinfalcon.com/api/v1'
            self.endpoint = 'http://localhost:3000/api/v1'
    
        def request_path(self, url):
            query = urllib.parse.urlparse(url).query
            if query == '':
                return urllib.parse.urlparse(url).path
            return urllib.parse.urlparse(url).path + '?' + query
    
        def get_headers(self, method, request_path, body={}):
            timestamp = str(int(time.time()))
    
            if method == 'GET':
                payload = '|'.join([timestamp, method, request_path])
            else:
                payload = '|'.join([timestamp, method, request_path, json.dumps(body, separators=(',', ':'))])
    
            print(payload)
            message = bytes(payload, 'utf-8')
            secret = bytes(self.secret, 'utf-8')
    
            signature = hmac.new(secret, message, hashlib.sha256).hexdigest()
            return {
                "CF-API-KEY": self.key,
                "CF-API-TIMESTAMP": timestamp,
                "CF-API-SIGNATURE": signature
            }
    
        def create_order(self, body):
            url = self.endpoint + "/user/orders"
            headers = self.get_headers('POST', urllib.parse.urlparse(url).path, body)
            return requests.post(url, headers=headers, data=body).json()
    
        def cancel_order(self, id):
            url = self.endpoint + "/user/orders/{}".format(id)
            print(url)
            headers = self.get_headers('DELETE', urllib.parse.urlparse(url).path, {})
            return requests.delete(url, headers=headers).json()
    
        def my_orders(self):
            url = self.endpoint + "/user/orders"
            headers = self.get_headers('GET', urllib.parse.urlparse(url).path)
            return requests.get(url, headers=headers).json()
    
        def deposit_address(self, currency):
            url = self.endpoint + "/account/deposit_address?currency={}".format(currency)
            headers = self.get_headers('GET', self.request_path(url))
            return requests.get(url, headers=headers).json()
    
        def orderbook(self, market):
            url = self.endpoint + "/markets/{}/orders".format(market)
            print(url)
            print(requests.get(url).text)
            return requests.get(url).json()
    
    #need use your own key && secret
    client = Coinfalcon('3b47b2f1-059f-4091-8cd6-50c7d7a3413d', 'cbac30d1-f014-4758-8250-699659f13772')
    #print(client.orderbook('IOT-BTC'))
    #print(client.my_orders())
    #result = client.create_order({'market': 'BTC-EUR', 'operation_type': 'market_order', 'order_type': 'sell', 'size': '0.1'})
    #print(result)
    #print(client.cancel_order(result['data']['id']))
    print(client.deposit_address('btc'))
    

    The CF-API-SIGNATURE header is generated by creating a sha256 HMAC using the secret key on the prehash string. If get, use timestamp|method|requestPath. If post, use timestamp|method|requestPath|body.to_json.

    Private

    Accounts

    The above command returns JSON structured like this:

    {
      "data": [
        {
          "id": "12345678-1234-1234-1234-123456789012",
          "balance": "0.0",
          "available_balance": "0.0",
          "hold_balance": "0.0",
          "currency_code": "usdt",
          "currency_name": "TetherUS"
        },
        {
          "id": "12345678-1234-1234-1234-123456789012",
          "balance": "0.0",
          "available_balance": "0.0",
          "hold_balance": "0.0",
          "currency_code": "btc",
          "currency_name": "Bitcoin"
        }
      ]
    }
    

    Get a list of your trading accounts.

    HTTP Request

    GET https://coinfalcon.com/api/v1/user/accounts

    FUNDS ON HOLD

    When you place an order, the funds for the order are placed on hold. They cannot be used for other orders or withdrawn. Funds will remain on hold until the order is filled or canceled.

    Create Order

    The above command returns JSON structured like this:

    {
        "data": {
            "id": "4cc9835d-3aad-4e3b-aa76-538e6f18247a",
            "market": "ETH-BTC",
            "price": "0.03993",
            "size": "1.0",
            "size_filled": "0.0",
            "fee": "0.0",
            "funds": "0.03993",
            "status": "pending",
            "order_type": "buy",
            "post_only": false,
            "operation_type": "limit_order",
            "created_at": "2017-11-03T08:46:14.354945Z"
        }
    }
    

    You can place different types of orders: limit, market. Orders can only be placed if your account has sufficient funds. Once an order is placed, your account funds will be put on hold for the duration of the order. How much and which funds are put on hold depends on the order type and parameters specified.

    HTTP Request

    POST https://coinfalcon.com/api/v1/user/orders

    Query Parameters

    Parameter Default Description
    market required Create order for specific market e.g. BTC-EUR
    operation_type required market_order or limit_order
    order_type required buy or sell left currency of market

    Limit order

    Parameter Default Description
    size required Amount of currency to buy or sell
    price required Set the price for limit_order
    post_only* optional 'true' or 'false'

    Market order

    Parameter Default Description
    size* optional Desired amount in currency
    funds* optional Desired amount of quote currency to use

    Get Order

    The above command returns JSON structured like this:

    {
        "data": {
                        "id": "a7ed361d-bf39-4b70-a456-e18eadc1b494",
                    "market": "BTC-EUR",
                     "price": "7263.0",
                      "size": "0.01",
               "size_filled": "0.0",
                       "fee": "0.0",
                     "funds": "0.01",
                    "status": "open",
                "order_type": "sell",
                 "post_only": false,
            "operation_type": "limit_order",
                "created_at": "2018-02-04T05:07:59.801504Z"
        }
    }
    

    Get order details by id.

    HTTP Request

    GET https://coinfalcon.com/api/v1/user/orders/:id

    Path Parameters

    Parameter Default Description
    id required Order id

    Cancel Order

    The above command returns JSON structured like this:

    {
        "data": {
                        "id": "a7ed361d-bf39-4b70-a456-e18eadc1b494",
                    "market": "BTC-EUR",
                     "price": "7263.0",
                      "size": "0.01",
               "size_filled": "0.0",
                       "fee": "0.0",
                     "funds": "0.01",
                    "status": "canceled",
                "order_type": "sell",
                 "post_only": false,
            "operation_type": "limit_order",
                "created_at": "2018-02-04T05:07:59.801504Z"
        }
    }
    

    Cancel a previously placed order.

    HTTP Request

    DELETE https://coinfalcon.com/api/v1/user/orders/:id

    Path Parameters

    Parameter Default Description
    id required Order id

    List Orders

    The above command returns JSON structured like this:

    {
        "data": [
            {
                "id": "a7ed361d-bf39-4b70-a456-e18eadc1b494",
                "market_name": "BTC-EUR",
                "price": "6420.0",
                "size": "0.1",
                "size_filled": "0.1",
                "fee": "0.00025",
                "funds": "642.0",
                "status": "fulfilled",
                "order_type": "buy",
                "post_only": false,
                "operation_type": "market_order",
                "created_at": "2017-11-06T09:54:42.723945Z"
            },
            {
                "id": "de45bc37-7440-40a3-b5ba-a08dc463e387",
                "market_name": "BTC-EUR",
                "price": "6419.0",
                "size": "0.1",
                "size_filled": "0.1",
                "fee": "0.00025",
                "funds": "641.9",
                "status": "fulfilled",
                "order_type": "buy",
                "post_only": false,
                "operation_type": "market_order",
                "created_at": "2017-11-06T09:53:08.383210Z"
            }
        ]
    }
    

    List your current open orders. Only open or un-settled orders are returned. As soon as an order is no longer open and settled, it will no longer appear in the default request.

    HTTP Request

    GET https://coinfalcon.com/api/v1/user/orders

    Query Parameters

    Parameter Default Description
    market optional Get only orders from specific market e.g. BTC-EUR
    status [pending, open, partially_filled] Use all to get all types of statuses
    since_time optional Returns orders since the given datetime
    start_time optional Returns orders beginning with the given datetime
    end_time optional Returns orders ending with the given datetime

    List Trades

    The above command returns JSON structured like this:

    {
        "data": [
            {
                "id": "74fcd4e5-a472-4482-92cf-70be8c44bda4",
                "price": "7541.6",
                "size": "0.00091",
                "market_name": "BTC-EUR",
                "order_id": "97aa8719-4e69-422f-86f8-7485170f0055",
                "side": "sell",
                "fee": "0.0",
                "liquidity": "M",
                "created_at": "2018-04-24T13:46:04.597195Z"
            },
            {
                "id": "330682ca-bd64-4883-8134-44def1e5a581",
                "price": "0.02394",
                "size": "0.00001",
                "market_name": "LTC-BTC",
                "order_id": "72828f0b-5796-484d-af1e-915a2495bb65",
                "side": "buy",
                "fee": "0.0",
                "liquidity": "M",
                "created_at": "2018-04-24T13:46:03.065418Z"
            }
        ]
    }
    

    Get a list of recent trades.

    HTTP Request

    GET https://coinfalcon.com/api/v1/user/trades

    Query Parameters

    Parameter Default Description
    market required Get only trades from specific market e.g. BTC-EUR
    since_time optional Returns trades since the given datetime
    start_time optional Returns trades beginning with the given datetime
    end_time optional Returns trades ending with the given datetime

    List Order Trades

    The above command returns JSON structured like this:

    {
        "data": [
            {
                "id": "74fcd4e5-a472-4482-92cf-70be8c44bda4",
                "price": "7541.6",
                "size": "0.00091",
                "market_name": "BTC-EUR",
                "order_id": "97aa8719-4e69-422f-86f8-7485170f0055",
                "side": "sell",
                "fee": "0.0",
                "liquidity": "M",
                "created_at": "2018-04-24T13:46:04.597195Z"
            },
            {
                "id": "74fcd4e5-a472-4482-92cf-70be8c44bda4",
                "price": "7541.7",
                "size": "0.00096",
                "market_name": "BTC-EUR",
                "order_id": "97aa8719-4e69-422f-86f8-7485170f0055",
                "side": "sell",
                "fee": "0.0",
                "liquidity": "M",
                "created_at": "2018-04-24T13:46:09.597195Z"
            }
        ]
    }
    

    Get a list of recent trades based on order id.

    HTTP Request

    GET https://coinfalcon.com/api/v1/user/orders/:uuid/trades

    Query Parameters

    Parameter Default Description
    uuid required Order uuid to get trades for

    Get Deposit Address

    The above command returns JSON structured like this:

    {
        "data": {
            "address": "2MttMDBh8Qj6EL8Pv6eF6CeaEUzgiaQeoYQ"
        }
    }
    

    If deposit requires tags (i.e. for XRP, EOS etc.), it will return following:

    {
        "data": {
            "address": "r3qasmoPKKpoH3b3zWWq6R2V849bPDZosJ",
            "tag": "2575700108"
        }
    }
    

    Get deposit address for currency

    HTTP Request

    GET https://coinfalcon.com/api/v1/account/deposit_address

    Query Parameters

    Parameter Default Description
    currency required currency code e.g. BTC

    Get Deposit History

    The above command returns JSON structured like this:

    {
        "data": [
            {
                           "id": "030c7377-32e5-4078-a1ca-18322250bfd5",
                       "amount": "0.01",
                       "status": "completed",
                "currency_code": "btc",
                         "txid": "3caa72cc139505f7e20f17f825c323c6e5888553098df2efe296362d79b7dcd8",
                      "address": "2NBoxXmc9E8Fa6TPfFLip6ifDUMcB3Nwsc6",
                         "type": "deposit"
            },
            {
                           "id": "2ee9a009-4c3c-4942-a73b-bbe893199beb",
                       "amount": "0.01",
                       "status": "completed",
                "currency_code": "btc",
                         "txid": "6f230aa0493b46d54ab82125ff50ff77bde419c0986660dc175060e367ca0a5a",
                      "address": "2NBoxXmc9E8Fa6TPfFLip6ifDUMcB3Nwsc6",
                         "type": "deposit"
            }
        ]
    }
    

    Get deposit history

    HTTP Request

    GET https://coinfalcon.com/api/v1/account/deposits

    Query Parameters

    Parameter Default Description
    currency optional currency code e.g. BTC
    status optional [pending, completed]
    since_time optional Returns deposits since the given datetime
    start_time optional Returns deposits beginning with the given datetime
    end_time optional Returns deposits ending with the given datetime

    Get Deposit Detail

    The above command returns JSON structured like this:

    {
        "data": {
                       "id": "e30a3ac8-33b1-46ed-8f54-1112417de581",
                   "amount": "0.01",
                   "status": "completed",
            "currency_code": "btc",
                     "txid": "782c9be82488e791a93facf7dff2809a8e32e8ec02ee723f0da7d4f72558d82e",
                  "address": "2NBoxXmc9E8Fa6TPfFLip6ifDUMcB3Nwsc6",
                     "type": "deposit"
        }
    }
    

    Get Deposit Detail

    HTTP Request

    GET https://coinfalcon.com/api/v1/account/deposit

    Path Parameters

    Parameter Default Description
    id required deposit id

    Create withdrawal

    The above command returns JSON structured like this:

    {
        "data": {
                       "id": "641e12db-699e-410e-8b3d-6fff4669119c",
                   "amount": "0.001",
                   "status": "pending",
                      "fee": "0.000441",
            "currency_code": "btc",
                     "txid": "nil",
                  "address": "2NBoxXmc9E8Fa6TPfFLip6ifDUMcB3Nwsc6",
                     "type": "withdraw"
        }
    }
    

    When create withdrawal through api, won't require 2fa code and email confirmation.

    HTTP Request

    POST https://coinfalcon.com/api/v1/account/withdraw

    Query Parameters

    Parameter Default Description
    currency required currency code like btc
    address required withdraw address
    amount required withdraw amount
    tag optional withdraw tag for currencies like XRP

    Get Withdrawal Detail

    The above command returns JSON structured like this:

    {
        "data": {
                       "id": "9b25877a-35ae-4812-8d89-953ed4c55094",
                   "amount": "0.01",
                   "status": "completed",
                      "fee": "0.00000662",
            "currency_code": "btc",
                     "txid": "af88900ee9b99b468bf3159be757d6d1be6ef4c2e0fb993e80acb8a2b733742d",
                  "address": "2NBoxXmc9E8Fa6TPfFLip6ifDUMcB3Nwsc6",
                     "type": "withdraw"
        }
    }
    

    Get Withdrawal Detail

    HTTP Request

    GET https://coinfalcon.com/api/v1/account/withdrawal

    Query Parameters

    Parameter Default Description
    id required withdrawal id

    Get Withdrawal History

    The above command returns JSON structured like this:

    {
        "data": [
            {
                           "id": "4f408bea-abf0-46f7-9ae3-c19edbbd38e9",
                       "amount": "1.0",
                       "status": "completed",
                          "fee": "0.000441",
                "currency_code": "btc",
                         "txid": "15d0ea80886ed8518373475bd621db5a04d05645bad13bf785b3032830cdb5f5",
                      "address": "2NBoxXmc9E8Fa6TPfFLip6ifDUMcB3Nwsc6",
                         "type": "withdraw"
            },
            {
                           "id": "7db1dd7e-bcdd-4b6d-b31c-3699d1ef4a95",
                       "amount": "0.01",
                       "status": "completed",
                          "fee": "0.000441",
                "currency_code": "btc",
                         "txid": "5c569352ae4d55c5f31a4087329bf4e38d57129f8522dd0e6ecccda355bbd570",
                      "address": "2NBoxXmc9E8Fa6TPfFLip6ifDUMcB3Nwsc6",
                         "type": "withdraw"
            }
        ]
    }
    

    Get withdrawal history

    HTTP Request

    GET https://coinfalcon.com/api/v1/account/withdrawals

    Query Parameters

    Parameter Default Description
    currency optional currency code e.g. BTC
    status optional [pending, completed]
    since_time optional Returns deposits since the given datetime
    start_time optional Returns deposits beginning with the given datetime
    end_time optional Returns deposits ending with the given datetime

    Cancel withdrawal

    The above command returns JSON structured like this:

    {
        "data": {
                       "id": "8b591a8a-6c4f-4ab6-bef4-f156c0311346",
                   "amount": "0.001",
                   "status": "canceled",
                      "fee": "0.000441",
            "currency_code": "btc",
                     "txid": nil,
                  "address": "2NBoxXmc9E8Fa6TPfFLip6ifDUMcB3Nwsc6",
                     "type": "withdraw"
        }
    }
    

    Cancel a previously placed withdrawal.

    HTTP Request

    DELETE https://coinfalcon.com/api/v1/account/withdrawals/:id

    Path Parameters

    Parameter Default Description
    id required withdrawal id

    Fees

    The above command returns JSON structured like this:

    {
        "data": {
            "maker_fee": "0.0",
            "taker_fee": "0.15",
            "btc_volume_30d": "0.0"
        }
    }
    

    Get your personal current fees.

    HTTP Request

    GET https://coinfalcon.com/api/v1/user/fees

    Public

    List trades

    The above command returns JSON structured like this:

    {
        "data": [
            {
                "id": "13f33ced-0652-4f30-a11b-d380844c50b2",
                "price": "0.066",
                "size": "0.01",
                "market_name": "ETH-BTC",
                "side": "buy",
                "created_at": "2018-04-06T10:14:33.009320Z"
            },
            {
                "id": "f46248d9-326f-405d-bfca-508e949116ad",
                "price": "0.066",
                "size": "0.01",
                "market_name": "ETH-BTC",
                "side": "buy",
                "created_at": "2018-04-06T10:13:57.709221Z"
            }
        ]
    }
    

    List the latest trades for a market.

    HTTP Request

    GET https://coinfalcon.com/api/v1/markets/:market/trades

    Query Parameters

    Parameter Default Description
    market required Get only orders from specific market e.g. BTC-EUR
    since_time optional Returns orders since the given datetime
    start_time optional Returns orders beginning with the given datetime
    end_time optional Returns orders ending with the given datetime

    List orderbook

    The above command returns JSON structured like this:

    {
        "data": {
            "bids": [
                {
                    "price": "6225.0",
                    "size": "0.01"
                },
                {
                    "price": "6220.14",
                    "size": "1.31"
                }
            ],
            "asks": [
                {
                    "price": "6400.0",
                    "size": "0.38493686"
                },
                {
                    "price": "6400.07",
                    "size": "0.0303693"
                }
            ]
        }
    }
    

    Get a list of open orders for a market. The amount of detail shown can be customized with the level parameter.

    HTTP Request

    GET https://coinfalcon.com/api/v1/markets/:market/orders

    Query Parameters

    Parameter Default Description
    market required Get only orders from specific market e.g. BTC-EUR
    level 1 Defines the level of the request

    Level Parameter

    Level Description
    1 Only the best bid and ask
    2 Top 50 bids and asks (aggregated)
    3 Full order book (non aggregated)

    Websocket Feed

    require 'faye/websocket'
    require 'eventmachine'
    require 'json'
    
    EM.run do
      endpoint = 'wss://ws.coinfalcon.com'
    
      ws = Faye::WebSocket::Client.new(endpoint)
    
      ws.on :open do |event|
        p [:open]
    
        identifier = { channel: 'TickerChannel', market: 'ETH-BTC' }.to_json
        request = { command: :subscribe, identifier: identifier }.to_json
    
        ws.send(request)
      end
    
      ws.on :message do |event|
        p [:message, JSON.parse(event.data)]
      end
    
      ws.on :close do |event|
        p [:close, event.code, event.reason]
        ws = nil
        EM.stop
      end
    end
    

    The websocket feed provides real-time market data updates for orders and trades.

    wss://ws.coinfalcon.com

    Subscribe

    // request

    {
        "command": "subscribe",
        "identifier": "{\"channel\":\"ChannelName\", \"market\":\"MARKET-NAME\"}"
    }
    

    // response

    {
        "type": "confirm_subscription",
        "identifier": "{\"channel\":\"ChannelName\", \"market\":\"MARKET-NAME\"}"
    }
    

    To begin receiving feed messages, you must first send a subscribe message to the server indicating which channels and products to receive.

    Make sure that you subscribed successfully by verifying the response's type field.

    Authentication

    import hashlib
    import hmac
    import time
    import json
    import websocket
    try:
        import thread
    except ImportError:
        import _thread as thread
    import time
    
    def on_message(ws, message):
        print(message)
    
    def on_error(ws, error):
        print(error)
    
    def on_close(ws):
        print("### closed ###")
    
    def on_open(ws):
        def run(*args):
            ws.send(json.dumps({ "command": "subscribe", "identifier": "{\"channel\":\"UserTradesChannel\",\"market\":\"ETH-BTC\"}" }))
            time.sleep(10)
            ws.close()
            print("thread terminating...")
        thread.start_new_thread(run, ())
    
    def headers(key, secret):
        timestamp = str(int(time.time()))
    
        payload = '|'.join([timestamp, 'GET', '/auth/feed'])
    
        message = bytes(payload)
        secret = bytes(secret)
    
        signature = hmac.new(secret, message, hashlib.sha256).hexdigest()
        return {
            "CF-API-KEY": key,
            "CF-API-TIMESTAMP": timestamp,
            "CF-API-SIGNATURE": signature
        }
    
    
    if __name__ == "__main__":
        custom_headers = headers('key', 'secret')
        websocket.enableTrace(True)
        ws = websocket.WebSocketApp("wss://ws.coinfalcon.com",
                                  on_message = on_message,
                                  on_error = on_error,
                                  on_close = on_close,
                                  header = custom_headers)
        ws.on_open = on_open
        ws.run_forever()
    

    It is possible to authenticate yourself when subscribing to the websocket feed.

    To authenticate, you send a subscribe message as usual, but you also provide request with the headers just as if you were signing a request to GET /auth/feed.

    To get the necessary headers, you would go through the same process as you do to make authenticated calls to the API.

    The ticker channel

    The ticker channel provides real-time price updates every time a match happens.

    // subscribe request

    {
        "command": "subscribe",
        "identifier": "{\"channel\":\"TickerChannel\",\"market\":\"IOT-BTC\"}"
    }
    

    // confirmation

    {
        "type": "confirm_subscription",
        "identifier": "{\"channel\":\"TickerChannel\",\"market\":\"IOT-BTC\"}"
    }
    

    // response structure

    {
        "identifier": "{\"channel\":\"TickerChannel\",\"market\":\"IOT-BTC\"}",
        "message": {
            "market_info": {
                "id": 72,
                "percent_change_24h": "0.0",
                "latest_trade_price": "0.00022168",
                "d1_volume": "294.00451",
                "d1_price_volume": "0.0230943697768",
                "price_precision": 8,
                "size_precision": 0,
                "right_currency_sign": "\u20BF"
            }
        }
    }
    

    The trades channel

    The trades channel provides real-time updates on trades.

    // subscribe request

    {
        "command": "subscribe",
        "identifier": "{\"channel\":\"TradesChannel\",\"market\":\"IOT-BTC\"}"
    }
    

    // confirmation

    {
        "type": "confirm_subscription",
        "identifier": "{\"channel\":\"TradesChannel\",\"market\":\"IOT-BTC\"}"
    }
    

    // response structure

    {
        "identifier": "{\"channel\":\"TradesChannel\",\"market\":\"IOT-BTC\"}",
        "message": {
            "trade": {
                "id": "d40d9f77-dbf3-4ffe-ba97-65eeacc8ebc7",
                "price": "0.02394",
                "size": "0.3",
                "market_name": "LTC-BTC",
                "side": "buy",
                "created_at": "2018-04-24T13:46:05.121966Z"
            }
        }
    }
    

    The orderbook channel

    The orderbook channel provides real-time updates on orders.

    // subscribe request

    {
        "command": "subscribe",
        "identifier": "{\"channel\":\"OrderbookChannel\",\"market\":\"IOT-BTC\"}"
    }
    

    // initial snapshot

    {
        "identifier": "{\"channel\":\"OrderbookChannel\",\"market\":\"ETH-BTC\"}",
        "message": {
            "init": {
                "bids": [
                    {"price": "0.075", "size": "1.56307"},
                    {"price": "0.07491", "size": "0.011"},
                    {"price": "0.0747", "size": "1.0"},
                    ...
                ],
                "asks": [
                    {"price": "0.08975", "size": "0.98998"},
                    {"price": "0.0899", "size": "0.5"},
                    {"price": "0.0913", "size": "0.19231"},
                    ...
                ],
                "price_precision": 5,
                "size_precision": 5
            }
        }
    }
    

    // confirmation

    {
        "type": "confirm_subscription",
        "identifier": "{\"channel\":\"OrderbookChannel\",\"market\":\"IOT-BTC\"}"
    }
    

    // response structure

    // asks

    {
        "identifier": "{\"channel\":\"OrderbookChannel\",\"market\":\"IOT-BTC\"}",
        "message": {
            "update": {
                "key": "asks",
                "value": [
                    {
                        "price": "0.00022168",
                        "size": "447.66944"
                    }
                ]
            }
        }
    }
    

    // bids

    {
        "identifier": "{\"channel\":\"OrderbookChannel\",\"market\":\"IOT-BTC\"}",
        "message": {
            "update": {
                "key": "bids",
                "value": [
                    {
                        "price": "0.00022168",
                        "size": 0.0
                    }
                ]
            }
        }
    }
    

    The user's orders channel

    // subscribe request

    {
        "command": "subscribe",
        "identifier": "{\"channel\":\"UserOrdersChannel\",\"market\":\"ETH-BTC\"}"
    }
    

    // confirmation

    {
        "type": "confirm_subscription",
        "identifier": "{\"channel\":\"UserOrdersChannel\",\"market\":\"ETH-BTC\"}"
    }
    

    // response structure

    // pending

    {
        "identifier": "{\"channel\":\"UserOrdersChannel\",\"market\":\"ETH-BTC\"}",
        "message": {
            "order": {
                "id": "1d475f9d-c883-4daf-8370-be43124960e4",
                "market": "ETH-BTC",
                "price": "0.0761",
                "size": "0.001",
                "size_filled": "0.0",
                "fee": "0",
                "funds": "0.0000761",
                "status": "pending",
                "order_type": "buy",
                "post_only": false,
                "operation_type": "limit_order",
                "created_at": "2018-03-19T17:33:43.300588Z"
            }
        }
    }
    

    // fulfilled

    {
        "identifier": "{\"channel\":\"UserOrdersChannel\",\"market\":\"ETH-BTC\"}",
        "message": {
            "order": {
                "id": "1d475f9d-c883-4daf-8370-be43124960e4",
                "market": "ETH-BTC",
                "price": "0.0761",
                "size": "0.001",
                "size_filled": "0.001",
                "fee": "0.00000019025",
                "funds": "0.0000761",
                "status": "fulfilled",
                "order_type": "buy",
                "post_only": false,
                "operation_type": "limit_order",
                "created_at": "2018-03-19T17:33:43.300588Z"
            }
        }
    }
    

    The user's trades channel

    // subscribe request

    {
        "command": "subscribe",
        "identifier": "{\"channel\":\"UserTradesChannel\",\"market\":\"ETH-BTC\"}"
    }
    

    // confirmation

    {
        "type": "confirm_subscription",
        "identifier": "{\"channel\":\"UserTradesChannel\",\"market\":\"ETH-BTC\"}"
    }
    

    // response structure

    {
        "identifier": "{\"channel\":\"UserTradesChannel\",\"market\":\"ETH-BTC\"}",
        "message": {
            "trade": {
                "id": "d40d9f77-dbf3-4ffe-ba97-65eeacc8ebc7",
                "price": "0.02394",
                "size": "0.3",
                "market_name": "LTC-BTC",
                "order_id": "72828f0b-5796-484d-af1e-915a2495bb65",
                "fee": "0.0",
                "liquidity": "M",
                "created_at": "2018-04-24T13:46:05.121966Z",
                "order_type": "buy",
                "volume": "0.3",
                "left_currency_code": "LTC",
                "right_currency_code": "BTC"
            }
        }
    }
    

    The user's balances channel

    // subscribe request

    {
        "command": "subscribe",
        "identifier": "{\"channel\":\"AccountChannel\"}"
    }
    

    // confirmation

    {
        "type": "confirm_subscription",
        "identifier": "{\"channel\":\"AccountChannel\"}"
    }
    

    // response structure

    {
        "identifier": "{\"channel\":\"AccountChannel\"}",
        "message": {
            "balances": [
                {
                    "balance": "1.24705",
                    "available_balance": "1.24705",
                    "hold_balance": "0.0",
                    "currency_code": "btc",
                    "currency_name": "Bitcoin"
                },
                {
                    "balance": "11.99342",
                    "available_balance": "11.99342",
                    "hold_balance": "0.0",
                    "currency_code": "eth",
                    "currency_name": "Ethereum"
                },
                {
                    ...
                }
            ]
        }
    }
    

    FIX API

    Coming soon...

    The Financial Information eXchange (FIX) protocol is a standard protocol which can be used to create orders, submit cancel requests, and receive reports.

    Messages

    The baseline specification for this API is FIX 4.4.

    A standard header must be present at the start of every message in both directions.

    Tag Name Description
    8 BeginString Must be FIX.4.4
    49 SenderCompID Client API key (on messages from the client)
    56 TargetCompID Must be CoinFalcon (on messages from the client)

    Logon [type 'A']

    # Signature example
    # SendingTime, SenderCompID, TargetCompID
    timestamp = Time.now.to_i
    key = 'api-key'
    target = 'CoinFalcon'
    secret = 'api-secret'
    
    payload = [timestamp, key, target].join(1.chr)
    signature = OpenSSL::HMAC.hexdigest('SHA256', secret, payload)
    
    // Signature example
    // SendingTime, SenderCompID, TargetCompID
    timestamp := time.Now().Unix()
    stamp := strconv.FormatInt(int64(timestamp), 10)
    key := "api-key"
    target := "CoinFalcon"
    s := []string{stamp, key, target}
    payload := strings.Join(s, "\x01")
    secret := []byte("api-secret")
    hash := hmac.New(sha256.New, secret)
    preHash := []byte(payload)
    hash.Write(preHash)
    
    signature := hex.EncodeToString(hash.Sum(nil))
    

    The logon message authenticates a user establishing a connection.

    Tag Name Description
    98 EncryptMethod Must be 0 (None)
    108 HeartBtInt Must be 60 (seconds)
    96 RawData Client message signature (see below)
    95 RawDataLength Signature length
    52 SendingTime Must be the same as used to sign

    The Logon message sent by the client must be signed for security. The signing method is described in Signing a message. The prehash string is the following fields joined by the FIX field separator (ASCII code 1):

    SendingTime, SenderCompID, TargetCompID.

    Logout [type '5']

    Sent by either side to initiate session termination. The side which receives this message first should reply with the same message type to confirm session termination. Closing a connection without logging out of the session first is an error.

    NewOrderSingle [type 'D']

    Sent by the client to create an order.

    Tag Name Description
    21 HandlInst Must be 1 (Automated)
    11 ClOrdID UUID selected by client to identify the order
    55 Symbol E.g. eth-btc
    54 Side Must be 1 to buy or 2 to sell
    44 Price (Limit order only)
    38 OrderQty Order size in base units (e.g. eth)
    152 CashOrderQty Order size in quote units (e.g. btc) (Market order only)
    40 OrdType Must be 1 for Market, 2 for Limit
    59 TimeInForce Must be a valid TimeInForce value (e.g. 0 for DAY). (Limit order only)

    OrderCancelRequest [type 'F']

    Sent by the client to cancel an order.

    Tag Name Description
    11 ClOrdID UUID from the ExecutionReport
    55 Symbol Symbol of the order to cancel (must match Symbol of the Order)

    OrderStatusRequest [type 'H']

    Sent by the client to obtain information about pending orders.

    Tag Name Description
    37 OrderID UUID of order to be sent back. Can be equal to wildcard (*) to send back all pending orders
    55 Symbol E.g. eth-btc
    54 Side Must be 1 to buy or 2 to sell

    The response to an OrderStatusRequest is a series of ExecutionReports with ExecType=I, each representing one open order belonging to the user.

    MarketDataRequest [type 'V']

    Used to request or manage subscriptions for market data.

    Tag Name Req'd Description
    262 MDReqID Y Unique ID for this request. FIX Engine returns this ID in all responses to the request.

    Data type: string
    263 SubscriptionRequestType Y Type of request. Valid values include:
    • 0: Snapshot
    • 1: Snapshot plus updates (subscribe)
    • 2: Disable previous (unsubscribe)
    Data type: char
    264 MarketDepth C Market depth to return in a snapshot. Valid values include:
    • 0: Full book
    • 1: Top of book
    • >1: Best specified number of price tiers data
    Data type: int

    Condition: Required when Tag 263 (SubscriptionRequestType) is 0 or 1.
    265 MDUpdateType C Type of messages FIX Engine sends when updating market data. Valid values include:
    • 0: Full refresh
    • 1: Incremental refresh
    Data type: int

    Condition: Required when Tag 263 (SubscriptionRequestType) is 1.
    267 NoMDEntryTypes Y Number of different Tag 269 (MDEntryType) fields in the request.

    Data type: NumInGroup

    Condition: Required when Tag 265 (SubscriptionRequestType) is 0 or 1.
    269 MDEntryType Y Type of market data to request. Valid values include:
    • 0: Bid
    • 1: Ask
    • 2: Trade
    • 4: Opening price
    • 5: Closing price
    • 6: Settlement price
    • 7: Trading session high price
    • 8: Trading session low price
    • A: Imbalance
    • P: Workup state
    • Y: Implied bid
    • Z: Implied ask
    • n: Market bid
    • o: Market ask
    • p: Indicative open
    • q: Indicative close
    • r: Indicative bid
    • s: Indicative ask
    • t: Indicative settlement
    Data type: char

    Condition: Required for the number of requests specified in Tag 267 (NoMDEntryTypes).
    146 NoRelatedSym Y Number of underlying instruments contained in this repeating group.

    Data type: NumInGroup
    55 Symbol Y E.g. eth-btc

    The Market Data Request (V) message is used by a FIX client to request market data information from FIX Engine. You can request information like the top of book (Bid, Ask, and session prices) and market depth data.

    FIX Engine responds to a Market Data Request (V) message with a Market Data Snapshot Full Refresh (W) message. Additionally: