Python3 wrapper

Asyncio API wrapper library over WebSocket protocol, examples included.
Python examples in this doc were made with this library. For more details about usage see examples in repository.

URL: https://github.com/asfin/bitlish-client

JSON-API

URL: https://bitlish.com/api/v1

Method name may be passed

  • in url: https://bitlish.com/api/v1/check_auth
  • as value of call parameter: https://bitlish.com/api/v1?call=check_auth

Parameters may be passed using GET or POST methods:

GET parameters may be passed in URI following the “?” symbol

$ curl -X GET https://bitlish.com/api/v1/trades_depth?pair_id=btceur
{"bid":[{"volume":"12","price":"370"},{"volume":"1","price":"100"}],"pair_id":"btceur","bid_end":"1","ask_end":"1","ask":[{"price":"380","volume":"10.999"},{"volume":"1.899","price":"393.5"},{"price":"393.6","volume":"2"},{"volume":"2.5","price":"393.7"},{"volume":"3.73","price":"393.8"},{"volume":"2.2","price":"394.9"},{"price":"397.2","volume":"2.2"},{"volume":"1.3","price":"397.6"},{"price":"398.2","volume":"4.2"},{"volume":"4.1","price":"398.3"},{"price":"399.3","volume":"3.16"},{"price":"399.5","volume":"4.9"},{"price":"399.8","volume":"4.8"}],"last":"1457539827535581"}

POST parameters may be passed in JSON format, with ‘Content-Type’: ‘application/json’ in header

curl -H "Content-Type: application/json" -X POST https://bitlish.com/api/v1/tickers;
{"btceur":{"prc":"0.0349","sum":"3.2485","min":"377.9000000000000000","max":"391.1","first":"377.9000000000000000","last":"391.1"},"btcrub":{"first":"30620.4","last":"30620.4","min":"30620.4","max":"30620.4","prc":"0","sum":"0.0055"},"btcusd":{"first":"421.9700000000000000","last":"436.9","min":"421.9700000000000000","max":"436.9","prc":"0.0354","sum":"2.8649"}}
$ curl -H "Content-Type: application/json" -X POST -d '{"call":"trades_depth", "pair_id":"btceur"}' https://bitlish.com/api/v1 
{"pair_id":"btceur","bid":[{"volume":"12","price":"370"},{"volume":"1","price":"100"}],"ask_end":"1","bid_end":"1","last":"1457539827535581","ask":[{"volume":"10.999","price":"380"},{"volume":"1.899","price":"393.5"},{"price":"393.6","volume":"2"},{"volume":"2.5","price":"393.7"},{"price":"393.8","volume":"3.73"},{"price":"394.9","volume":"2.2"},{"price":"397.2","volume":"2.2"},{"volume":"1.3","price":"397.6"},{"price":"398.2","volume":"4.2"},{"price":"398.3","volume":"4.1"},{"price":"399.3","volume":"3.16"},{"price":"399.5","volume":"4.9"},{"volume":"4.8","price":"399.8"}]}

WS-API

URL: wss://bitlish.com/ws

All data structures are JSON encoded objects with fields as described below:

Calls:
    token - token
    call - call name,
    data - object with call params,
    mark - arbitrate id for matching with response,

Responses:
    call - call name,
    data - object with params,
    type - type (response/event)
    mark - id of response (the same as used in call)
    error - Error code (additional data about error in data field)
    seen - is this event seen by user in UI
    created - event object creation time
SEND: {"type":"request","token":null,"mark":"1456906008097043","data":null,"call":"tickers"}
RECV: {"call":"tickers","type":"response","data":{"btcusd":{"last":"436.9","prc":"0.0354","max":"436.9","sum":"2.8649","first":"421.9700000000000000","min":"421.9700000000000000"},"btcrub":{"max":"30936.72","sum":"0.0965","first":"30620.4","min":"30620.4","last":"30936.72","prc":"0.0103"},"btceur":{"prc":"0.0349","last":"391.1","first":"377.9000000000000000","min":"377.9000000000000000","sum":"3.2485","max":"391.1"}},"mark":"1456906008097043"}

Public methods


OrderBook

trades_depth - returns first 100 records from each trade pair

Parameter * Type Description
pair_id 0 String trade pair

Request:

trades_depth '{ "pair_id": "btcusd" }'

Response:

{
  "ask" : [
     {
        "price" : "436.9",
        "volume" : "3.73"
     },
     {
        "price" : "439.9",
        "volume" : "0.12"
     },
     {
        "price" : "440",
        "volume" : "4.1"
     },
     ...
  ],
  "ask_end": "0",
  "bid" : [],
  "bid_end": "1",
  "last" : "1456906911797179",
  "pair_id" : "btcusd"
}

Ticker

tickers - summary information about last 24 hours for each trade pair

{
  "btceur" : {
     "first" : "377.9000000000000000",
     "last" : "391.1",
     "max" : "391.1",
     "min" : "377.9000000000000000",
     "prc" : "0.0349",
     "sum" : "3.2485"
  },
  "btcrub" : {
     "first" : "30620.4",
     "last" : "30936.72",
     "max" : "30936.72",
     "min" : "30620.4",
     "prc" : "0.0103",
     "sum" : "0.0965"
  },
  "btcusd" : {
     "first" : "421.9700000000000000",
     "last" : "436.9",
     "max" : "436.9",
     "min" : "421.9700000000000000",
     "prc" : "0.0354",
     "sum" : "2.8649"
  }
}

OHLCV

ohlcv - details for each tick

Parameter * Type Description
time_range 0 Array of ( Micro ts ) time period [from, to]

Request:

ohlcv '{ "time_range": [ "1456905508", null ] }'

Response:

{
  "list" : [
     {
        "data" : {
           "btcrub" : {
              "close" : "30936.7200000000000000",
              "close_ts" : "1456905570641364",
              "high" : "30936.7200000000000000",
              "low" : "30936.7200000000000000",
              "open" : "30936.7200000000000000",
              "open_ts" : "1456905508109709",
              "volume" : "0.0900000000000000"
           }
        },
        "from" : "1456902000",
        "to" : "1456905600"
     },
    ...
  ]
}

History

trades_history - get recent trades

Parameter * Type Description
pair_id 1 String trade pair

Request:

trades_history { "pair_id" : "btceur" }

Response:

{
  "list" : [
     {
        "amount" : 0.01,
        "created" : 1456392338877910,
        "dir" : "bid",
        "price" : 354.68
     },
     {
        "amount" : 0.01,
        "created" : 1456396242529690,
        "dir" : "bid",
        "price" : 354.46
     },
    ...
  ],
  "pair_id" : "btceur"
}

General information

instruments - get list of available currencies

{
  "btc" : {
     "icon" : "",
     "id" : "btc",
     "name" : "BTC",
     "prec" : 5,
     "symbol" : "฿"
  },
  "eur" : {
     "icon" : "$",
     "id" : "eur",
     "name" : "EUR",
     "prec" : 3,
     "symbol" : "€"
  },
  "rub" : {
     "icon" : "",
     "id" : "rub",
     "name" : "RUB",
     "prec" : 3,
     "symbol" : "₽"
  },
  "usd" : {
     "icon" : "",
     "id" : "usd",
     "name" : "USD",
     "prec" : 3,
     "symbol" : "$"
  }
}

pairs - get list of trade pairs
| Parameter | * | Type | Description |
|———–|—|——–| ———|
| currency | 0 | ‘Str’ | Return pairs with selected currency only (currency_id) |

{
  "btceur" : {
     "currency_id" : "eur",
     "id" : "btceur",
     "item_id" : "btc",
     "name" : "BTC/EUR"
  },
  "btcrub" : {
     "currency_id" : "rub",
     "id" : "btcrub",
     "item_id" : "btc",
     "name" : "BTC/RUB"
  },
  "btcusd" : {
     "currency_id" : "usd",
     "id" : "btcusd",
     "item_id" : "btc",
     "name" : "BTC/USD"
  }
}

Private requests


Authentication

Every private API request should be sent with an authentication token.

signin - create session, get a token

Parameter * Type Description
login 1 ‘Str’ login - phone or email
passwd 1 ‘Str’ password
token 0 ‘Str’ token

Request:

signin '{ "login" => "mbittest1@mail.ru", "passwd" => "mypass" }'

Response:

{
  "allowed_ips" : [],
  "ban_signin" : "0",
  "ban_withdraw" : "0",
  "confirmation_level" : "confirmed",
  "currencies" : [
     "rub",
     "btc",
     "ltc",
     "usd",
     "eur"
  ],
  "email" : "mbittest1@mail.ru",
  "ip" : "10.0.8.22",
  "is_guest" : "0",
  "lang" : "en",
  "level" : "user",
  "login" : "mbittest1@mail.ru",
  "mfa_provider" : "none",
  "mfa_signin" : "0",
  "mfa_withdraw" : "0",
  "notify" : "none",
  "password_outdated" : "0",
  "report" : "none",
  "timezone" : "Europe/London",
  "token" : "IT1I+1GAAI/c5tWvsQ7YtFg7VBrUjs5lyqkThYXuT42",
  "trade_confirm" : "1",
  "uid" : "1001"
}

Get user profile info, token, IP-address and uid (user id).

resign - renew token, get the same info as signin

signout - close session

Trades and accounts

Matching rules

Permitted precision of price and amount up to 8 digits.

  1. At the time of the order creation user’s funds are blocked and exchanged further
  2. Order with better price will be executed first.
  3. Orders with the same price will be executed according to the order it was received in (FIFO).
  4. When conditions of two orders are intersecting, the order will be executed using the price of the order received first (e.g. buy for 100, sell for 90).

Order management

It’s possible to create orders of several types depending on parameters as described below.

Each order have a number of properties:

User-defined properties:
    pair_id - trade pair
    dir - direction (bid - buy, ask - sell)
    amount - amount of product
    price - price
    expire - time of cancellation (should not be specified for orders)
    mark - atbitrary order id (string)

Informational properties:
    id - unique id
    created - timestamp of creation
    state - state of order
    amount_done - executed amount 
    amount_free - pending amount of product
    holded - funds on hold on user's account
    send - funds withdrawn for execution
    recv - funds received during execution of order
    fee - funds spent for trade fee
    ofee - maker trade fee, used  in case if this order are providing liquidity (0.01 = 1%)
    mid_price - average price for which the order is executed (it can be matched with several counter orders with different price)

Possible states of the order:

  • new - pending to execute
  • part - partly executed
  • done - completely executed (or partly executed and then cancelled)
  • cancel - completely cancelled

Each operation with orders generates a message event sent throug API.
Every event has common format, object with keys below:

  • ts - event creation time
  • action - action on order
  • diff - object with differences in order’s parameters
  • order - current state of order

Event names:

  • trade_order_create - order created
  • trade_order_match - order executed ( partly or completely - check ‘state’ parameter )
  • trade_order_cancel - order cancelled
  • trade_order_cancel_expire - time limited order cancelled due to timeout

Order creation

create_trade

Parameter * Type Description
pair_id 1 String trade pair
dir 1 String direction of trade ( bid - buy, ask - sell )
amount 1 Number amount of product for buy or sell
price 0 Number price (market order if not specified)
expire 0 Micro timestamp time when the order should be cancelled
mark 0 String arbitrary unique order id
part_match 0 Bool allow the order to be matched partially (default = true)

Request:

create_trade '{ "pair_id": "btcusd", "dir": "ask", "amount": 0.001, "price": 700 }'

Response:

{
    "amount" => "10"
    "amount_done" => "0"
    "amount_free" => "10"
    "created" => "1442241329269148"
    "dir" => "ask"
    "expire" => null,
    "fee" => "0"
    "holded" => "10"
    "id" => "1442241329269190"
    "mark" => null,
    "mid_price" => "0"
    "ofee" => "0.001"
    "pair_id" => "btceur"
    "price" => "300"
    "recv" => "0"
    "send" => "0"
    "state" => "new"
    "type" => "trade"
    "user_id" => 1001
}

Order creation event:

{
  "action" => "create"
  "diff" => {
              "amount" => "10"
              "amount_free" => "10"
              "holded" => "10"
              "state" => "new"
            },
  "order" => {
               "amount" => "10"
               "amount_free" => "10"
               "created" => "1442241329269148"
               "dir" => "ask"
               "id" => "1442241329269190"
               "mid_price" => "0"
               "pair_id" => "btceur"
               "price" => "300"
               "state" => "new"
               "type" => "trade"
             },
  "ts" => "1442241329299764"
}

Market order

Order will be executed for the amount specified without adding into order book.
Market order will be created if parameters price and expire time are not specified.

Limit order

Order with limit by price.

Will be executed by price not worst than specified.
(sell price >= specified price, buy price <= specified)
It will wait for counter order in order book. Can be cancelled.
This type of order will be created if price are specified.

Time-limit order

Will be executed by price not worst than specified.
(sell price >= specified price, buy price <= specified)
It will wait for counter order in order book. Can be cancelled.
It will be cancelled automatically if not executed until specified time.

This type of order will be created if price is specified.

Order cancellation

Orders can be cancelled in these states:

  • new - order will be cancelled completely and change his state to cancel.
  • part - partially executed order, the rest of amount will be cancelled and the order will change his state to done.

cancel_trade - cancel one order by id

Parameter * Type Description
id 1 String order id

Request:

cancel_trade { "id" : 1442241329269190 }

Response:

{
  "amount" => "0"
  "amount_done" => "0"
  "amount_free" => "0"
  "created" => "1442241329269148"
  "dir" => "ask"
  "expire" => null,
  "fee" => "0"
  "holded" => "0"
  "id" => "1442241329269190"
  "mark" => null,
  "mid_price" => "0"
  "ofee" => "0.001"
  "pair_id" => "btceur"
  "price" => "300"
  "recv" => "0"
  "send" => "0"
  "state" => "cancel"
  "type" => "trade"
  "user_id" => 1001
}

Order cancellation event:

{
  "action" => "cancel"
  "diff" => {
              "amount" => "10"
              "amount_free" => "10"
              "holded" => "10"
              "state" => "cancel"
            },
  "order" => {
               "amount" => "0"
               "amount_done" => "0"
               "amount_free" => "0"
               "created" => "1442241329269148"
               "dir" => "ask"
               "expire" => null,
               "fee" => "0"
               "holded" => "0"
               "id" => "1442241329269190"
               "mark" => null,
               "mid_price" => "0"
               "ofee" => "0.001"
               "pair_id" => "btceur"
               "price" => "300"
               "recv" => "0"
               "send" => "0"
               "state" => "cancel"
               "type" => "trade"
               "user_id" => 1001
             },
  "ts" => "1442251616720575"
}

cancel_trades_by_ids - cancel several orders by list of ids

Parameter * Type Description
ids 0 Array of ( Number ) список идентификаторов

Request:

cancel_trades_by_ids '{ "ids": [ 1456912337770541, 1456911814615664 ] }'

Response:

{
  "count" : 2
}

cancel_all_trades - cancel all orders (no parameters required)

List of own orders

list_active_trades - list of all active orders (new and part)

Parameter * Type Description
pair_id 0 String trade pair

Request:

list_active_trades '{ "pair_id": "btceur" }'

Response:

{
  "list" : [
     {
        "amount" : "0.001",
        "amount_done" : "0",
        "amount_free" : "0.001",
        "created" : 1456911814615598,
        "dir" : "ask",
        "expire" : null,
        "fee" : "0",
        "holded" : "0.001",
        "id" : 1456911814615664,
        "mark" : null,
        "mid_price" : "0",
        "ofee" : "0.001",
        "pair_id" : "btcusd",
        "price" : "700",
        "recv" : "0",
        "send" : "0",
        "state" : "new",
        "type" : "trade",
        "user_id" : 1001
     }
  ]
}

list_my_trades - search for orders by filtres

Parameter * Type Description
id 0 String order id
dir 0 String direction (ask - sell, bid - buy)
pair_id 0 String trade pair
price 0 Array of ( Number ) price range [ from, to ]
amount 0 Array of ( Number ) amount range [ from, to ]
expire 0 Array of ( Micro ts ) time range [ from, to ]
mark 0 String arbitrary id specified on creation
state 0 Array of ( String ) list of states ( new/part/done/cancel )
sort 0 Array of ( Object of ( String => String ) ) list of objects, key as name (id/created/amount/price/amount_done/state/expire), value as sort direction (asc/desc).
page 0 Number page number
limit 0 Number records per page

Request:

list_my_trades '{ "pair_id": "btcusd", "state": ["cancel", "done"], "limit": 1 }

Response:

{
  "limit" : 1,
  "list" : [
     {
        "amount" : "0.98",
        "amount_done" : "0.98",
        "amount_free" : "0",
        "created" : 1455561804270658,
        "dir" : "ask",
        "expire" : null,
        "fee" : "0.3430000000000000",
        "holded" : "0",
        "id" : 1455561804270917,
        "mark" : null,
        "mid_price" : "350",
        "ofee" : "0.0010000000000000",
        "pair_id" : "btcusd",
        "price" : "350.0000000000000000",
        "recv" : "342.6570000000000000",
        "send" : "0.9800000000000000",
        "state" : "done",
        "type" : "trade",
        "user_id" : 1001
     }
  ],
  "page" : "1",
  "pages" : "4"
}

trade_details - detailed information about order

Parameter * Type Description
id 1 String order id

Request:

trade_details '{ "id": 1455561804270917 }'

Response:

   {
      "amount" : "0.98",
      "amount_done" : "0.98",
      "amount_free" : "0",
      "created" : 1455561804270658,
      "deals" : [
         {
            "amount" : "0.98",
            "created" : 1455561804292327,
            "id" : 1455561804292336,
            "price" : "350",
            "state" : "done"
         }
      ],
      "dir" : "ask",
      "expire" : null,
      "fee" : "0.3430000000000000",
      "holded" : "0",
      "id" : 1455561804270917,
      "mark" : null,
      "mid_price" : "350",
      "ofee" : "0.0010000000000000",
      "pair_id" : "btcusd",
      "price" : "350.0000000000000000",
      "recv" : "342.6570000000000000",
      "send" : "0.9800000000000000",
      "state" : "done",
      "transfers" : [
         {
            "amount" : "0.98",
            "direction" : "hold",
            "ext_fee" : "0",
            "group_id" : "1455561804302553",
            "id" : "229",
            "instrument_id" : "btc",
            "notes" : "Hold funds on ask order: 0.98 BTC for 343 USD",
            "operation" : "trade_create",
            "order_id" : "1455561804270917",
            "our_fee" : "0",
            "ts" : "1455561804310062",
            "type" : "hold"
         },
         {
            "amount" : "342.657",
            "direction" : "both",
            "ext_fee" : "0",
            "group_id" : "1455561804302553",
            "id" : "230",
            "instrument_id" : "usd",
            "new_amount" : "0.9800000000000000",
            "new_instrument_id" : "btc",
            "notes" : "Sell 0.98 BTC ( for 343 USD )",
            "operation" : "trade_match",
            "order_id" : "1455561804270917",
            "our_fee" : "0.343",
            "ts" : "1455561804322570",
            "type" : "transfer"
         }
      ],
      "type" : "trade",
      "user_id" : 1001
   }

list_my_trads_from_ts - list of orders executed after time specified

Request:

list_my_matches_from_ts '{ "pair_id": "btcusd", "from_ts": 1455561804000000, "limit": 1 }'

Response:

{
  "from_id" : null,
  "from_ts" : "1455561804000000",
  "limit" : "1",
  "list" : [
     {
        "amount" : "0.9800000000000000",
        "dir" : "ask",
        "id" : "1455561804292336",
        "order_id" : "1455561804270917",
        "pair_id" : "btcusd",
        "price" : "350.0000000000000000",
        "ts" : "1455561804292327"
     }
  ],
  "pair_id" : "btcusd"
}

Get information on accounts

Every user have varios accounts in the system, one account for one currency.
Account are separated by 3 parts:

  • funds - funds available for operations
  • holded - funds on hold (for orders, for withdrawals, etc.)
  • fee - funds spent to pay fees

On each change in accounts an event ‘balances’ will be sent.
Each key in this object are curreny and value - a object with information about this account.

Example:

{
  "btc" : {
     "fee" : "0",
     "funds" : "999.02",
     "holded" : "0"
  },
  "eur" : {
     "fee" : "0",
     "funds" : "0",
     "holded" : "0"
  },
  "rub" : {
     "fee" : "0",
     "funds" : "1000",
     "holded" : "0"
  },
  "usd" : {
     "fee" : "0.343",
     "funds" : "1342.657",
     "holded" : "0"
  }
}

This information can be obtained using API-call balance (without parameters)

Accounts’ history

accounts_operations - get operations with pagination

Parameter * Type Description
instrument_id 0 String currency name (btc/usd/eur/rub)
type 0 String type of operation (transfer/withdraw/deposit/hold)
nohide 0 Bool (0/1) show all operation including hold (by default 0)
operation 0 Array of ( String ) list of operations (trade_match/trade_create/trade_cancel/trade_cancel_expire/adm_withdraw/adm_deposit/adm_transfer/adm_hold/deposit/withdraw)
amount 0 Array of ( Number ) amount range [ from, to ]
ts 0 Array of ( Micro ts ) time range [ from, to ]
sort 0 Array of ( Object of ( String => String ) ) list of objects, key - field name (instrument_id/type/amount/ts), value - sort direction (asc/desc).
page 0 Number page number
limit 0 Number records per page

Request:

accounts_operations '{ "page": 7, "limit": 2 }'

Response:

{
  "limit" : 2,
  "list" : [
     {
        "amount" : "0.001",
        "direction" : "hold",
        "ext_fee" : "0",
        "group_id" : "1456911400014321",
        "id" : "318",
        "instrument_id" : "btc",
        "notes" : "Hold funds on ask order: 0.001 BTC for 0.7 USD",
        "operation" : "trade_create",
        "order_id" : "1456911399985635",
        "our_fee" : "0",
        "ts" : "1456911400024950",
        "type" : "hold"
     },
     {
        "amount" : "-0.001",
        "direction" : "unhold",
        "ext_fee" : "0",
        "group_id" : "1456911673240700",
        "id" : "319",
        "instrument_id" : "btc",
        "notes" : "Release funds on request cancel",
        "operation" : "trade_cancel",
        "order_id" : "1456911399985635",
        "our_fee" : "0",
        "ts" : "1456911673241750",
        "type" : "hold"
     }
  ],
  "page" : 7,
  "pages" : "9"
}

list_accounts_operations_from_ts - get opeations before or after specified time

Parameter * Type Description
instrument_id 0 String currency name (btc/usd/eur/rub)
type 0 String type of operation (transfer/withdraw/deposit/hold)
operation 0 Array of ( String ) list of operations (trade_match/trade_create/trade_cancel/trade_cancel_expire/adm_withdraw/adm_deposit/adm_transfer/adm_hold/deposit/withdraw)
nohide 0 Bool (0/1) show all operation including hold (by default 0)
ts 0 Micro ts time mark
dir 0 String direction ( > - after specified ts, < - before specified ts )
limit 0 Number maximum number of records to return

Request:

list_accounts_operations_from_ts '{ "ts": 1456911400024950, "dir": "<", "limit": 2 }'

Response:

{
  "dir" : "<",
  "limit" : 2,
  "list" : [
     {
        "amount" : "342.657",
        "direction" : "both",
        "ext_fee" : "0",
        "group_id" : "1455561804302553",
        "id" : "230",
        "instrument_id" : "usd",
        "new_amount" : "0.9800000000000000",
        "new_instrument_id" : "btc",
        "notes" : "Sell 0.98 BTC ( for 343 USD )",
        "operation" : "trade_match",
        "order_id" : "1455561804270917",
        "our_fee" : "0.343",
        "ts" : "1455561804322570",
        "type" : "transfer"
     },
     {
        "amount" : "0.001",
        "direction" : "income",
        "ext_fee" : "0",
        "group_id" : "1454686743380838",
        "id" : "137",
        "instrument_id" : "ltc",
        "notes" : "deposit from payment system \"litecoin\", currency: ltc",
        "operation" : null,
        "order_id" : null,
        "our_fee" : "0",
        "ts" : "1454686743438505",
        "type" : "deposit"
     }
  ],
  "ts" : "1456911400024950"
}

trade_options - get information on trade conditions

Deposits and withdrawals

Get information

list_payment_methods - get the list of available payment methods and limits

Parameter * Type Description
currency 1 Str currency
direction 1 Str direction (withdraw, deposit)
payment_method 0 Str payment type
# python3
resp = yield from api.list_payment_methods({
    'direction': 'withdraw',
    'currency': 'eur',
})
pprint(resp['data'])
{'payment_methods': [{'available': '1',
                      'currency': 'eur',
                      'decimal_precision': 5,
                      'direction': 'withdraw',
                      'display_name': 'Bank transfer',
                      'display_name_ru': 'Банковский перевод',
                      'enabled': 0,
                      'fee': {'amount': 50,
                              'prc': 0.025,
                              'type': 'compound'},
                      'limits': [{'avail': '200',
                                  'limit': 200,
                                  'period': '2592000',
                                  'sum': '0'},
                                 {'avail': '50',
                                  'limit': 50,
                                  'period': '86400',
                                  'sum': '0'}],
                      'max_payment_size': 10000,
                      'min_payment_size': 5,
                      'nearest': 1,
                      'payment_method': 'bank_account',
                      'pm_conf': {'decimal_precision': 5,
                                  'display_name': 'Bank transfer',
                                  'display_name_ru': 'Банковский перевод',
                                  'enabled': 0,
                                  'fee': {'amount': 50,
                                          'prc': 0.025,
                                          'type': 'compound'},
                                  'limits': [],
                                  'max_payment_size': 10000,
                                  'min_payment_size': 1,
                                  'our_min_pay_size': 5,
                                  'paysystem': 'bank',
                                  'priority': 100},
                      'priority': 100,
                      'ps_type': 'bank'}]}

list_payments - get list of payments filtered and sorted

Parameter * Type Description
id 1 Str payment id
paysystem 1 Str paysystem
currency 0 Str currency
direction 0 Str direction (withdraw, deposit)
state 0 Str state (new,payed,done,rollback,error,need_check)
amount 0 Num,Num amount
created 0 Num,Num creation time
confirms_cnt 0 Num number of confirmations
page 0 Number page number
limit 0 Number number of records on page
sort 0 Array of ( Object of ( String => String ) ) list of objects, key - name of field (id/created/amount/price/amount_done/state/expire), value - sorting direction (asc/desc).
# python3
resp = yield from api.list_payments({
    'limit': 1,
})
pprint(resp['data'])
# shell
curl https://bitlish.com/api/v1/list_payments -w %{response_code} -H 'Content-Type: application/json' --data-raw '{"token": "fixed:...", "direction": "withdraw", "currency": "rub"}'
{'amount': 9863.3077808,
 'amount_f': 10657.66869517,
 'fee': 794.36091437,
 'from_amount': 10637.7637808,
 'limit': 1,
 'list': [{'amount': '100.00000000',
           'amount_f': '100.00000000',
           'confirms_cnt': '1',
           'created': '1446916340',
           'currency': 'rub',
           'deposit_wallet_id': '1446916146694879',
           'direction': 'deposit',
           'errcode': None,
           'fee': '0.00000000',
           'from_amount': '100.00000000',
           'from_currency': 'rub',
           'group_id': None,
           'id': '133',
           'invoice': '1446916146694775',
           'mark': None,
           'our_fee': '4.50000000',
           'paysystem': 'okpay:rub',
           'state': 'done',
           'txid': '4809966',
           'updated': None,
           'user_confirm': '-1',
           'user_id': '1001',
           'user_notes': None,
           'withdraw_wallet_id': None}],
 'our_fee': 1370.516,
 'page': 1,
 'pages': 105}

Deposits

deposit - get information required for deposit. On receiving this information and further changes an event payment_info will be sent.
For bitcoin is_invoice forces to get new address. Please note that is_invoice field from response have different meaning.

Parameter * Type Description
payment_method 1 Str payment type
currency 1 Str currency
amount 0 Num amount
is_invoice 0 Bool forces to create new invoice number(if applicable)

Request:

# python3
resp = yield from api.deposit({
    'payment_method': 'bitcoin',
    'currency': 'btc',
    'is_invoice': 1,
})
pprint(resp['data'])
# shell
curl https://bitlish.com/api/v1/deposit -w %{response_code} -H 'Content-Type: application/json' --data-raw '{"token": "fixed:...", "payment_method": "bitcoin", "currency": "btc"}'

Response:

{'account': '1248VjPfEaNchbXbW2uQ81AhmV3RVWgmuz',
 'amount': None,
 'currency': 'btc',
 'direction': 'deposit',
 'id': '1466067262102971',
 'invoice': None,
 'is_invoice': '0',
 'minimal_amount': None,
 'other_data': None,
 'payment_method': 'bitcoin',
 'paysystem': 'bitcoin:btc',
 'ps_type': None,
 'type': 'bitcoin',
 'user_id': '1001'
}

Withdrawals

create_template_wallet - validates input and returns wallet id which can be used for withdrawals.
All parameters are optional and real requirements depends on selected payment_method.

Parameter * Type Description
payment_method 1 Str payment type
account 1 Str account number or any other identifier
currency 0 Str currency
exp_date 0 Str for withdrawals to bank cards: expiry date. e.g. ‘12/16’
name 0 Str name of cardholder or beneficiary
address 0 Str address
phone 0 Str phone number
is_template 0 Str pin this wallet as “favorite” in UI
user_notes 0 Str any associated notes, 128 chars max
bank_name 0 Str for bank withdrawals: bank name
bank_iban 0 Str for bank withdrawals: IBAN
bank_swift_bic 0 Str for bank withdrawals: SWIFT

Request:

# python3
resp = yield from api.create_template_wallet({
    'payment_method': 'bitcoin',
    'account': '1248VjPfEaNchbXbW2uQ81AhmV3RVWgmuz',
})
pprint(resp['data'])
# shell
curl https://bitlish.com/api/v1/create_template_wallet -w %{response_code} -H 'Content-Type: application/json' --data-raw '{"token": "fixed:...", "payment_method": "bitcoin", "account": "1248VjPfEaNchbXbW2uQ81AhmV3RVWgmuz"}'

Response:

{'account': '1248VjPfEaNchbXbW2uQ81AhmV3RVWgmuz',
 'created': 1472645753,
 'enabled': 1,
 'id': '1472645753410160',
 'is_template': 1,
 'other_data': {},
 'supported_currencies': {'btc': 1},
 'supported_paysystems': {'bitcoin:btc': 1},
 'type': 'bitcoin',
 'updated': 1472645753,
 'user_id': '1001',
 'user_notes': None}

withdraw_by_id - create withdrawal request to selected wallet. Returns list of payments which will be performed(Note about max single payment size of selected paysystem).

Parameter * Type Description
wallet_id 1 Str id of wallet returned from create_template_wallet call
currency 1 Str currency
amount 1 Num amount to withdraw
mark 0 Str arbitrary mark that can be assigned to payment on creation for further tracking, guaranteed to be uniq
autorounding 0 Bool if requested amount have too high precision(e.g. 1.256 EUR) allows to round value automatically

Request:

# python3
resp = yield from api.withdraw_by_id({
    'wallet_id': '1472645753410160',
    'amount': 0.01,
    'currency': 'btc',
})
pprint(resp['data'])
# shell
curl https://bitlish.com/api/v1/withdraw_by_id -w %{response_code} -H 'Content-Type: application/json' --data-raw '{"token": "fixed:...", "wallet_id": "1472645753410160", "amount": "0.01", "currency": "btc"}'

Response:

{'payments': [{'amount': '0.01',
               'amount_f': '0.009',
               'confirms_cnt': '0',
               'created': '1472648184',
               'currency': 'btc',
               'deposit_wallet_id': None,
               'direction': 'withdraw',
               'errcode': None,
               'fee': None,
               'from_amount': '0.01',
               'from_currency': 'btc',
               'group_id': None,
               'id': '5939',
               'invoice': '14726481845939',
               'mark': None,
               'our_fee': '0.001',
               'paysystem': 'bitcoin:btc',
               'state': 'new',
               'txid': None,
               'updated': None,
               'user_confirm': '-1',
               'user_id': '1001',
               'user_notes': None,
               'withdraw_wallet_id': '1472645753410160'}]}

withdraw - create withdrawal request.

If the profile has enabled two-factor authentication for withdrawals,
then request should be confirmed by calling user_confirm_withdraw.
The request will be made after it is approved by the operator.
On every change in request’s status events are sent as payment_info.

Parameter * Type Description
payment_method 1 Str payment type
account 1 Str account number or any other identifier
amount 1 Num amount
currency 1 Str currency
mark 0 Str arbitrary mark that can be assigned to payment on creation for further tracking, guaranteed to be uniq
exp_date 0 Str expire date of bank card: like ‘12/16’
name 0 Str name of cardholder or beneficiary
address 0 Str address
phone 0 Str phone number
user_notes 0 Str any associated notes, 128 chars max
bank_name 0 Str for bank withdrawals: bank name
bank_iban 0 Str for bank withdrawals: IBAN
bank_swift_bic 0 Str for bank withdrawals: SWIFT

Request:

# python3
resp = yield from api.withdraw({
    'payment_method': 'bitcoin',
    'account': '1248VjPfEaNchbXbW2uQ81AhmV3RVWgmuz',
    'amount': 0.002,
    'currency': 'btc',
})
pprint(resp['data'])
# shell
curl https://bitlish.com/api/v1/withdraw -w %{response_code} -H 'Content-Type: application/json' --data-raw '{"token": "fixed:...", "payment_method": "bitcoin", "account": "1248VjPfEaNchbXbW2uQ81AhmV3RVWgmuz", "amount": "0.002", "currency": "btc"}'

Response:

{'payments': [{'amount': '0.002',
               'amount_f': '0.001',
               'confirms_cnt': '0',
               'created': '1472648916',
               'currency': 'btc',
               'deposit_wallet_id': None,
               'direction': 'withdraw',
               'errcode': None,
               'fee': None,
               'from_amount': '0.002',
               'from_currency': 'btc',
               'group_id': None,
               'id': '5940',
               'invoice': '14726489165940',
               'mark': None,
               'our_fee': '0.001',
               'paysystem': 'bitcoin:btc',
               'state': 'new',
               'txid': None,
               'updated': None,
               'user_confirm': '-1',
               'user_id': '1001',
               'user_notes': None,
               'withdraw_wallet_id': '1472645753410160'}]}

B-codes

Response parameter direction values means:
-1 - created
1 - activated
0 - created and activated

Create

create_bcode - creates B-code.

Parameter * Type Description
instrument_id 1 String currency
amount 1 Num amount

Request:

# python3
resp = yield from api.create_bcode({
    'instrument_id': 'usd',
    'amount': 100,
})
pprint(resp['data'])
# shell
curl https://bitlish.com/api/v1/create_bcode -w %{response_code} -H 'Content-Type: application/json' --data-raw '{"token": "fixed:...", "instrument_id": "usd", "amount": 100}'

Response:

{'amount': '100',
 'code': 'B-USD-BBUKZ5-V6F9EP-7C4XFU-NMQSRD-4Z8PEP',
 'created': '1472654414548650',
 'direction': '-1',
 'id': '1',
 'instrument_id': 'usd'}

Activate

redeem_code - activates B-code.

Parameter * Type Description
code 1 Str B-code

Request:

# python3
resp = yield from api.redeem_bcode({
    'code': 'B-USD-BBUKZ5-V6F9EP-7C4XFU-NMQSRD-4Z8PEP',
})
pprint(resp['data'])
# shell
curl https://bitlish.com/api/v1/redeem_bcode -w %{response_code} -H 'Content-Type: application/json' --data-raw '{"token": "fixed:...", "code": "B-USD-BBUKZ5-V6F9EP-7C4XFU-NMQSRD-4Z8PEP"}'

Response:

{'amount': '100.0000000000000000',
 'applied': '1472654364026125',
 'code': 'B-USD-BBUKZ5-V6F9EP-7C4XFU-NMQSRD-4Z8PEP',
 'created': '1472654319592708',
 'direction': '0',
 'id': '1',
 'instrument_id': 'usd'}

Get info

list_bcodes - get info about created and activated codes

Parameter * Type Description
id 0 Str identifier
code 0 Str B-code
instrument_id 0 Str currency
created 0 Str creation date
amount 0 Str amount
sort 0 Array of ( Object of ( String => String ) ) list of objects, key - field name (instrument_id/type/amount/ts), value - sort direction (asc/desc).
page 0 Num page number
limit 0 Num records per page

Request:

# python3
resp = yield from api.list_bcodes({
    'limit': 1,
})
pprint(resp['data'])
# shell
curl https://bitlish.com/api/v1/list_bcodes -w %{response_code} -H 'Content-Type: application/json' --data-raw '{"token": "fixed:...", "limit": 1}'

Response:

{'limit': 1,
 'list': [{'amount': '100.0000000000000000',
           'code': 'B-USD-BBUKZ5-V6F9EP-7C4XFU-NMQSRD-4Z8PEP',
           'created': '1472654414548650',
           'direction': '-1',
           'id': '1',
           'instrument_id': 'usd'}],
 'page': '1',
 'pages': '3'}