Skip to content
Daniel Newton edited this page Oct 13, 2017 · 42 revisions

Test address

192.168.1.1:8080

API description

The API is based on HTTP protocol using JSON RPC,HTTP request methods must be POST, URL is: / , Content-Type is: application/json

Request

  • method: Method, String
  • params: Parameters, Array
  • id: Request id, Integer

Response

  • result: Json object, null failed
  • error: Json object, null success,not null failed
  1. code: error code
  2. message: error message
  • id: Request id, Integer

common error codes:

  • 1: invalid argument
  • 2: internal error
  • 3: service unavailable
  • 4: method not found
  • 5: service timeout

Balance API

Balance query

  • method: balance.query
  • params: No fixed parameters, first param is user ID, followed by a list of asset names, if the list is empty, return all the assets of the user
  1. user_id: ID, Integer
  • result: {"asset": {"available": "amount", "freeze": "amount"}}
  • example:
"params": [1, "BTC"]
"result": {"BTC": {"available": "1.10000000","freeze": "9.90000000"}}

Balance update

  • method: balance.update
  • params:
  1. user_id: ID, Integer
  2. asset: Asset, String
  3. business: Type of action, String
  4. business_id: Business ID, Integer (the same user_id, asset, business and business_id can only be executed once)
  5. change: Change amount, String, (negative number means deduct from the balance)
  6. detail: Json object with any extra information
  • result: "success"
  • error code:
  1. repeat update
  2. balance not enough
  • example:
"params": [1, "BTC", "deposit", 100, "1.2345", {"metadata": 123}]
"result": "success"

Balance history

  • method: balance.history
  • params:
  1. user_id: User ID, Integer
  2. asset: Asset name, can be empty
  3. business: Type of action, can be empty or mutiple entries split by ','
  4. start_time: Start time, 0 means no limit, Integer
  5. end_time: End time,0 means no limit, Integer
  6. offset: Offset position, Integer
  7. limit: Record limit, Integer
  • result:
{
    "offset":
    "limit":
    "records": [
        {
            "time": timestamp,
            "asset": asset,
            "business": business,
            "change": change,
            "balance":balance,
            "detail": detail
        }
        ...
    ]

Trading API

Limit order

  • method: order.put_limit
  • params:
  1. user_id: User ID, Integer
  2. market: Market, String
  3. side: 1: list ask, 2: list bid,Integer
  4. amount: Amount, String
  5. price: Price, String
  6. taker_fee_rate: String, taker rate
  7. maker_fee_rate: String, maker reate
  8. source: String, source, max 30 bytes long
  • result: order details
  • error:
  1. balance not enough
  • example:
params: [1, "BTCCNY", 1, "10", "8000", "0.002", "0.001"]

Market order

  • method: order.put_market
  • params:
  1. user_id: User ID, Integer
  2. market: Market, String
  3. side: 1: list ask, 2: list bid,Integer
  4. amount: Amount, String
  5. taker_fee_rate: taker rate
  6. source: String, source, max 30 bytes long
  • result: order details
  • error:
  1. balance not enough
  • example:
params: '[1, "BTCCNY", 1, "10","0.002"]'

Cancel order

  • method: order.cancel
  • params:
  1. user_id: User ID
  2. market: Market
  3. order_id: Order ID
  • result: order details
  • error:
  1. order not found
  2. user not match

Order Transations

  • method: order.deals
  • params:
  1. order_id: Order ID, Integer
  2. offset
  3. limit
  • result:
  • example:
"result": {
    "offset":
    "limit":
    "records": [
        {
            "id": transaction ID
            "time": timestamp
            "user": user ID
            "role": actor 1: Maker, 2: Taker
            "amount": amount
            "price": price
            "deal": transaction amount
            "fee": fee
            "deal_order_id": counterparty transaction ID
        }
    ...
    ]

Order book

  • method: order.book
  • params:
  1. market:
  2. side: direction,1: ask,2: bid
  3. offset:
  4. limit:
  • result:

Order depth

  • method: order.depth
  • params:
  1. market: Market name
  2. limit: Limit, Integer
  3. interval: Interval,String, eg: "1" means intervals of 1 unit, "0" mean no interval
  • result:
"result": {
    "asks": [
        [
            "8000.00",
            "9.6250"
        ]
    ],
    "bids": [
        [
            "7000.00",
            "0.1000"
        ]
    ]
}

Orders pending

  • method: order.pending
  • params:
  1. user_id: User ID, Integer
  2. market: Market, String
  3. offset: Offet, Integer
  4. limit: Limit, Integer
  • result:
  • example:
"params": [1, "BTCCNY", 0, 100]"
"result": {
    "offset": 0,
    "limit": 100,
    "total": 1,
    "records": [
        {
            "id": 2,
            "ctime": 1492616173.355293,
            "mtime": 1492697636.238869,
            "market": "BTCCNY",
            "user": 2,
            "type": 1, // 1: limit order,2: market order
            "side": 2, // 1: ask,2: bid
            "amount": "1.0000".
            "price": "7000.00",
            "taker_fee": "0.0020",
            "maker_fee": "0.0010",
            "source": "web",
            "deal_money": "6300.0000000000",
            "deal_stock": "0.9000000000",
            "deal_fee": "0.0009000000"
        }
    ]
}

Pending order details

  • method: order.pending_detail
  • params:
  1. market:
  2. order_id: Order ID, Interger
  • result:

Orders completed

  • method: order.finished
  • params:
  1. user_id: User ID, Integer
  2. market: Market, String
  3. start_time: Start time, 0 means no limit, Integer
  4. end_time: End time, 0 means no limit, Integer
  5. offset: Offset, Integer
  6. limit: Limit, Integer
  7. side: direction,0 open/not-limited??, 1 ask, 2 bid
  • result:

Order completed details

  • method: order.finished_detail
  • params:
  1. order_id: Order ID, Interger
  • result:

Market API

Market price

  • method: market.last
  • params:
  1. market
  • result: "price"

Market history

  • method: market.deals
  • params:
  1. market:
  2. limit: Integer,not over 10000
  3. last_id: Last id
  • result:
"result": [
    {
        "id": 5,
        "time": 1492697636.238869,
        "type": "sell",
        "amount": "0.1000",
        "price": "7000.00"
    },
    {
        "id": 4,
        "time": 1492697467.1411841,
        "type": "sell",
        "amount": "0.1000"
        "price": "7000.00",
    }
}

User transaction history

  • method: market.user_deals
  • params:
  1. user_id: User ID, Integer
  2. market: Market name, String
  3. offset: Offset, Integer
  4. limit: Limit, Integer
  • result:
"result": [
    "offset":
    "limit":
    "records": [
        {
            "id": transaction ID
            "time": timestamp
            "user": user ID
            "side": direction, 1: ask, 2: bid
            "role": actor, 1: maker, 2: taker
            "amount": amount
            "price": price
            "deal": transaction amount
            "fee": fee
            "deal_order_id": counterparty transaction ID
        }
    ...
    ]
}

KLine

  • method: market.kline
  • params:
  1. market: Market
  2. start: Start time, Integer
  3. end: End time, Integer
  4. interval: Number of seconds, Integer
  • result:
"result": [
    [
        1492358400, time
        "7000.00",  open
        "8000.0",   close
        "8100.00",  high
        "6800.00",  low
        "1000.00"   volume
        "123456.78" turnover
        "BTCCNY"    market name
    ]
]

Market status

  • method: market.status
  • params:
  1. market: Market name
  2. period: Number of seconds, Integer, such as 86400 for the past 24 hours
  • result:
"result": {
    "period": 86400,
    "last": "7000.00",
    "open": "0",
    "close": "0",
    "high": "0",
    "low": "0",
    "volume": "0"
}

Todays market status

  • method: market.status_today
  • params:
  1. market: Market name
  • result:
{
    "open": todays open
    "last": latest price
    "high": high price
    "low":  lowest price
    "deal": 24 hour turnover
    "volume": 24 hour volume
}
Clone this wiki locally