TOKPIE API

Last updated on February 10, 2021

TOKPIE offers its users a FREE access to the Public API.
Public API does not require authorization and can be accessed using the GET method.

Public API

This API does not require authorization and can be accessed using the GET method.
General URL with API access looks like this: https://tokpie.com/{api_name}/ where ‘api_name’ is the name of API you are accessing. Currently available API endpoints are described below.

Method description:

1. Live statistics on prices and volumes for all tickers.

Method name: ticker
Type of request: GET
Incoming parameters: None
Call: https://tokpie.com/api_ticker/
Return information sample:
…{
    "updated": "11.12.2018 22:00 UTC",
    "at_first24": "0.00000575",
    "pair": "TKP@ETH",
    "quoteVolume": "0.03449196",
    "high24hr": "0.0000058",
    "isFrozen": 0,
    "highestBid": "0.0000056",
    "percentChange": "0.87%",
    "low24hr": "0.0000056",
    "last": "0.0000058",
    "avg": "0.000005659893995832",
    "lowestAsk": "0.0000058",
    "id": 22,
    "baseVolume": "6094.10"}…
                        
Fields description: updated – date and time of data update.
at_first24 – the price of the first deal for the last 24 hours.
pair – unique combination of base and quote currencies or assets.
quoteVolume - the total quantity of quote currency or asset for all deals within the last 24 hours.
high24hr - maximum deal price within the last 24 hours.
isFrozen - indicator specifying whether the market is frozen where return “1” means the market is frozen.
highestBid - current maximum buy price.
percentChange - percentage change in price for the last 24 hours.
low24hr - minimum deal price within the last 24 hours.
last - last deal price.
avg - average deal price within the last 24 hours.
lowestAsk - current minimum sell price.
id - unique identification number for a trading pair or instrument.
baseVolume - the total quantity of base currency or asset for all deals within the last 24.


2. Live trading data, prices and volume for a specified ticker.

Method name: ticker/market
Type of request: GET
Incoming parameters: market
example: OMG@ETH
Call example: https://tokpie.com/api_ticker/?market=OMG@ETH
Return information sample:
…{
    "is_ok": true, "result": {
    "updated": "30.05.2019 12:47 UTC",
    "at_first24": "0.00828541",
    "quoteVolume": "55.3715673852",
    "high24hr": "0.00864548",
    "isFrozen": 0,
    "highestBid": "0.0083513",
    "percentChange": "0.80%",
    "low24hr": "0.0082432",
    "pair": "OMG@ETH",
    "last": "0.0083513",
    "avg": "0.00844854079280071",
    "lowestAsk": "0.00837394",
    "id": 659,
    "baseVolume": "6553.98"
}}…
                        
Fields description: updated – date and time of data update.
at_first24 – the price of the first deal for the last 24 hours.

quoteVolume - the total quantity of quote currency or asset for all deals within the last 24 hours.

high24hr - maximum deal price within the last 24 hours.

isFrozen - indicator specifying whether the market is frozen where return “1” means the market is frozen.


highestBid - current maximum buy price.

percentChange - percentage change in price for the last 24 hours.
low24hr - minimum deal price within the last 24 hours.
pair – unique combination of base and quote currencies or assets.
last - last deal price.

avg - average deal price within the last 24 hours.

lowestAsk - current minimum sell price.

id - unique identification number for a trading pair or instrument.
 baseVolume - the total quantity of base currency or asset for all deals within the last 24.


3. Live order book data (market depth), prices and volume for a specified ticker.

Method name: order_book/market
Type of request: GET
Incoming parameters: market
example: OMG@ETH
size
Gear position 1-10
Call example: https://tokpie.com/api_order_book/?market=OMG@ETH&size=10
Return information sample:
…{
    "is_ok": true,
    "result": {
        "aob_bid": [
            [0.00871812, 40.0],
            [0.00852264, 177.0],
            [0.00850299, 231.0],
            [0.00840701, 238.0],
            [0.00837394, 103.0],
            [0.0083513, 47.0],
            [0.0082432, 82.0],
            [0.00819645, 144.0],
            [0.00814769, 286.0],
            [0.0081437, 221.0]
        ],
        "aob_datetime": "30.05.2019 13:02 UTC",
        "aob_ask": [
            [0.00922465, 111.0],
            [0.00917475, 83.0],
            [0.00915936, 106.0],
            [0.00912976, 83.0],
            [0.009092, 30.0],
            [0.0090821, 114.0],
            [0.0089919, 199.0],
            [0.00899181, 83.0],
            [0.0088142, 87.0],
            [0.0087542, 99.0]
        ]
    }
}…
                        
Fields description: aob_bid – Buyer depth [price, quantity]

aob_datetime – date and time of this depth
aob_ask – Seller depth [price, quantity]


4. OrderBookNew. Returns the full order book for a given market. It shows live order book data (market depth), prices and volume for a specified ticker. Market depth is unlimited. Fields include:

Method name: order_book_v2/market/depth
Type of request: GET
Incoming parameters: market
example: OMG@ETH
depth
0: returns full order book. Gear position 1-n: returns a predefined number of levels.
Call example: https://tokpie.com/api_order_book_v2/?market=OMG@ETH&depth=0
Return information sample:
…{
    "is_ok": true,
    "result": {
        "aob2_asks": [
            [0.004561, 587],
            [0.00446, 245],
            [0.004365, 381],
            [0.00433, 119],
            [0.00425, 717],
            [0.00423, 710],
            [0.00419, 793],
            [0.00415, 752],
            [0.004084, 506],
            [0.00408, 103],
            [0.004021, 73]
        ],
         "aob2_bids": [
            [0.004016, 54],
            [0.004011, 83.0],
            [0.004008, 96.0],
            [0.004, 53.0],
            [0.003905, 35.0],
            [0.003575, 100.0],
            [0.00357, 53.0],
            [0.00354, 97.0],
            [0.00234, 37.0],
            [0.00234, 23.0],
            [0.0018, 106.0]
        "aob2_datetime": "06.08.2020 15:47:04 UTC",

                        
Fields description: aob2_asks – Seller depth [price, quantity of Base currency]

aob2_bids – Buyer depth [price, quantity of Base currency]
aob2_datetime – date and time of this depth in UTC format


5. Trades. Retrieves all recently completed trade for a given market. Fields include:

Method name: trades/market
Type of request: GET
Incoming parameters: market
example: TKP@ETH
Call example: https://tokpie.com/api_trades/?market=TKP@ETH
Return information sample:
…{
    "is_ok": true,
    "result": [{
        "at_base_volumeat_base_volume": "920.00",
        “at_price”: "0.0000396",
        “at_trade_datetime”: "06.08.2020 14:12:21 UTC",
        “at_quote_volume”: "0.036432",
        “at_trade_id”: "219307",
        “at_type”: "buy",
 },
        "at_base_volumeat_base_volume": "11.00",
        “at_price”: "0.00004",
        “at_trade_datetime”: "05.08.2020 16:15:07 UTC",
        “at_quote_volume”: "0.00044",
        “at_trade_id”: "219018",
        “at_type”: "sell",}

        ]
    }
}…
                        
Fields description: at_base_volume – Transaction amount in BASE currency

at_price – Transacted price of base currency based on given quote currency
at_trade_datetime – The UTC date and time of the trade execution
at_quote_volume – Transaction amount in QUOTE currency
at_trade_id – The unique ID related only to this currency pair associated with this trade
at_typeat_type – Designates whether or not the trade originated as a buy or a sell. Buy – Identifies an ask was removed from the order book. Sell – Identifies a bid was removed from the order book.


6. CandleStick (OHLC). Retrieves candlestick bars for a market. Shows open, high, low, and close prices for a given market. Fields include:

Method name: candlestick/pair
Type of request: GET
Incoming parameters: Pair
Example: OMG@ETH
Retrieves 100 candlesticks with 1 minute interval by default.
Limit (optional)
Example: 100, 101, 102, …1000
Retrieves a number of candlesticks. Minimum 100 and maximum 1000 candlesticks. If not stated then returns 100 candlesticks.

Interval (optional)
Example: 5, 15, 30, 60, 240, 1440, 10080, 21600
Retrieves the time interval for each candlestick in minutes.
If not stated then returns a 1 minute interval.

Start_time (optional)
Example: 2020-08-28 20:13:35
Retrieves information starting from the date and time in the following format: YYYY-MM-DD HH:MM:SS.
If not stated then the Start_time is calculated due to the formula: [current time - limit x interval].
End_time (optional) Example: 2020-08-30 20:13:35
Retrieves information up to the date and time in the following format: YYYY-MM-DD HH:MM:SS.
If not stated then the end_time is the current time.
Call example: https://tokpie.com/api_candlestick/?pair=OMG@ETH&limit=2&interval=240
Return information sample:
…{
    "is_ok": true,
    "result": [{
        "29.08.2020 08:31:02", // Open time
        “0.012940000000000000", // Open price
        “0.012940000000000000", // High price
        “0.012940000000000000", // Low price
        “0.012940000000000000", // Close price
        “52.000000000000000000", // Volume
        “29.08.2020 12:31:02", // Close time
 },
        "29.08.2020 12:31:02", // Open time
        “0.012940000000000000", // Open price
        “0.012850000000000000", // High price
        “0.012940000000000000", // Low price
        “0.012940000000000000", // Close price
        “141.000000000000000000", // Volume
        “29.08.2020 16:31:02", // Close time
        ]
    }
}…
                        
Fields description: Open time – The UTC date and time of the candlestick’s start.
Open price – price of base currency based on given quote currency on the moment of candlestick’s open time
High price – highest price of base currency based on given quote currency during candlestick’s time interval
Low price – lowest price of base currency based on given quote currency during candlestick’s time interval
Close price – price of base currency based on given quote currency on the moment of candlestick’s close time
Volume – Transaction amount in BASE currency
Close time – The UTC date and time of the candlestick’s end.


7. History. Retrieves a full order history with order ID, volume and price for a given pair. Fields include:

Method name: historical_trades/pair
Type of request: GET
Incoming parameters: Pair
example: OMG@ETH
Call example: https://tokpie.com/api_historical_trades/?pair=OMG@ETH
Return information sample:
…{
    "is_ok": true,
    "result": [{
        "aht_type": "buy",
        “aht_id”: "225280",
        “aht_datetime”: "20.08.2020 11:30:06 UTC",
        “aht_volume”: "65",
        “aht_price”: "aht_price",
 },
        "aht_type": "buy",
        “aht_id”: "225276",
        “aht_datetime”: "20.08.2020 11:29:17 UTC",
        “aht_volume”: "40",
        “aht_price”: "0.00948",}

        ]
    }
}…

                        
Fields description: aht_type - Designates whether or not the trade originated as a buy or a sell.
Buy – Identifies an ask was removed from the order book.
Sell – Identifies a bid was removed from the order book.
aht_id - The unique ID related only to this currency pair associated with this trade
aht_datetime - The UTC date and time of the trade execution
aht_volume - Trade (transaction) amount in BASE currency
aht_price - Transacted price of base currency based on given quote currency


8. DeFi Public API. Decentralized Finance (DeFi) API allowing to retrieve promissory notes trading data is coming soon.



9. Private (trade) API.

Create Order

Method name: add_order/pair/key
Type of request: POST
Incoming parameters: The following parameters should be added to the request body:
Key
Example: 18bef029-b9513-1931-92jf-632f809m5gf1
The key allows to identify a user. Get your trade API key here.

Pair
Example: OMG@ETH
Pair name from the list of existing enabled market pairs. Base currency @ quote currency.

Type
Example: buy
Type (side) of a trade order. Valid values: 'sell, 'buy'.

Volume
Example: 156.35
Amount of base currency.

Price
Example: 0.0045
Price nominated in quote currency

Expire_tm
Example: 39
Number of minutes after which an order will be automatically cancelled. If expire_tm = 0 then a trade order will not be auto- cancelled.
Call example: https://tokpie.com/api_add_order/?api_key=18bef029-b9513-1931-92jf-632f809m5gf1&pair=OMG@ETH&type=buy&volume=156.35&price=0.00457&expire_tm=39
Return information sample:
…{
    "is_ok": true,
    "result": [{
         aao_added_request_id	: 252094
                        
Fields description: aao_added_request_id – the identification number (ID) of the successfully created order for trade.


10. Websocket Messages.

Tokpie’s WebSocket makes persistent connections available. You can send and receive messages in a non-simultaneous way. WebSocket base URL request at ws://tokpie.com:8222. Message encoding: JSON.

Every WebSocket session is live for 90 seconds. After 90 seconds of inactivity, you will be disconnected. To ensure that your session remains active, send a ping frame before you reach the 90 second timeout.

Trades

Subscribes to the recent trades feed for a specified market by subscribing to the topic tradeHistory with the market names appended to it. The market names can be obtained from ticker API. The websocket feed will send over a snapshot of the last 24 recent trades.

Method name: ws://tokpie.com:8222
Type of request: JSON
Incoming parameters: pair
Example: OMG@ETH
Subscribe:
{
   "sws_operation":"swsOperationSubscribe",
   "sws_pair":"OMG@ETH"
}
                        
Unsubscribe:
{
   "sws_operation":"swsOperationUnsubscribe",
   "sws_pair":"OMG@ETH"
}
                        
A sample JSON payload to subscribe to recent trade message:
{
    "op":"subscribe",
    "args":["tradeHistory:OMG@ETH"]
}
                    
A sample JSON payload to unsubscribe to recent trade message:
{
    "op":"unsubscribe",
    "args":["tradeHistory:OMG@ETH"]
}
                    
Return information sample:
{
    "topic": "tradeHistory:OMG@ETH",
    "data": [{
        "pair": "OMG@ETH",
        "aht_type": "SELL",
        "aht_volume": 100.07,
        "aht_price": 3.83,
        "aht_id": 225280,
        "aht_datetime": 20.01.2021 10:54:18 UTC
    }]
}
                    
Fields description: aht_type - Designates whether or not the trade originated as a buy or a sell.
Buy – Identifies an ask was removed from the order book.
Sell – Identifies a bid was removed from the order book.
aht_id - The unique ID related only to this currency pair associated with this trade.
aht_datetime - The UTC date and time of the trade execution.
aht_volume - Trade (transaction) amount in BASE currency.
aht_price - Transacted price of base currency based on given quote currency.