xbt/cad XɃT/USD eth/xbt eth/cad
  • Last trade: $1,010.00USD
  • Volume: 32.17570307XɃT
  • Low: $956.34USD
  • High: $1,010.00USD

Overview

The QuadrigaCX API allows you to integrate the QuadrigaCX trading platform with third party applications, such as trading applications, charting programs, point of sale systems, and much more. Below you will find details on how the system functions, along with examples in common programming languages.

QuadrigaCX notations

Major denotes any of the Cryptocurrencies such as Bitcoin (BTC) or any other cryptocurrency which is added to the QuadrigaCX trading platform in the future.

Minor denotes fiat currencies such as Canadian Dollars (CAD), etc.

An order book is always referred to in the API as "Major_Minor". For example: "btc_cad"

The current order books on QuadrigaCX are:

  • btc_cad
  • btc_usd
  • eth_btc
  • eth_cad

*Note that Bitcoin is considered the "minor" currency in the Ether/Bitcoin order book.

The currencies are specified with the following 3 letter codes

  • Canadian Dollars = cad
  • US Dollars = usd
  • Bitcoin = btc
  • Ether = eth

Public Functions

Current Trading Information

GET https://api.quadrigacx.com/v2/ticker?book=XXX

The above url will return trading information from the specified book. If unspecified, the book will default to btc_cad

Result

Returns JSON dictionary:

  • last - last BTC price
  • high - last 24 hours price high
  • low - last 24 hours price low
  • vwap - last 24 hours volume weighted average price: vwap
  • volume - last 24 hours volume
  • bid - highest buy order
  • ask - lowest sell order

Order Book

GET https://api.quadrigacx.com/v2/order_book

List of all open orders

Params:

  • book - optional book to return orders for. Default btc_cad.
  • group - optional group orders with the same price (0 - false; 1 - true). Default: 1.

Result

Returns JSON dictionary with "bids" and "asks". Each is a list of open orders and each order is represented as a list of price and amount.

Transactions

GET https://api.quadrigacx.com/v2/transactions

List of recent trades

Params:

  • book - book to return orders for (optional, default btc_cad)
  • time - time frame for transaction export ("minute" - 1 minute, "hour" - 1 hour). Default: hour.

Result

Returns descending JSON list of transactions. Every transaction (dictionary) contains:

  • date - unix timestamp date and time
  • tid - transaction id
  • price - BTC price
  • amount - BTC amount
  • side - The trade side indicates the maker order side (maker order is the order that was open on the order book)

API Authentication

Setup

To setup an API within your account, click on your username in the top right hand corner of the screen, and select "API Setup" from the drop down menu.

When setting up a new API, you will need to choose an API Name to identify your API. This name will never be shown anywhere apart from on your API Index page within your account. In addition to the name, an API Secret must be chosen. The field is pre-populated with a random number of characters, but can be changed at your discretion. Finally, you have the option of adding a Withdrawal Bitcoin Address, which can be used to lock the API Withdrawal function to a specific Bitcoin address of your choosing. This field is optional.

Make a note of these 2 fields as they are needed to authenticate you on the server when making requests to the private APIs. To generate a new API Secret, click on the icon next to the current secret. Note that this will instantly change the key, and cannot be undone.

Authentication

You need to POST 3 fields as a JSON payload to the API in order to perform authentication.

  • key – The API Key as shown above
  • nonce – an integer that must be unique for each API call (we recommend using a UNIX timestamp)
  • signature – HMAC_SHA256 encrypted string

Signature

The signature has to be created using a concatenation of the nonce, your client id, the API key and using the API Secret as key. The pseudo-algorithm is shown below and you will find code examples in the Appendix.

HMAC_SHA256 ( nonce + client + key, secret )

Please note the HMAC_SHA256 should be lower case.

Using the API shown in Figure 2, the JSON payload will be:

{
    key: "JJHlXeDcFM",
    nonce: 1391683499,
    signature: "cdbf5cc64c70e1485fcf976cdf367960c2b28cfc28080973ce677cebb6db9681"
}

The signature is calculated using:

HMAC_SHA256 ( 1391683499 + 3 + JJHlXeDcFM , 230664ae53cbe5a07c6c389910540729 )
HMAC_SHA256 ( 13916834993JJHlXeDcFM , 230664ae53cbe5a07c6c389910540729 )
= cdbf5cc64c70e1485fcf976cdf367960c2b28cfc28080973ce677cebb6db9681

Private Functions

Account balance

POST https://api.quadrigacx.com/v2/balance

Params

  • key - API key
  • signature - signature
  • nonce - nonce

Result

Returns JSON dictionary of all balances, e.g.:

  • cad_balance - CAD balance
  • btc_balance - BTC balance
  • cad_reserved - CAD reserved in open orders
  • btc_reserved - BTC reserved in open orders
  • cad_available - CAD available for trading
  • btc_available - BTC available for trading
  • fee - customer trading fee

User Transactions

POST https://api.quadrigacx.com/v2/user_transactions

Params

  • key - API key
  • signature - signature
  • nonce - nonce
  • offset - skip that many transactions before beginning to return results. Default: 0.
  • limit - limit result to that many transactions. Default: 100.
  • sort - sorting by date and time (asc - ascending; desc - descending). Default: desc.
  • book - optional, if not specified, will default to btc_cad

Result

Returns descending JSON list of transactions. Every transaction (dictionary) contains:

  • datetime - date and time
  • id - unique identifier (only for trades)
  • type - transaction type (0 - deposit; 1 - withdrawal; 2 - trade)
  • method - deposit or withdrawal method
  • (minor currency code) – the minor currency amount
  • (major currency code) – the major currency amount
  • order_id - a 64 character long hexadecimal string representing the order that was fully or partially filled (only for trades)
  • fee – transaction fee
  • rate – rate per btc (only for trades)

Open Orders

POST https://api.quadrigacx.com/v2/open_orders

Params

  • key - API key
  • signature - signature
  • nonce - nonce
  • book - optional, if not specified, will default to btc_cad

Result

Returns JSON list of open orders. Each order is represented as dictionary:

  • id - order id
  • datetime - date and time
  • type - buy or sell (0 - buy; 1 - sell)
  • price - price
  • amount - amount
  • status - status of the order (0 - active; 1 - partially filled)

Lookup Order new

POST https://api.quadrigacx.com/v2/lookup_order

Params

  • key - API key
  • signature - signature
  • nonce - nonce
  • id – a single or array of 64 characters long hexadecimal string taken from the list of orders

Result

Returns JSON list of details about 1 or more orders. Each order is represented as dictionary:

  • id - the order id passed to that function
  • book - which orderbook it belongs to
  • price - price of the order
  • amount - amount of the order
  • type - buy or sell (0 - buy; 1 - sell)
  • status - status of the order (-1 - cancelled; 0 - active; 1 - partially filled; 2 - complete)
  • created - date the order was created
  • updated - date the order was last updated (not shown when status = 0)

Cancel Order

POST https://api.quadrigacx.com/v2/cancel_order

Params

  • key - API key
  • signature - signature
  • nonce - nonce
  • id – a 64 characters long hexadecimal string taken from the list of orders

Result

Returns 'true' if order has been found and canceled.

Buy Order - Limit Order

POST https://api.quadrigacx.com/v2/buy

Params

  • key - API key
  • signature - signature
  • nonce - nonce
  • amount - amount of major currency
  • price - price to buy at
  • book - optional, if not specified, will default to btc_cad

Result / Limit Order

Returns JSON dictionary representing order:

  • id - order id
  • datetime - date and time
  • type - buy or sell (0 - buy; 1 - sell)
  • price - price
  • amount - amount

Buy Order - Market Order

POST https://api.quadrigacx.com/v2/buy

Params

  • key - API key
  • signature - signature
  • nonce - nonce
  • amount - amount of major currency to buy
  • book - optional, if not specified, will default to btc_cad

Result / Market Order

Returns JSON dictionary representing market order:

  • amount - the total amount of the major currency purchased
  • orders_matched - a set of amount/price pairs, one for each order that was matched in the trade

Sell Order - Limit Order

POST https://api.quadrigacx.com/v2/sell

Params

  • key - API key
  • signature - signature
  • nonce - nonce
  • amount - amount of major currency
  • price - price to sell at
  • book - optional, if not specified, will default to btc_cad

Result / Limit Order

Returns JSON dictionary representing order:

  • id - order id
  • datetime - date and time
  • type - buy or sell (0 - buy; 1 - sell)
  • price - price
  • amount - amount

Sell Order - Market Order

POST https://api.quadrigacx.com/v2/sell

Params

  • key - API key
  • signature - signature
  • nonce - nonce
  • amount - amount of major currency to sell
  • book - optional, if not specified, will default to btc_cad

Result / Market Order

Returns JSON dictionary representing market order:

  • amount - the total amount of the minor currency acquired in the sale
  • orders_matched - a set of amount/price pairs, one for each order that was matched in the trade

Bitcoin Deposit

POST https://api.quadrigacx.com/v2/bitcoin_deposit_address

Payload

  • key - API key
  • signature - signature
  • nonce - nonce

Result

Returns a bitcoin deposit address for funding your account.

Bitcoin Withdraw

POST https://api.quadrigacx.com/v2/bitcoin_withdrawal

Payload

  • key - API key
  • signature - signature
  • nonce - nonce
  • amount – The amount to withdraw
  • address – The bitcoin address we will send the amount to

Result

OK or error

Ether Deposit

POST https://api.quadrigacx.com/v2/ether_deposit_address

Payload

  • key - API key
  • signature - signature
  • nonce - nonce

Result

Returns the ethereum deposit address for funding your account.

Ether Withdraw

POST https://api.quadrigacx.com/v2/ether_withdrawal

Payload

  • key - API key
  • signature - signature
  • nonce - nonce
  • amount – The amount to withdraw
  • address – The ethereum address we will send the amount to

Result

OK or error

Appendix

PHP Examples

You must be familiar with PHP - https://php.net - and the CURL extension - https://php.net/curl

Rates

$ch = curl_init('http://api.quadrigacx.com/v2/ticker');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$result = curl_exec($ch);
Result
{
    "high":"8650.00",
    "last":"8500.00",
    "timestamp":"1410341807",
    "bid":"8310.00",
    "vwap":"8414.15",
    "volume":"107.05882350",
    "low":"8480.00",
    "ask":"8500.00"
}

My Orders

$nonce     = time(); // Unix timestamp
$key       = 'JJHlXeDcFM'; // My API Key
$client    = 3; // My Client ID
$secret    = '230664ae53cbe5a07c6c389910540729'; // My secret
$signature = hash_hmac('sha256', $nonce . $client . $key, $secret); // Hashing it
$data = array(
    'key'       => $key,
    'nonce'     => $nonce,
    'signature' => $signature
);
$data_string = json_encode($data);
$ch = curl_init('https://api.quadrigacx.com/v2/open_orders');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json; charset=utf-8',
    'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);

Add a new Buy Order

$nonce     = time(); // Unix timestamp
$key       = 'JJHlXeDcFM'; // My API Key
$client    = 3; // My Client ID
$secret    = '230664ae53cbe5a07c6c389910540729'; // My secret
$signature = hash_hmac('sha256', $nonce . $client . $key, $secret); // Hashing it
$data = array(
    'key'       => $key,
    'nonce'     => $nonce,
    'signature' => $signature,
    'amount'    => 2.34,
    'price'     => 8469
);
$data_string = json_encode($data);
$ch = curl_init('https://api.quadrigacx.com/v2/buy');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json; charset=utf-8',
    'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);