NAV Navbar
Logo
Python Node.js

Introduction

Welcome to the BTC-Alpha API docs!

Service btc-alpha.com provides open API for trading operations and broadcasting of all trading events.

Web Sockets API

Currently Web Socket API can be used for getting the freshest info about lats trades, new and cancelled orders as well. Such as using socket connection reduce network overhead it’s preferable way to get latest exchange rate and orderbook.

API built on latest version of socket.io library for Node.js. So it should be easy to get work with.

Orderbook events

There are two types of order book notification messages In case new order was created, you’ll get information about order, what amount remained after operation and list of trades created after that order.

{
  "date": 1485686507.0944622, 
  "oid": 15234,
  "type": "sell", 
  "price": 935.23, 
  "amount": 0.0, 
  "trades": [
    {
      "tid": 14876, 
      "type": "buy",
      "price": "936.00", 
      "amount": "0.1", 
      "o_id": 15201
     }
  ]
}

When order was cancelled by owner

{
  "success": true,
  "date": 1485686413.5688234,
  "oid": 15235, 
  "type": "sell", 
  "price": 935.23, 
  "amount": 0.0123,
  "pair": "BTC_USD",
  "cancelled": true
}

All you need to start receiving live information about orderbook is connect to wss://btc-alpha.com and subscribe to necessary channel.

There are chanel names have pattern book_<pair_name> where <pair_name> is any pair available in service. For example book_BTC_USD or book_BTC_ETH.

HTTP API (v1)

HTTP API endpoint available on https://btc-alpha.com/api/v1/.

Some methods requires authorization read below.

All HTTP methods accept JSON formats of requests and responses if it not specified by headers.

Authorization

To generate auth headers, use this code:

import hmac
from time import time
from urllib.parse import urlencode

def get_auth_headers(self, data):
        msg = 'your key' + urlencode(sorted(data.items(), key=lambda val: val[0]))

        sign = hmac.new('your keys secret'.encode(), msg.encode(), digestmod='sha256').hexdigest()

        return {
            'X-KEY': 'your key',
            'X-SIGN': sign,
            'X-NONCE': str(int(time() * 1000)),
        }
var sortObj = require('sort-object');
var hmacSha256 = require('crypto-js/hmac-sha256');

function serializeObject (object) {
    var str = '';
    for (var key in object) {
        if (str !== '')
            str += '&';

        str += key + "=" + encodeURIComponent(object[key]);
    }
    return str;
}

function getAuthHeaders (data) {
    var message = 'your key' + serializeObject(sortObj(data));
    var sign = hmacSha256(message, 'your secret').toString();

    return {
        'X-KEY': 'your key',
        'X-SIGN': sign,
        'X-NONCE': (new Date()).getTime()
    };
}

In order for access to private API methods, generate authorization keys in profile settings.

All request to these methods must contain the following headers:

Currencies

List all currencies

import requests

response = requests.get('https://btc-alpha.com/api/v1/currencies/')
var request = require('request');

request.get('https://btc-alpha.com/api/v1/currencies/', function (error, response, body) {
    // process response    
});

Sample output

[
  {
    "sign": "Ƀ", 
    "short_name": "BTC"
  }, 
  {
    "sign": "Ξ", 
    "short_name": "ETH"
  } 
]

Returns information about all available currencies.

HTTP Request

GET https://btc-alpha.com/api/v1/pairs/

Pairs

List all pairs

import requests

response = requests.get('https://btc-alpha.com/api/v1/pairs/')
var request = require('request');

request.get('https://btc-alpha.com/api/v1/pairs/', function (error, response, body) {
    // process response    
});

Sample output

[
  {
    "currency2": "USD", 
    "maximum_order_size": 100000000.00000000, 
    "minimum_order_size": 0.00000001,
    "currency1": "BTC", 
    "name": "BTC_USD", 
    "price_precision": 3
   }
]

Returns information about all available pairs.

HTTP Request

GET https://btc-alpha.com/api/v1/pairs/

Query Parameters

Parameter Default Description
currency1 all Filter by first currency.
currency2 all Filter by second currency.

Wallets

List own wallets

import requests

response = requests.get('https://btc-alpha.com/api/v1/wallets/', headers = get_auth_headers({}))
var request = require('request');

request.get(
    'https://btc-alpha.com/api/v1/wallets/', 
    {
        headers: getAuthHeaders({})
    }, 
    function (error, response, body) {
        // process response    
    }
);

Sample output

[
  {
    "currency": "BTC", 
    "balance": 0.00000000, 
    "reserve": 0.00000000
   }
]

Returns information about all wallets of account.

HTTP Request

GET https://btc-alpha.com/api/v1/wallets/

Query Parameters

Parameter Default Description
currency_id all Filter by currency.

Orders

Order statuses

Value Status name Description
1 Active Order in queue for executing
2 Canceled Order not active, permanently
3 Done Order fully executed

Get orderbook

import requests

params = { 
    limit_bids: 1,
    limit_asks: 1,
}

response = requests.get('https://btc-alpha.com/api/v1/orderbook/BTC_USD/', params=params)
var request = require('request');

var url = 'https://btc-alpha.com/api/v1/orderbook/BTC_USD/';

var params = {
    limit_bids: 1,
    limit_asks: 1
};

request.get({url: url, qs: params}, function (error, response, body) {
        // process response    
    }
);

Sample output when grouping disabled

{
  "sell": [
    {
      "price": 911.519, 
      "id": 44667, 
      "amount": 0.000446, 
      "timestamp": 1485777324.410015
     }
   ],
  "buy": [
    {
      "price": 911.122, 
      "id": 44647, 
      "amount": 0.001233, 
      "timestamp": 1485777124.415542
    }
  ]
}

Sample output when grouping enabled

{
  "sell": [
    {
      "price": 911.519, 
      "amount": 0.000446 
     }
   ],
  "buy": [
    {
      "price": 911.122, 
      "amount": 0.001233 
    }
  ]
}

Get full orderbook of active orders

HTTP Request

GET https://btc-alpha.com/api/v1/orderbook/<pair_name>/

Query Parameters

Parameter Default Description
limit_sell all Sell orders limit
limit_buy all Buy orders limit
group 0 If set 1, then order will grouped by price

List own orders

import requests

response = requests.get('https://btc-alpha.com/api/v1/orders/own/', headers = get_auth_headers({}))
var request = require('request');

request.get('https://btc-alpha.com/api/v1/orders/own/', {headers: getAuthHeaders({})}, function (error, response, body) {
    // process response    
});

Sample output

[
  {
    "amount": 0.500000000, 
    "pair": "ETH_USD", 
    "type": "buy", 
    "status": 3, 
    "price": 0.00113000,
    "id": 11249
  }
]

List all orders created in your account. Can be filtered by query parameters.

HTTP Request

GET https://btc-alpha.com/api/v1/orders/own/

Query Parameters

Parameter Default Description
type all Filter by orders type (sell or buy).
pair none Filter by pair.
status all Filter by status.
limit 2000 Limiting results.

Retrieve single order

import requests

oid = 53189

response = requests.get('https://btc-alpha.com/api/v1/order/{}/'.format(oid))
var request = require('request');

var oid = 53189;

request.get('https://btc-alpha.com/api/v1/order/' + oid + '/', function (error, response, body) {
    // process response    
});

Sample output

{
  "amount": 0.1250000,
  "pair": "BTC_USD",
  "type": "buy",
  "status": "1",
  "price": 870.69000000, 
  "id": 11259
}

Get detailed information about order by its id

HTTP Request

GET https://btc-alpha.com/api/v1/order/<pk>/

Create order

import requests

order = {
    type: 'buy',
    pair: 'BTC_USD',
    amount: '1.0',
    price: '870.69'
}

response = requests.post('https://btc-alpha.com/api/v1/order/', data = order, headers = get_auth_headers(order))
var request = require('request');

var order = {
    type: 'buy',
    pair: 'BTC_USD',
    amount: '1.0',
    price: '870.69'    
};

request.post({
                url: 'https://btc-alpha.com/api/v1/order/',
                form: order,
                headers: getAuthHeaders(order)
            }, function (error, response, body) {
                // process response
                // save order id, check if it's executed
            }
);

Sample output

{
  "type": "buy", 
  "date": 1483721079.51632, 
  "oid": 11268, 
  "price": 870.69000000, 
  "amount": 0.00000000,
  "trades": [
    {
      "type": "sell", 
      "price": 870.69000000, 
      "o_id": 11266, 
      "amount": 0.00010000, 
      "tid": 6049
    }
  ]
}

Create new order that will be automatically executed.

HTTP Request

POST https://btc-alpha.com/api/v1/order/

POST params

Parameter Description
type Type of order (sell or buy).
pair Pair of order
amount Amount of first currency of pair.
price Price of order. This param have limited precision (See pairs).

Cancel order

import requests

data = {
    order: 63568
}

response = requests.post('https://btc-alpha.com/api/v1/order-cancel/', data = data, headers = get_auth_headers(data))
var request = require('request');

var data = {
    order: 63568
};

request.post({
        url: 'https://btc-alpha.com/api/v1/order-cancel/',
        form: data,
        headers: getAuthHeaders(data)
    }, function (error, response, body) {
        // process response    
    }
);

Sample output

{
  "order": 63568
}

Cancel your active order. If order not exists, it’s done or cancelled error message will be returned.

HTTP Request

POST https://btc-alpha.com/api/v1/order-cancel/

POST params

Parameter Description
order ID of order to cancel

Exchanges

List all exchanges

import requests

response = requests.get('https://btc-alpha.com/api/v1/exchanges/')
var request = require('request');

request.get('https://btc-alpha.com/api/v1/exchanges/', function (error, response, body) {
    // process response    
});

Sample output

[
  {
    "id": 6030, 
    "price": 839.36000000, 
    "pair": "BTC_USD", 
    "type": "sell", 
    "timestamp": 1483705817.735508,
    "amount": 0.00281167
  }
]

List last exchanges

HTTP Request

GET https://btc-alpha.com/api/v1/exchanges/

Query Parameters

Parameter Default Description
pair all Filter by pair.
limit 2000 Limiting results.

List own exchanges

List only own exchanges where your account was buyer or seller.

HTTP Request

GET https://btc-alpha.com/api/v1/exchanges/own/

Query Parameters

Parameter Default Description
type all Filter by orders type (sell or buy).
pair all Filter by pair.
limit 2000 Limiting results.

Deposits

List own deposits

import requests

response = requests.get('https://btc-alpha.com/api/v1/deposits/', headers = get_auth_headers({}))
var request = require('request');

request.get({
                url: 'https://btc-alpha.com/api/v1/deposits/',
                headers: getAuthHeaders({})
            }, function (error, response, body) {
                // process response    
            }
);
[
  {
    "timestamp": 1485363039.18359, 
    "id": 317, 
    "currency": "BTC", 
    "amount": 530.00000000
  }
]

List your deposits

HTTP Request

GET https://btc-alpha.com/api/v1/deposits/

Withdraws

Withdraw statuses

Value Status name Description
10 New Withdraw created, verification need
20 Verified Withdraw verified, waiting for approving
30 Approved Approved by moderator
40 Refused Refused by moderator. See your email for more details
50 Canceled Cancelled by user

List own made withdraws

import requests

response = requests.get('https://btc-alpha.com/api/v1/withdraws/', headers: get_auth_headers({}))
var request = require('request');

request.get({
        url: 'https://btc-alpha.com/api/v1/withdraws/',
        headers: getAuthHeaders({})
    }, function (error, response, body) {
        // process response    
    }
);

Sample output

[
  {
    "id": 403, 
    "timestamp": 1485363466.868539, 
    "currency": "BTC", 
    "amount": 0.53000000, 
    "status": 20
  }
]

Get list of your withdraws

HTTP Request

GET https://btc-alpha.com/api/v1/withdraws/

Query Parameters

Parameter Default Description
currency_id all Filter currency.
status all Filter by status.

Charts

import requests

params = {
    'limit': 1
    }

response = requests.get('https://btc-alpha.com/api/charts/BTC_USD/60/chart', params = params)
var request = require('request');

var params = {limit: 1};

request.get({
                url: 'https://btc-alpha.com/api/charts/BTC_USD/60/chart',
                qs: params
            }, function (error, response, body) {
                // process response    
            }
);

Sample output

[
  {
    "volume": 0.262929, 
    "high": 912.236, 
    "low": 910.086, 
    "close": 911.915, 
    "time": 1485777600, 
    "open": 910.424
   }
]

Chart types

Type value Type name
1 1 minute
5 5 minutes
15 15 minutes
30 30 minutes
60 1 hour
240 4 hours
D 1 day

HTTP Request

GET https://btc-alpha.com/api/charts/<pair>/<type>/chart

Query Parameters

Parameter Default Description
limit 720 Limiting results
since None Since Timestamp
until None Until Timestamp

HTTP Errors

HTTP API uses following error statuses:

Error Code Meaning
400 Bad Request – Something wrong with input data. See response body for mode details. Also check API documentation.
401 Unauthorized – Your API key is wrong. Check publick and secret keys, check auth headers.
403 Forbidden – Forbidden to process method with specified parameters.
404 Not Found – Method or resource not found.
405 Method Not Allowed – Check HTTP method for specified endpoint.
406 Not Acceptable – You requested a format that isn’t json.
429 Too Many Requests – You’re requesting fast! Slow down! See documentation for more details.
500 Internal Server Error – We had a problem with our server. Try again later.
503 Service Unavailable – We’re temporarially offline for maintanance. Please try again later.