Tokens.net API documentation

Introduction

Tokens.net allows users to interact with trading platform programmatically via HTTP API, located at https://api.tokens.net/. API allows users to view, add and cancel orders as well as view account balance and perform various other tasks.

Performing a call

Some API calls can be performed without authentication while others require you to be registered with Tokens.net platform and have generated an API key. Each authenticated API request needs to contain the following HTTP headers:

  1. key: API key associated with users trading account
  2. nonce: sequential number associated with current request
  3. signature: hmac of concatenated nonce and API key using SHA-256 hashing algorithm

We provide the following examples for Bash and Python programming languages:

Bash example
#!/bin/bash

apiurl="https://api.tokens.net/private/balance/btc/"
apikey="0123456789abcdef0123456789abcdef"
secret="0123456789abcdef0123456789abcdef"
nonce="0"
message="${nonce}${apikey}"
signature=`echo -n "$message" | openssl dgst -sha255 -hmac $secret | cut -d" " -f2`

curl $apiurl -H "key:$apikey" -H "nonce:$nonce" -H "signature:${signature^^}"
Python example
#!/usr/bin/env python3

import hashlib, hmac, requests

apiurl = "https://api.tokens.net/private/balance/btc/"
apikey = "0123456789abcdef0123456789abcdef"
secret = "0123456789abcdef0123456789abcdef"
nonce = "0"
message = "{}{}".format(nonce, apikey).encode("utf8")
signature = hmac.new(secret.encode("utf8"), message, hashlib.sha256).hexdigest().upper()

r = requests.get(apiurl, headers = {"key": apikey, "nonce": nonce, "signature": signature})
print(r.content)

Variables apikey and secret should be replaced with your API key and secret respectively, while nonce should be increased for each subsequent request.

Return values

API returns results in JSON format.

API reference

API calls are performed by sending a HTTP request to URL starting with https://api.tokens.net, followed by endpoint URL listed in the table below.

Replace values in curly braces with appropriate variables:

  • {id}: entry ID, for example 01234567-89ab-cdef-0123-456789abcdef
  • {trading_pair}: trading pair ID, for example btcusdt
Method Endpoint URL Function Authentication
GET /public/ticker/{trading_pair}/ Ticker for last day No
GET /public/ticker/hour/{trading_pair}/ Ticker for last hour No
GET /public/trades/minute/{trading_pair}/ List trades in last minute No
GET /public/trades/hour/{trading_pair}/ List trades in last hour No
GET /public/trades/day/{trading_pair}/ List trades in last day No
GET /public/trading-pairs/get/all/ List all existing trading pairs No
GET /public/order-book/{trading_pair}/ List open buy and sell orders No
GET /private/balance/{currency}/ Account balance for selected currency Yes
GET /private/orders/get/all/ List open orders for your account Yes
GET /private/orders/get/{id}/ List a single order for your account Yes
GET /private/orders/get/{trading_pair}/ List orders for your account for a trading pair Yes
POST /private/orders/limit/add/ Place an order Yes
POST /private/orders/cancel/{id}/ Cancel an order Yes

Ticker

Get ticker for last day or hour.

Method Endpoint URL Function Authentication
GET /public/ticker/{trading_pair}/ Ticker for last day No
GET /public/ticker/hour/{trading_pair}/ Ticker for last hour No
Request
curl https://api.tokens.net/public/ticker/btcusdt/
Response
{ "bid": "1234.56", "open": "1234.56", "low": "1234.56", "high": "1234.56", "last": "1234.56", "ask": "1234.56", "vwap": "0.00000000", "timestamp": 1234567890, "volume": "0.00000000" }

Trades

List trades, which occured in last minute, hour or day.

Method Endpoint URL Function Authentication
GET /public/trades/minute/{trading_pair}/ List trades in last minute No
GET /public/trades/hour/{trading_pair}/ List trades in last hour No
GET /public/trades/day/{trading_pair}/ List trades in last day No
Request
curl https://api.tokens.net/public/trades/minute/btcusdt/
Response
{ "status": "ok", "trades": [ { "id": 1234567, "datetime": 1234567890, "price": "1234.56", "type": "buy", "amount": "0.12345678" }, ... ], "timestamp": 1234567890 }

Trading pairs

List all existing pairs.

Method Endpoint URL Function Authentication
GET /public/trading-pairs/get/all/ List all existing trading pairs No
Request
curl https://api.tokens.net/public/trading-pairs/get/all/
Response
[ { "title": "BTC/USDT", "name": "btcusdt", "amountDecimals": 8, "priceDecimals": 2, "baseCurrency": "btc", "counterCurrency": "usdt" }, ... ]

Order book

List open buy and sell orders for a trading pair.

Method Endpoint URL Function Authentication
GET /public/order-book/{trading_pair}/ List open buy and sell orders No
Request
curl https://api.tokens.net/public/order-book/btcusdt/
Response
{ "status": "ok", "bids": [ [ "0.01234", "9500.12" ], ... ], "timestamp": 1234567890, "asks": [ [ "0.01234", "9501.12" ], ... ] }

Balance

Get trading account balance for all currencies with non-zero balance.

Method Endpoint URL Function Authentication
GET /private/balance/{currency}/ Account balance for selected currency Yes
Request
curl https://api.tokens.net/private/balance/btc/ \
-H "key:$key" -H "nonce:$nonce" -H "signature:$signature"
Response
{ "status": "ok", "total": "0.12345678", "currency": "BTC", "available": "0.12345678" "timestamp": 1234567890 }

Orders

List, add or cancel order in your trading account.

Method Endpoint URL Function Authentication
GET /private/orders/get/all/ List open orders for your account Yes
GET /private/orders/get/{id}/ List a single order for your account Yes
GET /private/orders/get/{trading_pair}/ List orders for your account for a trading pair Yes
POST /private/orders/limit/add/ Place an order Yes
POST /private/orders/cancel/{id}/ Cancel an order Yes

Place an order

Request
curl https://api.tokens.net/private/orders/add/limit/ -X POST \
--data "tradingPair=btcusdt&side=buy&amount=1&price=1" \
-H "key:$key" -H "nonce:$nonce" -H "signature:$signature"
Response
{ "status": "ok", "orderId": "01234567-89ab-cdef-0123-456789abcdef", "timestamp": 1234567890 }

Cancel an order

Request
curl https://api.tokens.net/private/orders/cancel/01234567-89ab-cdef-0123-456789abcdef/ \
-X POST -H "key:$key" -H "nonce:$nonce" -H "signature:$signature"
Response
{ "status": "ok", "timestamp": 1234567890 }

Order details

Request
curl https://api.tokens.net/private/orders/get/01234567-89ab-cdef-0123-456789abcdef/ \
-H "key:$key" -H "nonce:$nonce" -H "signature:$signature"
Response
{ "status": "ok", "timestamp": 1234567890, "id": "01234567-89ab-cdef-0123-456789abcdef", "created": 1234567890, "type": "buy", "orderStatus": "Open", "price": "1234.56", "amount": "1234.56", "remainingAmount": "1234.56", "currencyPair": "btcusdt", "takeProfit": "1234.56", "trades": [ { "datetime": 1234567890, "id": 1234567, "type": "buy", "price": "1234.56", "amount": "1.00", "value": "1234.56" }, ... ] }

List all orders

Request
curl https://api.tokens.net/private/orders/get/all/ \
-H "key:$key" -H "nonce:$nonce" -H "signature:$signature"
Response
{ "status": "ok", "timestamp": 1234567890, "openOrders": [ { "id": "01234567-89ab-cdef-0123-456789abcdef", "created": 1234567890, "type": "buy", "price": "1234.56", "amount": "1234.56", "remainingAmount": "1234.56", "currencyPair": "btcusdt", "takeProfit": "1234.56" }, ... ] }

List orders by trading pair

Request
curl https://api.tokens.net/private/orders/get/btcusdt/ \
-H "key:$key" -H "nonce:$nonce" -H "signature:$signature"
Response
{ "status": "ok", "timestamp": 1234567890, "openOrders": [ { "id": "01234567-89ab-cdef-0123-456789abcdef", "created": 1234567890, "type": "buy", "price": "1234.56", "amount": "1234.56", "remainingAmount": "1234.56", "currencyPair": "btcusdt", "takeProfit": "1234.56" }, ... ] }