altilly Websocket API


Global Paramaters

method - The method you would like to call
params - The parameters for the method
id - An identification you can pass to the server, the same id will be passed in the results.

Why do we use port 2096? All requests go through our provider, Cloudflare, for an extra layer of security. Cloudflare has designated 2096 as a port for websocket usage.

Currency/Asset Lists



Request method: getCurrency Public Method

Get single currency information

Input Parameters:
currency - The currency symbol you would like information on.


Request method: getCurrencies Public Method

Get all currency information

Input Parameters:
none
Request
wscat -c wss://wsapi.altilly.com:2096

{
  "method": "getCurrency",
  "params": {
    "currency": "ETH"
  },
  "id": 123
}

Response
{
  "jsonrpc": "2.0",
  "result": {
  	"id": "ETH",
  	"fullName": "Ethereum",
  	"crypto": true,
  	"payinEnabled":true,
  	"payinPaymentId":false,
  	"payinConfirmations":20,
  	"payoutEnabled":true,
  	"payoutIsPaymentId":false,
  	"delisted":false,
  	"payoutFee":"0.00080000"
  },
  "id":123
}

Request
wscat -c wss://wsapi.altilly.com:2096

{
  "method": "getCurrencies",
  "params": {},
  "id": 123
}

Response
{
  "jsonrpc": "2.0",
  "result": [
  
  ... Array of currencies ... 
  
  ],
  "id":123
}


Symbol/Market Lists


Request method: getSymbol Public Method

Get single currency information

Input Parameters:
symbol - The market symbol you would like information on.


Request method: getSymbols Public Method

Get all currency information

Input Parameters:
none
Request
wscat -c wss://wsapi.altilly.com:2096

{
  "method": "getSymbol",
  "params": {
    "symbol": "ETHBTC"
  },
  "id": 123
}

Response
{
  "jsonrpc": "2.0",
  "result": {
    "id": "ETHBTC",
    "baseCurrency": "ETH",
    "quoteCurrency": "BTC",
    "quantityIncrement": "0.001",
    "tickSize": "0.000001",
    "takeLiquidityRate": "0.0012",
    "provideLiquidityRate": "0.0000",
    "feeCurrency": "BTC"
  },
  "id": 123
}

Request
wscat -c wss://wsapi.altilly.com:2096

{
  "method": "getSymbols",
  "params": {},
  "id": 123
}

Response
{
  "jsonrpc": "2.0",
  "result": [
  
  ... Array of symbols ... 
  
  ],
  "id":123
}


Trade History


Request method: getTrades Public Method

Get trade history information on a market

Input Parameters:
symbol - The market symbol you would like information on.
limit - The limit of total results you would like (Optional, default: 100)
offset - Offset the results by this number (Optional, default: 0)
sort - Either 'ID' or 'TIMESTAMP' (Optional, default: TIMESTAMP)
by - 'ASC' for ascending order, 'DESC' for decending order. (Optional, default: DESC)
from - If 'sort' is ID, then this is the smallest trade id, If 'sort' is TIMESTAMP, then this is earliest datetime. (Optional)
till - If 'sort' is ID, then this is the largest trade id, If 'sort' is TIMESTAMP, then this is latest datetime. (Optional)
Request
wscat -c wss://wsapi.altilly.com:2096

{
  "method": "getTrades",
  "params": {
    "symbol": "ETHBTC",
    "limit": 3,
    "sort": "DESC",
    "by": "id"
  },
  "id": 123
}

Response
{
  "jsonrpc": "2.0",
  "result": {
    "data": [
      {
        "id": 54472171,
        "price": "0.054443",
        "quantity": "2.213",
        "side": "sell",
        "timestamp": "2017-10-19T16:39:20.796Z"
      },
      {
        "id": 54472170,
        "price": "0.054453",
        "quantity": "0.030",
        "side": "sell",
        "timestamp": "2017-10-19T16:39:20.796Z"
      },
      {
        "id": 54472169,
        "price": "0.054454",
        "quantity": "0.052",
        "side": "sell",
        "timestamp": "2017-10-19T16:39:20.796Z"
      }
    ],
    "symbol": "ETHBTC"
  },
  "id": 123
}


Subscribe to Ticker


Request method: subscribeTicker Public Method

Subscribe to ticker information

Input Parameters:
symbol - The market symbol you would like to subscribe to.

Notification method: ticker


Request method: unsubscribeTicker Public Method

Unsubscribe from ticker information

Input Parameters:
symbol - The market symbol you would like to unsubscribe.
wscat -c wss://wsapi.altilly.com:2096

{
  "method": "subscribeTicker",
  "params": {
    "symbol": "ETHBTC"
  }
}

Notification ticker
{
  "jsonrpc": "2.0",
  "method": "ticker",
  "params": {
    "ask": "0.054464",
    "bid": "0.054463",
    "last": "0.054463",
    "open": "0.057133",
    "low": "0.053615",
    "high": "0.057559",
    "volume": "33068.346",
    "volumeQuote": "1832.687530809",
    "timestamp": "2017-10-19T15:45:44.941Z",
    "symbol": "ETHBTC"
  }
}

Unsubscribe
wscat -c wss://wsapi.altilly.com:2096

{
  "method": "unsubscribeTicker",
  "params": {
    "symbol": "ETHBTC"
  }
}

Unsubscribe Response
{
  "jsonrpc": "2.0",
  "result": true
}


Subscribe to Orderbook


Request method: subscribeOrderbook Public Method

Subscribe to orderbook information

Input Parameters:
symbol - The market symbol you would like to subscribe to.

Notification snapshot method: snapshotOrderbook
  • Message contains a full snapshot of order book.


  • Notification update method: updateOrderbook
  • Message contains incremental changes, size = 0 means that price level was deleted. Sequence is an increasing number for each update, each symbol has its own sequence.



  • Request method: unsubscribeOrderbook Public Method

    Unsubscribe from orderbook information

    Input Parameters:
    symbol - The market symbol you would like to unsubscribe.
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "subscribeOrderbook",
      "params": {
        "symbol": "ETHBTC"
      }
    }
    

    Notification snapshot
    {
      "jsonrpc": "2.0",
      "method": "snapshotOrderbook",
      "params": {
        "ask": [
          {
            "price": "0.054588",
            "size": "0.245"
          },
          {
            "price": "0.054590",
            "size": "0.000"
          },
          {
            "price": "0.054591",
            "size": "2.784"
          }
        ],
        "bid": [
          {
            "price": "0.054558",
            "size": "0.500"
          },
          {
            "price": "0.054557",
            "size": "0.076"
          },
          {
            "price": "0.054524",
            "size": "7.725"
          }
        ],
        "symbol": "ETHBTC",
        "sequence": 8073827
      }
    }
    

    Notification update
    {
      "jsonrpc": "2.0",
      "method": "updateOrderbook",
      "params": {    
        "ask": [
          {
            "price": "0.054590",
            "size": "0.000"
          }
        ],
        "bid": [],
        "symbol": "ETHBTC",
        "sequence": 8073830
      }
    }
    

    Unsubscribe
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "unsubscribeOrderbook",
      "params": {
        "symbol": "ETHBTC"
      }
    }
    

    Unsubscribe Response
    {
      "jsonrpc": "2.0",
      "result": true
    }
    


    Subscribe to Trades


    Request method: subscribeTrades Public Method

    Subscribe to trade information

    Input Parameters:
    symbol - The market symbol you would like to subscribe to.

    Notification snapshot method: snapshotTrades
  • Message contains a snapshot of the last 50 trades.


  • Notification update method: updateTrades
  • Message contains new trade information as it occurs.



  • Request method: unsubscribeTrades Public Method

    Unsubscribe from trade information

    Input Parameters:
    symbol - The market symbol you would like to unsubscribe.
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "subscribeTrades",
      "params": {
        "symbol": "ETHBTC"
      }
    }
    

    Notification snapshot
    {
      "jsonrpc": "2.0",
      "method": "snapshotTrades",
      "params": {
        "data": [
          {
            "id": 54469456,
            "price": "0.054656",
            "quantity": "0.057",
            "side": "buy",
            "timestamp": "2017-10-19T16:33:42.821Z"
          },
          {
            "id": 54469497,
            "price": "0.054656",
            "quantity": "0.092",
            "side": "buy",
            "timestamp": "2017-10-19T16:33:48.754Z"
          },
          {
            "id": 54469697,
            "price": "0.054669",
            "quantity": "0.002",
            "side": "buy",
            "timestamp": "2017-10-19T16:34:13.288Z"
          }
        ],
        "symbol": "ETHBTC"
      }
    }
    

    Notification update
    {
      "jsonrpc": "2.0",
      "method": "updateTrades",
      "params": {
        "data": [
          {
            "id": 54469813,
            "price": "0.054670",
            "quantity": "0.183",
            "side": "buy",
            "timestamp": "2017-10-19T16:34:25.041Z"
          }
        ],
        "symbol": "ETHBTC"
      }
    }    
    

    Unsubscribe
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "unsubscribeTrades",
      "params": {
        "symbol": "ETHBTC"
      }
    }
    

    Unsubscribe Response
    {
      "jsonrpc": "2.0",
      "result": true
    }
    


    Subscribe to Candles


    Request method: subscribeCandles Public Method

    Subscribe to candlestick information

    Input Parameters:
    symbol - The market symbol you would like to subscribe to.
    period - The candlestick period you would like. (M30, H3, H8, H12, or H24)
    limit - Limit the results. (Optional, default: 100)

    Notification snapshot method: snapshotCandles
  • Message contains a a snapshot of the candlestick information up to the limit, sorted by newest first.


  • Notification update method: updateCandles
  • Message contains any new changes to the candlestick data.



  • Request method: unsubscribeCandles Public Method

    Unsubscribe from candlestick information

    Input Parameters:
    symbol - The market symbol you would like to unsubscribe.
    period - The candlestick period you would like unsubscribe from. (M30, H3, H8, H12, or H24)
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "subscribeCandles",
      "params": {
        "symbol": "ETHBTC",
        "period": "M30"
      },
      "id": 123
    }  
    

    Notification snapshot
    {
      "jsonrpc": "2.0",
      "method": "snapshotCandles",
      "params": {
        "data": [
          {
            "timestamp": "2017-10-19T15:00:00.000Z",
            "open": "0.054801",
            "close": "0.054625",
            "min": "0.054601",
            "max": "0.054894",
            "volume": "380.750",
            "volumeQuote": "20.844237223"
          },
          {
            "timestamp": "2017-10-19T15:30:00.000Z",
            "open": "0.054616",
            "close": "0.054618",
            "min": "0.054420",
            "max": "0.054724",
            "volume": "348.527",
            "volumeQuote": "19.011854364"
          },
          {
            "timestamp": "2017-10-19T16:00:00.000Z",
            "open": "0.054587",
            "close": "0.054626",
            "min": "0.054408",
            "max": "0.054768",
            "volume": "194.014",
            "volumeQuote": "10.595416973"
          },
          {
            "timestamp": "2017-10-19T16:30:00.000Z",
            "open": "0.054614",
            "close": "0.054443",
            "min": "0.054339",
            "max": "0.054724",
            "volume": "141.213",
            "volumeQuote": "7.706358298"
          }
        ],
        "symbol": "ETHBTC",
        "period": "M30"
      }
    }
    

    Notification update
    {
      "jsonrpc": "2.0",
      "method": "updateCandles",
      "params": {
        "data": [
          {
            "timestamp": "2017-10-19T16:30:00.000Z",
            "open": "0.054614",
            "close": "0.054465",
            "min": "0.054339",
            "max": "0.054724",
            "volume": "141.268",
            "volumeQuote": "7.709353873"
          }
        ],
        "symbol": "ETHBTC",
        "period": "M30"
      }
    }
    

    Unsubscribe
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "unsubscribeCandles",
      "params": {
        "symbol": "ETHBTC"
      }
    }
    

    Unsubscribe Response
    {
      "jsonrpc": "2.0",
      "result": true
    }
    


    Socket Session Authentication


    Request method: login Public Method

    Authenticate session with your API keys in order to use any Private Method

    Input Parameters:
    algo - Either "BASIC" or "HS256".
    pKey - API Public Key
    sKey - API Secret Key, required for BASIC algo
    nonce - Random string, required on HS256 algo
    signature - HMAC SHA256 sign nonce with API secret key, required on HS256 algo

    Here is an example of creating the signature in Nodejs
    var hmac = crypto.createHmac('sha256', sKey);
    hmac.update(nonce);
    var signature = hmac.digest('hex');
    
    BASIC Authorization Request
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "login",
      "params": {
        "algo": "BASIC",
        "pKey": "3ef4a9f8322f04bd8f09823b98403eae",
        "sKey": "2deb5702358fd553a4ed3e3229fd2d51"
      }
    }
    

    Response
    {
      "jsonrpc": "2.0",
      "result": true
      "id": 123
    }
    

    HS256 Authorization Request
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "login",
      "params": {
        "algo": "HS256",
        "pKey": "3ef4a9f8c8bf04bd8f09884b98403eae",
        "nonce": "N1g287gL8YOwDZr",
        "signature": "b1c0ae399c2d341866a214f7d3ed755b821c1c36fc6f17083ef05fbb55b7f986"
      }
    }
    

    Response
    {
      "jsonrpc": "2.0",
      "result": true
      "id": 123
    }
    


    Order Creation


    Request method: newOrder Private Method

    Submit a new order request

    Input Parameters:
    symbol - The market symbol you are submitting an order for.
    clientOrderId - Required parameter. Unique string.
    side - 'buy' or 'sell'
    type - 'limit', 'market', 'stopLimit', or 'stopMarket' (Optional, default: limit)
    timeInForce - 'GTC', 'IOC', 'FOK', 'Day', or 'GTD'. (Optional, default: GTC)
    quantity - Required. Order quantity.
    price - Order price. Required for limit types.
    stopPrice - Stop price. Required for stop types.
    expireTime - Required for GTD timeInForce.
    scriptValidate - Boolean (true/false). Price and quantity will be checked that they increment within tick size and quantity step. See symbol tickSize and quantityIncrement. (default: false)
    Request
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "newOrder",
      "params": {
        "clientOrderId": "57d5525562c945448e3cbd559bd068c4",
        "symbol": "ETHBTC",
        "side": "sell",
        "price": "0.059837",
        "quantity": "0.015"
      },
      "id": 123
    }
    

    Success Response
    {
      "jsonrpc": "2.0",
      "result": {
        "id": "4345947689",
        "clientOrderId": "57d5525562c945448e3cbd559bd068c4",
        "symbol": "ETHBTC",
        "side": "sell",
        "status": "new",
        "type": "limit",
        "timeInForce": "GTC",
        "quantity": "0.001",
        "price": "0.093837",
        "cumQuantity": "0.000",
        "createdAt": "2017-10-20T12:29:43.166Z",
        "updatedAt": "2017-10-20T12:29:43.166Z",
        "reportType": "new"
      },
      "id": 123
    }
    

    Error Response
    {
      "jsonrpc": "2.0",
      "error": {
        "code": 20001,
        "message": "Insufficient funds",
        "description": "Check that the funds are sufficient, given commissions"
      },
      "id": 123
    }
    


    Order Cancellation


    Request method: cancelOrder Private Method

    Cancel an existing order request

    Input Parameters:
    uuid - Use this parameter if you want to cancel by order uuid.
    -or-
    clientOrderId - Use this paramter if you want to cancel by clientOrderId
    Request
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "cancelOrder",
      "params": {
        "clientOrderId": "57d5525562c945448e3cbd559bd068c4"
      },
      "id": 123
    }
    

    Success Response
    {
      "jsonrpc": "2.0",
      "result": {
        "id": "4345947689",
        "clientOrderId": "57d5525562c945448e3cbd559bd068c4",
        "symbol": "ETHBTC",
        "side": "sell",
        "status": "canceled",
        "type": "limit",
        "timeInForce": "GTC",
        "quantity": "0.001",
        "price": "0.093837",
        "cumQuantity": "0.000",
        "createdAt": "2017-10-20T12:29:43.166Z",
        "updatedAt": "2017-10-20T12:31:26.174Z",
        "reportType": "canceled"
      },
      "id": 123
    }
    


    Get Active Orders


    Request method: getOrders Private Method

    Get a list of all open orders

    Input Parameters:
    none
    Request
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "getOrders",
      "params": {},
      "id": 123
    }
    

    Response
    {
      "jsonrpc": "2.0",
      "result": [
        {
          "id": "4346371528",
          "clientOrderId": "9cbe79cb6f864b71a811402a48d4b5b2",
          "symbol": "ETHBTC",
          "side": "sell",
          "status": "new",
          "type": "limit",
          "timeInForce": "GTC",
          "quantity": "0.002",
          "price": "0.083837",
          "cumQuantity": "0.000",
          "createdAt": "2017-10-20T12:47:07.942Z",
          "updatedAt": "2017-10-20T12:50:34.488Z",
          "reportType": "status",
        },
        {
          "id": "4346371529",
          "clientOrderId": "9cbe79cb6f864b71a811402a48d48c73",
          "symbol": "ETHBTC",
          "side": "buy",
          "status": "new",
          "type": "limit",
          "timeInForce": "GTC",
          "quantity": "0.002",
          "price": "0.073837",
          "cumQuantity": "0.000",
          "createdAt": "2017-10-20T12:47:07.942Z",
          "updatedAt": "2017-10-20T12:50:34.488Z",
          "reportType": "status",
        }
      ],
      "id": 123
    }
    


    Get Trading Balance


    Request method: getTradingBalance Private Method

    Get a list of all account balances

    Input Parameters:
    none
    Request
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "getTradingBalance",
      "params": {},
      "id": 123
    }
    

    Response
    {
      "jsonrpc": "2.0",
      "result": [
        {
          "currency": "USDT",
          "available": "100.000000000",
          "reserved": "0"
        },
        {
          "currency": "BTC",
          "available": "0.013634021",
          "reserved": "0"
        },
        {
          "currency": "ETH",
          "available": "0",
          "reserved": "0.00200000"
        }
      ],
      "id": 123
    }
    


    Subscribe to Order/Trade Reports


    Request method: subscribeReports Private Method

    Get a list of all account balances

    Input Parameters:
    none

    Notification snapshot method: activeOrders
  • Message contains a list of all currently active orders.


  • Notification update method: report
  • Message contains any new changes to your orders such as new order, cancelled order, or trade.
  • Request
    wscat -c wss://wsapi.altilly.com:2096
    
    {
      "method": "subscribeReports",
      "params": {}
    }
    

    Notification snapshot
    {
      "jsonrpc": "2.0",
      "method": "activeOrders",
      "params": [
        {
          "id": "4345613661",
          "clientOrderId": "57d5525562c945448e3cbd559bd068c3",
          "symbol": "BCCBTC",
          "side": "sell",
          "status": "new",
          "type": "limit",
          "timeInForce": "GTC",
          "quantity": "0.013",
          "price": "0.100000",
          "cumQuantity": "0.000",
          "createdAt": "2017-10-20T12:17:12.245Z",
          "updatedAt": "2017-10-20T12:17:12.245Z",
          "reportType": "status"
        }
      ]
    }
    

    Notification report
    {
      "jsonrpc": "2.0",
      "method": "report",
      "params": {
        "id": "4345697765",
        "clientOrderId": "53b7cf917963464a811a4af426102c19",
        "symbol": "ETHBTC",
        "side": "sell",
        "status": "filled",
        "type": "limit",
        "timeInForce": "GTC",
        "quantity": "0.001",
        "price": "0.053868",
        "cumQuantity": "0.001",
        "createdAt": "2017-10-20T12:20:05.952Z",
        "updatedAt": "2017-10-20T12:20:38.708Z",
        "reportType": "trade",
        "tradeQuantity": "0.001",
        "tradePrice": "0.053868",
        "tradeId": 55051694,
        "tradeFee": "0.00000000"
      }
    }