AlienCloud API

All data is send in JSON format with UTF8 encoding. Specify in the request headers Content-Type: application/json

REST API: https://aliencloud.xyz/api/1.0
Stream API: https://aliencloud.xyz/ws


Authorization

To create and get orders, you need to pass authorization by token. To do this, get a token in your account and send it in each request in the header:

Authorization: Bearer AqyWUZWlFTdxNkDmv2222MsyFQZoCH00t3fm7p1lSq1111JQNWnbHK262D3333_g

Trade: REST API

POST /api/1.0/trade/create-order

Create order

Request:

{
    "pairName": "btc_usd",      // Pair name
    "tradeType": "limit"        // Trade type: "limit" or "market"
    "directionType": "buy",     // Direction: "buy" or "sell"
    "price": 6541.21,           // Order price, required for limit
    "amount": 1.002,            // Order amount
}

Response 200:

{
    "id": 820,                              // Order unique ID
    "pairName": "btc_usd",                  // Pair name
    "tradeType": "limit",                   // Trade type: "limit" or "market"
    "directionType": "sell",                // Direction: "buy" or "sell"
    "price": 6609.37,                       // Order price
    "amount": 0.000002,                     // Order amount
    "amountUsed": 0,                        // Used amount. Order will be fully executed when amount = amountUsed.
    "isCancelled": false,                   // True, when cancelled by user
    "createTime": "2018-01-01 05:38:51",    // Order create time
    "updateTime": "2018-01-01 05:38:51",    // Order last update time
}

Response 400:

{
    "errors": {
        "amount": [
            "Not enough funds on balance"
        ]
    }
}

POST /api/1.0/trade/cancel-order

Cancel order

Request:

{
    "orderId": 820",  // Order ID
}

Response 200:

[]

Response 400:

{
    "errors": {
        "orderId": [
            "Order already canceled"
        ]
    }
}

GET /api/1.0/trade/pairs

Get exchanges for all pairs

Response 200:

[
    {
        "pairName": "btc_usd",
         "openValue": 6421.42,
         "minValue": 6421.42,
         "maxValue": 6624.85,
         "closeValue": 6609.37,
         "volume": 546.32
    }
]

GET /api/1.0/trade/pairs/{pairName}

Get initial data for pair page:
   - exchanges for all pairs
   - all aggregated orders
   - last 200 history items
   - last 200user orders for all pairs (return null for non-authenticated request)
   - last 200user history for all pairs (return null for non-authenticated request)

Response 200:

{
    "exchanges": [
        {
            "pairName": "btc_usd",  // Pair name
            "openValue": 6421.42,   // Open value 24h
            "minValue": 6421.42,    // Min value 24h
            "maxValue": 6624.85,    // Max value 24h
            "closeValue": 6609.37,  // Close value 24h (current exchange)
            "volume": 546.32        // Volume 24h
        }
    ],
    "orders": {
        "buy": [
            {
                "price": 6543.61,   // Order price
                "amount": 0.007917  // Aggregate order amounts for this price
            }
        ],
        "sell": [
            {
                "price": 6624.85,   // Order price
                "amount": 0.007147  // Aggregate order amounts for this price
            }
        ]
    },
    "history": [
        {
            "directionType": "sell"                 // Direction type: "buy" or "sell"
            "tradeType": "limit",                   // Trade type: "limit" or "market"
            "price": 6421.42,                       // Order price
            "amount": 0.000004,                     // Order amount
            "tradeTime": 1541221598,                // Trade execute timestamp in seconds
            "eventTimeMicro": "1541221598929761",   // Event time in microseconds
        }
    ],
    "userOrders": [
        {
            "id": 820,                              // Order unique ID
            "pairName": "btc_usd",                  // Pair name
            "directionType": "sell",                // Direction: "buy" or "sell"
            "tradeType": "limit",                   // Trade type: "limit" or "market"
            "price": 6609.37,                       // Order price
            "amount": 0.000006,                     // Order amount
            "amountUsed": 0.000002,                 // Used amount. Order will be fully executed when amount = amountUsed.
            "isCancelled": false,                   // True, when cancelled by user
            "createTime": "2018-01-10 05:38:51"     // Order create time
        }
    ],
    "userHistory": [
        {
            "id": 820,                              // Operation (trade) unique ID
            "pairName": "btc_usd",                  // Pair name
            "tradeType": "limit",                   // Trade type: "limit" or "market"
            "directionType": "sell",                // Direction: "buy" or "sell"
            "price": 6609.37,                       // Order price
            "amount": 0.000006,                     // Order amount
            "tradeTime": "2018-01-10 05:38:51"      // Trade execute time
        }
    ]
}

GET /api/1.0/trade/pairs/{pairName}/chart/{period}

Get data for chart
Period - one of value: 1m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1w

Response 200:

[
    [
        1541221500000,  // Timestamp in ms
        6421.42,        // Open value
        6421.42,        // Min value
        6624.85,        // Max value
        6609.37,        // Close value
        0.41097088      // Volume
    ]
]

GET /api/1.0/trade/pairs/{pairName}/orders

Get aggregate orders for pair

Response 200:

{
    "buy": [
        {
            "price": 6543.61,   // Order price
            "amount": 0.007917  // Aggregate order amounts for this price
        }
    ],
    "sell": [
        {
            "price": 6624.85,   // Order price
            "amount": 0.007147  // Aggregate order amounts for this price
        }
    ]
}

GET /api/1.0/trade/pairs/{pairName}/history

Get history for pair

Response 200:

[
    {
        "tradeType": "limit",                   // Trade type: "limit" or "market"
        "directionType": "sell"                 // Direction type: "buy" or "sell"
        "price": 6421.42,                       // Order price
        "amount": 0.000004,                     // Order amount
        "tradeTime": 1541221598,                // Trade execute timestamp in seconds
        "eventTimeMicro": "1541221598929761",   // Event time in microseconds
    }
]

GET /api/1.0/trade/pairs/{pairName}/user-balances

Get user balances for pair

Response 200:

[
    {
        "currency": "btc",          // Currency
        "balance": "0.00002525"     // Balance
    },
    {
        "currency": "usd",          // Currency
        "balance": "0.00000000"     // Balance
    }
]

GET /api/1.0/trade/pairs/{pairName}/user-orders

Get user orders with pagination for all pairs

Request:

?page=1&pageSize=50

Response 200:

{
    "total": 410,
    "items": [
        {
            "id": 820,                              // Order unique ID
            "pairName": "btc_usd",                  // Pair name
            "tradeType": "limit",                   // Trade type: "limit" or "market"
            "directionType": "sell",                // Direction: "buy" or "sell"
            "price": 6609.37,                       // Order price
            "amount": 0.000006,                     // Order amount
            "amountUsed": 0.000002,                 // Used amount. Order will be fully executed when amount = amountUsed.
            "isCancelled": false,                   // True, when cancelled by user
            "createTime": "2018-01-10 05:38:51"     // Order create time
        }
    ]
}

GET /api/1.0/trade/pairs/user-history

Get user history with pagination for all pairs

Request:

?page=1&pageSize=50

Response 200:

{
    "total": 142,
    "items": [
        {
            "id": 820,                              // Operation (trade) unique ID
            "pairName": "btc_usd",                  // Pair name
            "tradeType": "limit",                   // Trade type: "limit" or "market"
            "directionType": "sell",                // Direction: "buy" or "sell"
            "price": 6609.37,                       // Order price
            "amount": 0.000006,                     // Order amount
            "tradeTime": "2018-01-10 05:38:51"      // Trade execute time
        }
    ]
}

Trade: Stream API (WebSocket)

Stream API is read only. The list of channels for the subscription is indicated by the GET `streams` parameter in the request. To subscribe to several channels at once, list them separated by commas:

https://aliencloud.xyz/ws?streams=exchanges,orders:btc_usd,history:btc_usd,user_orders:5555bde1-1111-2222-3333-9ff6666250b1

exchanges

{
    "stream": "exchanges",
    "data": [
        {
            "pairName": "btc_usd",                  // Pair name
            "openValue": 6421.42,                   // Open value 24h
            "minValue": 6421.42,                    // Min value 24h
            "maxValue": 6624.85,                    // Max value 24h
            "closeValue": 6609.37,                  // Close value 24h (current exchange)
            "volume": 546.32,                       // Volume 24h
            "eventTimeMicro": "1541221598929761",   // Event time in microseconds
        }
    ]
}

orders:{pairName}

{
    "stream": "orders:btc_usd",
    "data": {
        "buy": [
            {
                "price": 6543.61,                       // Order price
                "amount": 0.007917,                     // Aggregate order amounts for this price
                "eventTimeMicro": "1541221598929761",   // Event time in microseconds
            }
        ],
        "sell": [
            {
                "price": 6624.85,                       // Order price
                "amount": 0.007147,                     // Aggregate order amounts for this price
                "eventTimeMicro": "1541221598929761",   // Event time in microseconds
            }
        ]
    }
}

history:{pairName}

{
    "stream": "history:btc_usd",
    "data": [
        {
            "directionType": "sell"                 // Direction type: "buy" or "sell"
            "tradeType": "limit",                   // Trade type: "limit" or "market"
            "price": 6421.42,                       // Order price
            "amount": 0.000004,                     // Order amount
            "tradeTime": 1541221598,                // Trade execute timestamp in seconds
            "eventTimeMicro": "1541221598929761"    // Event time in microseconds
        }
    ]
}

user_orders:{userUid}

{
    "stream": "user_orders:5555bde1-1111-2222-3333-9ff6666250b1",
    "data": {
        "id": 820,                              // Order unique ID
        "pairName": "btc_usd",                  // Pair name
        "tradeType": "limit",                   // Trade type: "limit" or "market"
        "directionType": "sell",                // Direction: "buy" or "sell"
        "price": 6609.37,                       // Order price
        "amount": 0.000006,                     // Order amount
        "amountUsed": 0.000002,                 // Used amount. Order will be fully executed when amount = amountUsed.
        "isCancelled": false,                   // True, when cancelled by user
        "createTime": "2018-01-10 05:38:51"     // Order create time
    }
}

user_history:{userUid}

{
    "stream": "user_history:5555bde1-1111-2222-3333-9ff6666250b1",
    "data": {
        "id": 820,                              // Operation (trade) unique ID
        "pairName": "btc_usd",                  // Pair name
        "tradeType": "limit",                   // Trade type: "limit" or "market"
        "directionType": "sell",                // Direction: "buy" or "sell"
        "price": 6609.37,                       // Order price
        "amount": 0.000006,                     // Order amount
        "tradeTime": "2018-01-10 05:38:51"      // Trade execute time
    }
}