API-methods

Request

Обратите внимание, текущая версия API может незначительно измениться.

Request-response

Each request to platfrom's API is JSON using POST method or GET without request body. All requests should be send to this url: https://api.bitflip.cc/method/METHOD.

METHOD – one of availables methods from list below.

Request body is JSON as hash-structure:

{"version": "1.0","nonce": 0,"argument": "...value"}

version (optional) – preferect API version. Default is latest available.

nonce (optional) – if nonce is passed you cant make request with nonce lower than previos request was done. Its int64. Default is 0.

Response is unified and represents list structure:

[error, response]

error – null or string with error code.

response – result of request, it may vary onn method you call.

There are meta information in response headers:

X-Server-Time – server time UNIX TIMESTAMP * 1000 (UTC)

X-API-Version – current version of API used for request

Public and private methods

There are public and private methods. Public methods are opened and available to quering for all. Private methods require sepcial API-token you can create in userspace to use it for authentification purpose.

Private methods accept token and signature in request headers. Token should be passed in header with name X-API-Token. Signature in header with name X-API-Sign.

Signature

To make signature you should take your POST-request as string with token secret and make HMAC sha-512 of it.

For example, our secret key is top-secret. Our json-body is {"version": 1.0}. Signature in that case will be created as HMAC sha512. Signature: fb909103d8177205a227a1f58079e4bda61be8e32faa71cd1ae17487651b42c3676073f827d208b53e8198ca231a3259cafeeb7521932e6e1f4ac7d177055d09

Examples

Request:

curl -H 'Content-type: application/json' -d '{"version": "1.0"}' https://api.bitflip.cc/method/server.getTime

Response:

[null, 1499927970357]

Error codes

If something went wrong you will get error code as a string.

e_api_version_not_found – wrong API version.

e_api_method_not_found – there is no such method in requested API-version.

e_api_token_not_found – check you token you provide in header X-API-Token.

e_api_token_inactive – that token you passed in header is disabled.

e_api_sign_incorrect – check signature passed in header X-API-Sign.

e_something_went_wrong – it's mysterious error, you can write to us to figure out what is wrong.

e_[field]_required – its required to pass [field] in request body, [field] – id, pair, type, amount, rate, symbbol.

e_[field]_incorrect – its just wrong value for that [field] in request body, [field] – limit, pair, state, symbol, period, locale.

e_[field]_not_found – object type of [field] was not found, just check value of [field] – pair, wallet, order, symbol, locale.

Methods

server.getTime public

Get current server time.

The time is UNIX TIMESTAMP * 1000 (UTC).

Result:

1499940778211

market.getTrades public

Get trades for trading pair.

Request:

pair (required) – trading pair in format of btc:usd.

limit (optional) – limit output. It can be 1 to 500, default is 50.

Result:

[{"id": "QPYRgfwiB9","type": "buy","amount": 0.01,"rate": 3000,"price": 30,"timestamp": 1497768062},"..."]

id – internal string identifier of trade.

type – type: buy or sell.

amount – amount on that trade.

rate – rate for one.

price – total price for whole amount of trade.

timestamp – UNIX TIMESTAMP when trade was made.

market.getUserTrades private

Get list of trades by user of current API-token using trading pair in request arguments.

See market.getTrades.

Get list of orders for trading pair of current user for requested token.

Request:

pair (required) – trading pair in format of btc:usd.

state (optional) – string or list of states, for example [opened, traded] for active orders or closed for executed and closed. By default you will get only active orders.

limit (optional) – limit output. It can be 1 to 500, default is 50.

Result:

[{"id": "QPYRgfwiB9","state": "opened","type": "buy","open_amount": 0.001,"amount": 0.001,"rate": 0.001,"price": 0.000001,"timestamp": 1498215757},"..."]

id – internal string identifier ордера

state – state of order: opened, closed, traded, canceled

amount – amount on that order

rate – rate on that order

price – total price for whole amount

timestamp – UNIX TIMESTAMP of order creation

market.getOrderBook private

Get active orders grouped by rate for trading pair.

Request:

pair (required) – trading pair in format of btc:usd.

type (optional) – string or list of types: buy, sell. Default is [buy, sell].

limit (optional) – limit output. It can be 1 to 500, default is 50.

Result:

{"buy": [{"amount": 0.2,"rate": 2247,"price": 449.4},"..."],"sell": [{"amount": 0.2487343,"rate": 2233,"price": 555.4236919},"..."]}

buy – orders that wanna buy.

sell – orders that wanna sell.

amount – amount on order.

rate – rate for one.

price – total price for whole amount: amount * rate.

market.getPairs public

Get all trading pairs available to request.

Result:

[{"pair": "BTC:USD","enabled": true,"fee": {"maker": 0.001,"taker": 0.0018},"amount": {"min": 0.001,"max": 10000000,"step": 0.00000001},"rate": {"min": 0.001,"max": 10000000,"step": 0.00000001},"price": {"min": 0.001,"max": 10000000,"step": 0.00000001}},"..."]

pair – trading pair as BTC:USD.

enabled – is that pair traded? Boolean value.

fee.maker – fee on order execution as maker on that pair, used best of currency pair or account according to its trading volume for last 30 days.

fee.taker – fee on order execution as taker on that pair.

amount – it contains information about traded coin like minimum, maximum and step for number.

rate – information about rate.

price – information about total price (amount * rate).

market.getSymbols public

Get all symbols traded on platform.

Result:

["USD","RUB","BTC","LTC","ETH","..."]

market.getRates public

Get current rates for all pairs using active orders.

Result:

[{"pair": "USD:EUR","buy": 0,"sell": 0},{"pair": "USD:RUB","buy": 294,"sell": 0.3435902},"..."]

pair – trading pair.

buy – buy rate, if no data available it contains 0.

sell – sell rate, if no data available it contains 0.

market.getOHLC public

Get OHLC data on requested trading pair.

Request:

pair (required) – trading pair in format of btc:usd.

period (optional) – period in hours from 1 to 24. Default is 24.

Result:

{"volume": 0,"high": 0,"low": 0,"open": 0,"close": 0,"ohlc_avg": 0,"hlc_avg": 0}

volume – trade volume.

high – maximum rate during the period.

low – minimum rate during the period.

open – open rate on that period.

close – last rate on that period.

ohlc_avg – average as (open + high + low + close) / 4.

hlc_avg – average as (high + low + close) / 3.

order.get private

Get information about order of current token user using its identifier.

Request:

id – string identifier of order.

Result:

{"id": "QPYRgfwiB9","state": "traded","type": "sell","pair": "BTC:USD","open_amount": 34,"amount": 28.477,"rate": 111,"price": 3160.947,"timestamp": 1498321616}

id – internal string identifier ордера.

state – state of order: opened, closed, traded, canceled.

type – type of order: buy or sell.

pair – trading pair.

open_amount – starting amount on order creation.

amount – current amount on that order.

rate – rate for one.

price – total price on available amount.

timestamp – UNIX TIMESTAMP of order creationg

order.create private

Match and create order.

Request:

pair (required) – trading pair in format of btc:usd.

type (required) – type of order: buy or sell.

amount (required) – amount to buy or sell.

rate (required) – rate for one.

Result:

{"executed": {"amount": 0.001,"min_rate": 111,"max_rate": 111,"price": 0.111},"order": {"id": "QPrHefwiB9","state": "opened","type": "sell","open_amount": 0.001,"amount": 0.001,"rate": 2399,"price": 2.399,"timestamp": 1499944786}}

executed.amount – that amount was closed (bought or sold).

executed.min_rate – minimum rate of executed orders.

executed.max_rate – maximum rate of executed orders.

executed.price – total price for wanted amount.

order – order information if it was not executed on all amount, see order.get.

order.cancel private

Cancel current active order of current token's user.

Request:

id (required) – string identifier of orderа.

Result:

{"id": "QPYRgfwiB9","state": "canceled","type": "sell","open_amount": 1,"amount": 1,"rate": 2399,"price": 2399,"timestamp": 1499944328}

See order.get

wallet.get private

Get all balances for all wallets of current user token.

Request:

id (required) – string identifier of orderька.

Result:

{"id": "QPYRgfwiB9","symbol": "LTC","address": "LQoifHCPS2Vqgt3mk64xmfn1abdfGpgAda","amount": {"available": 1353.71391024,"pending": 2342,"trading": 2144},"timestamp": 1498772107}

id – string identifier of orderька на платформе.

symbol – currency of wallet.

address – it contains address for coins that can be used for topup.

amount.available – available amount.

amount.pending – its temporery blocked amount, for example withdrawal request.

amount.trading – that amount is used for active orders.

timestamp – UNIX TIMESTAMP of latest transaction on this wallet.

wallet.getBySymbol private

Get information for wallet using symbol instead of identifier.

Request:

symbol (required) – string identifier of order, for example LTC.

See wallet.get

wallet.getBalances private

Get all balances for all wallets of current user token.

Result:

[{"id": "QPYRgfwiB9","symbol": "USD","address": "","amount": {"available": 1353.71391024,"pending": 2342,"trading": 2144},"timestamp": 1498772107},"..."]

See wallet.get

wallet.getTransactions private

Get all balances for all wallets of current user token.

Request:

id (required) – string identifier of orderька.

locale (optional) – locale for descriptions: ru, en. Default is ru.

Result:

[{"id": "QNTQJE9uak","desc": "Wallet transfer","state": "confirmed","amount": 0.12199999,"fee": 0,"timestamp": 1500050521},"..."]

id – string identifier of transaction.

desc – description of that transaction.

state – status of transaction: confirmed, pending, processing, canceled.

amount – amount in that transaction. Fees are included.

fee – total amount of fees.

timestamp – UNIX TIMESTAMP of transaction creation.

user.get private

Get current user token information.

Result:

{"id": "QPYRgfwiB9","name": "ro","fee": {"taker": 0.0014,"maker": 0.0007},"trade_volume": {"USD": 0,"BTC": 18.34399996,"LTC": 0.01,"ETH": 0,"DASH": 0,"DOGE": 0,"XRP": 0},"trade_volume_btc": 22.04484664}

id – string identifier of user.

name – name for user.

fee.taker – fees on trading as taker.

fee.maker – fees on trading as maker.

trade_volume – trading volume for last 30 days in each available currency.

trade_volume_btc – trading volume in BTC for last 30 days that used for taker and maker fees deduction.