Introduction
Welcome to the qTrade API documentation. These documents detail how to use qTrade's exchange API and are open source on github. If you'd like to make a correction or suggest any changes please feel free to make a pull request.
qTrade's APIs are separated into two categories public and private. Private APIs require authentication and allows placing orders, making deposits and withdrawals, and other account information. Public APIs provide market data and do not require authentication.
The qTrade API is available at
https://api.qtrade.io/
Client Libraries
Python Client
We provide a Python client for our API. This client offers helper functions, convenient response formatting, and automatic rate limit waiting to make developing applications with our API as efficient as possible.
CryptoCurrency eXchange Trading Library
Our API is also supported by CCXT, a JavaScript / Python / PHP cryptocurrency trading API with support for over 120 exchanges.
Vocabulary
Here is how we define the terms used in our documentation and API:
Term | Definition |
---|---|
Market Currency | The currency which is bought or sold on a market (e.g. NYZO on the NYZO/BTC market). |
Base Currency | The currency which is used to buy or sell a market currency (currently BTC on all markets). Price is given in this currency. |
Value | The total worth of an order or trade in base currency. |
Amount | The size of an order or trade in market currency. |
Authentication
import requests
import requests.auth
import base64
import time
import json
import binascii
from hashlib import sha256
from urllib.parse import urlparse
class QtradeAuth(requests.auth.AuthBase):
def __init__(self, key):
self.key_id, self.key = key.split(":")
def __call__(self, req):
# modify and return the request
timestamp = str(int(time.time()))
url_obj = urlparse(req.url)
request_details = req.method + "\n"
"""
request_details = 'GET
'
"""
uri = url_obj.path
# uri = "/v1/user/orders"
if url_obj.query:
uri += "?" + url_obj.query
# uri = "/v1/user/orders?open=true"
request_details += uri + "\n"
"""
request_details = 'GET
/v1/user/orders?open=true
'
"""
request_details += timestamp + "\n"
"""
request_details = 'GET
/v1/user/orders?open=true
1573604427
'
"""
if req.body:
# this request has no body, so this code isn't run in this example
if isinstance(req.body, str):
request_details += req.body + "\n"
else:
request_details += req.body.decode('utf8') + "\n"
else:
request_details += "\n"
"""
request_details = 'GET
/v1/user/orders?open=true
1573604427
'
"""
request_details += self.key
"""
request_details = 'GET
/v1/user/orders?open=true
1573604427
1111111111111111111111111111111111111111111111111111111111111111'
"""
hsh = sha256(request_details.encode("utf8")).digest()
signature = base64.b64encode(hsh)
req.headers.update({
"Authorization": "HMAC-SHA256 {}:{}".format(self.key_id, signature.decode("utf8")),
"HMAC-Timestamp": timestamp
})
return req
# Create a session object to make repeated API calls easy!
api = requests.Session()
# Create an authenticator with your API key
api.auth = QtradeAuth("1:1111111111111111111111111111111111111111111111111111111111111111")
# Make a call to API
res = api.get('https://api.qtrade.io/v1/user/orders', params={'open': "true"}).json()
print(res)
# Generated headers are:
{'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'Authorization': 'HMAC-SHA256 1:111111111111111111111111111111111111111111',
'Connection': 'keep-alive',
'HMAC-Timestamp': '1574589817',
'User-Agent': 'python-requests/2.18.4'}
# Generated body is:
{'data': {'orders': [{'created_at': '2019-11-12T22:42:15.643486Z',
'id': 8932525,
'market_amount': '1.10428011',
'market_amount_remaining': '1.10428011',
'market_id': 1,
'open': True,
'order_type': 'sell_limit',
'price': '0.0083759',
'trades': None},
{'created_at': '2019-11-12T22:42:14.713136Z',
'id': 8932523,
'market_amount': '0.92023342',
'market_amount_remaining': '0.92023342',
'market_id': 1,
'open': True,
'order_type': 'sell_limit',
'price': '0.00788731',
'trades': None},
{'base_amount': '0.00433166',
'created_at': '2019-11-12T22:42:08.51142Z',
'id': 8932503,
'market_amount': '14862.44638875',
'market_amount_remaining': '14862.44638875',
'market_id': 36,
'open': True,
'order_type': 'buy_limit',
'price': '0.00000029',
'trades': None}]}}
from qtrade_client.api import QtradeAPI
# Create an API client with your key
endpoint = "https://api.qtrade.io"
key = "1:1111111111111111111111111111111111111111111111111111111111111111"
api = QtradeAPI(endpoint, key)
# Make a call to API
res = api.orders(open=True)
print(res)
# Returned list:
[{'created_at': '2019-11-12T22:42:15.643486Z',
'id': 8932525,
'market_amount': '1.10428011',
'market_amount_remaining': '1.10428011',
'market_id': 1,
'open': True,
'order_type': 'sell_limit',
'price': '0.0083759',
'trades': None},
{'created_at': '2019-11-12T22:42:14.713136Z',
'id': 8932523,
'market_amount': '0.92023342',
'market_amount_remaining': '0.92023342',
'market_id': 1,
'open': True,
'order_type': 'sell_limit',
'price': '0.00788731',
'trades': None},
{'base_amount': '0.00433166',
'created_at': '2019-11-12T22:42:08.51142Z',
'id': 8932503,
'market_amount': '14862.44638875',
'market_amount_remaining': '14862.44638875',
'market_id': 36,
'open': True,
'order_type': 'buy_limit',
'price': '0.00000029',
'trades': None}]
var crypto = require('crypto');
var https = require('https');
class QtradeAuth {
constructor(key) {
[this.keyID, this.key] = key.split(":");
this.host = 'api.qtrade.io';
}
req(method, endpoint, body='', handleData) {
let timestamp = Math.floor(Date.now() / 1000);
// Create hmac sig
let sig_text = method + "\n";
sig_text += endpoint + "\n";
sig_text += timestamp + "\n";
sig_text += body + "\n";
sig_text += this.key;
var hash = crypto.createHash('sha256').update(sig_text, 'utf8').digest().toString('base64');
var opt = {
host: this.host,
path: endpoint,
method: method,
headers: {
'Content-Type': 'application/json; charset=utf-8',
'Authorization': 'HMAC-SHA256 ' + this.keyID + ':' + hash,
"HMAC-Timestamp": timestamp,
}
};
var output = '';
let req = https.request(opt, (res) => {
res.setEncoding('utf8');
res.on('data', (chunk) => {
output += chunk;
});
res.on('end', () => {
handleData(JSON.parse(output));
})
});
req.write(body);
req.end();
}
get(endpoint, handleData) {
return this.req("GET", endpoint, undefined, handleData);
}
post(endpoint, body, handleData) {
return this.req("POST", endpoint, body, handleData);
}
}
let api = new QtradeAuth("1:1111111111111111111111111111111111111111111111111111111111111111");
// GET request
api.get("/v1/user/me", (resp) => {
console.log(resp);
});
// POST request
payload = {
"amount": "1",
"price": "0.01",
"market_id": 1,
};
api.post("/v1/user/sell_limit", JSON.stringify(payload), (resp) => {
console.log(resp);
});
// Generated headers are:
{
data: {
user: {
id: 1111111,
email: 'hugh@example.com',
lname: 'Jass',
fname: 'Hugh',
verified_email: true,
tfa_enabled: false,
withdraw_limit: 0,
verification: 'none',
can_withdraw: true,
can_login: true,
can_trade: true,
referral_code: '6W56QFFVIIJ2',
email_addresses: [Array]
}
}
}
// Generated body is:
{
data: {
order: {
id: 8932314,
market_amount: '1',
market_amount_remaining: '1',
created_at: '2018-13-12T23:18:01.070552Z',
price: '0.01',
order_type: 'sell_limit',
market_id: 1,
open: true,
trades: []
}
}
}
<?php
class QtradeAuth
{
public $key_id;
public $key;
public $base = "https://api.qtrade.io";
public function __construct($key)
{
$key_pieces = explode(":", $key);
$this->key_id = $key_pieces[0];
$this->key = $key_pieces[1];
}
public function __call($method, $args)
{
$request_path = $args[0];
$timestamp = time();
if ($method === "get" || $method === "post") {
$body = array_key_exists(1, $args) ? $args[1] : '';
} else {
throw new BadMethodCallException;
}
// Build hmac sig
$sig_text = strtoupper($method) . "\n";
$sig_text .= $request_path . "\n";
$sig_text .= $timestamp . "\n";
$sig_text .= $body . "\n";
$sig_text .= $this->key;
$hmac_sig = base64_encode(hash("sha256", $sig_text, $raw_output = TRUE));
// Build CURL req
$ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, strtoupper($method));
curl_setopt($ch, CURLOPT_URL, $this->base . $request_path);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if ($method === "post") {
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
}
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json; charset=utf-8",
"Accept: application/json",
'Authorization: HMAC-SHA256 ' . $this->key_id . ':' . $hmac_sig,
'HMAC-Timestamp: ' . $timestamp,
));
return curl_exec($ch);
}
}
$api = new QtradeAuth("1:1111111111111111111111111111111111111111111111111111111111111111");
// GET request
$result = $api->get("/v1/user/me");
print_r(json_decode($result));
// POST request
$req = array(
"amount" => "1",
"price" => "2",
"market_id" => 7
);
$result = $api->post("/v1/user/buy_limit", json_encode($req));
print_r(json_decode($result));
?>
qTrade's private API requires HMAC authentication. All requests and responses are the application/json
content type return typical HTTP status codes.
The HMAC protocol uses an API key issued on qTrade's website in the account settings page. API keys have a limited set of permissions and you should always issue a key with the minimum set of permissions needed. API keys may also be revoked on the settings page.
API Key permissions are mapped into realms
and each realm
is granted access to specific API endpoints
Realm | Endpoints |
---|---|
Info | /user/balances , /user/withdraws , /user/deposits , /user/orders |
Withdraw | /user/withdraw |
Deposit | /user/deposit_address/{currency_code} |
Trade | /user/sell_limit , /user/buy_limit , /user/cancel_order |
Approved Withdraw Addresses
For user security, account withdrawals require email or 2FA approval. However, this usually isn't practical for API integrations.
Users can whitelist specific withdrawal addresses in the Manage Addresses panel of the user settings on the website. Adding an address to the approved list will allow users and API integrations to withdraw to it without manual confirmation.
Public
Summary
{'currencies': api.currencies, 'markets': api.markets, 'tickers': api.tickers}
api.get("/v1/common").json()
api.get("/v1/common", (resp) => {})
<?php
$result = $api->get("/v1/common");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/common
200 Response
{
"data": {
"currencies": [
{
"can_withdraw": false,
"code": "MMO",
"config": {
"address_version": 50,
"default_signer": 23,
"price": 0.002,
"required_confirmations": 6,
"required_generate_confirmations": 120,
"satoshi_per_byte": 100,
"wif_version": 178,
"withdraw_fee": "0.001"
},
"long_name": "MMOCoin",
"metadata": {
"delisting_date": "12/13/2018"
},
"precision": 8,
"status": "delisted",
"type": "bitcoin_like"
},
{
"can_withdraw": true,
"code": "BTC",
"config": {
"address_version": 0,
"default_signer": 6,
"explorerAddressURL": "https://live.blockcypher.com/btc/address/",
"explorerTransactionURL": "https://live.blockcypher.com/btc/tx/",
"p2sh_address_version": 5,
"price": 8595.59,
"required_confirmations": 2,
"required_generate_confirmations": 100,
"satoshi_per_byte": 15,
"withdraw_fee": "0.0005"
},
"long_name": "Bitcoin",
"metadata": {
"withdraw_notices": []
},
"precision": 8,
"status": "ok",
"type": "bitcoin_like"
},
{
"can_withdraw": true,
"code": "BIS",
"config": {
"data_max": 1000,
"default_signer": 54,
"enable_address_data": true,
"explorerAddressURL": "https://bismuth.online/search?quicksearch=",
"explorerTransactionURL": "https://bismuth.online/search?quicksearch=",
"price": 0.12891653720125376,
"required_confirmations": 35,
"withdraw_fee": "0.25"
},
"long_name": "Bismuth",
"metadata": {
"deposit_notices": [],
"hidden": false
},
"precision": 8,
"status": "ok",
"type": "bismuth"
}
],
"markets": [
{
"base_currency": "BTC",
"can_cancel": false,
"can_trade": false,
"can_view": false,
"id": 8,
"maker_fee": "0.0025",
"market_currency": "MMO",
"metadata": {
"delisting_date": "12/13/2018",
"market_notices": [
{
"message": "Delisting Notice: This market has been delisted due to low volume. Please cancel your orders and withdraw your funds by 12/13/2018.",
"type": "warning"
}
]
},
"taker_fee": "0.0025"
},
{
"base_currency": "BTC",
"can_cancel": true,
"can_trade": true,
"can_view": true,
"id": 20,
"maker_fee": "0",
"market_currency": "BIS",
"metadata": {
"labels": []
},
"taker_fee": "0.005"
}
],
"tickers": [
{
"ask": null,
"bid": null,
"day_avg_price": null,
"day_change": null,
"day_high": null,
"day_low": null,
"day_open": null,
"day_volume_base": "0",
"day_volume_market": "0",
"id": 8,
"id_hr": "MMO_BTC",
"last": "0.00000076"
},
{
"ask": "0.000014",
"bid": "0.00001324",
"day_avg_price": "0.0000147000191353",
"day_change": "-0.023086269744836",
"day_high": "0.00001641",
"day_low": "0.00001292",
"day_open": "0.00001646",
"day_volume_base": "0.36885974",
"day_volume_market": "25092.46665642",
"id": 20,
"id_hr": "BIS_BTC",
"last": "0.00001608"
}
]
}
}
Retrieve All Markets, All Currencies, and All Tickers in one call.
GET /v1/common
Ticker
api.tickers['VEO_BTC']
api.get("/v1/ticker/VEO_BTC").json()
api.get("/v1/ticker/VEO_BTC", (resp) => {})
<?php
$result = $api->get("/v1/ticker/VEO_BTC");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/ticker/VEO_BTC
200 Response
{
"data": {
"ask": "0.02249",
"bid": "0.0191",
"day_avg_price": "0.0197095311101552",
"day_change": "0.0380429141071119",
"day_high": "0.02249",
"day_low": "0.0184",
"day_open": "0.01840001",
"day_volume_base": "0.42644484",
"day_volume_market": "21.63647819",
"id": 15,
"id_hr": "VEO_BTC",
"last": "0.0191"
}
}
Get ticker values for the given market. The market_string
value should be formatted ala LTC_BTC
for a market that buys and sells Litecoin with Bitcoin.
Key | Description |
---|---|
ask | The current ask price on the market |
bid | The current bid price on the market |
day_avg_price | The market average price over the last 24 hours |
day_change | The change in the market's midpoint over the last 24 hours |
day_high | The price of the highest trade in the last 24 hours |
day_low | The price of the lowest trade in the last 24 hours |
day_open | The price of the latest trade which occurred more than 24 hours ago |
day_volume_base | The market volume in its base currency |
day_volume_market | The market volume in market currency |
id | A globally unique market identifier as an integer |
id_hr | A globally unique market identifier as a human-readable string |
last | The price of the last trade made on the market |
Path variables
Variable | Description |
---|---|
market_string | Integer ID ('1') or a string pair ('LTC_BTC') |
GET /v1/ticker/:market_string
All Tickers
api.tickers
-> {36: {'ask':...}, 'DOGE_BTC': {'ask':...}}
# Tickers are lazily loaded. To set the update interval in seconds:
api.tickers_update_interval = 30
api.get("/v1/tickers").json()
api.get("/v1/tickers", (resp) => {})
<?php
$result = $api->get("/v1/tickers");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/tickers
200 Response
{
"data": {
"markets": [
{
"ask": "0.0034",
"bid": "0.0011",
"day_avg_price": null,
"day_change": null,
"day_high": null,
"day_low": null,
"day_open": null,
"day_volume_base": "0",
"day_volume_market": "0",
"id": 23,
"id_hr": "GRIN_BTC",
"last": "0.0033"
},
{
"ask": "0.000099",
"bid": "0.0000795",
"day_avg_price": "0.0000795337894515",
"day_change": "-0.2205882352941176",
"day_high": "0.00008",
"day_low": "0.0000795",
"day_open": "0.000102",
"day_volume_base": "0.07353291",
"day_volume_market": "924.549308",
"id": 19,
"id_hr": "SNOW_BTC",
"last": "0.0000795"
}
]
}
}
Get ticker values for all markets.
Return parameters are as for Ticker.
GET /v1/tickers
Currency
api.currencies['BTC']
api.get("/v1/currency/BTC").json()
api.get("/v1/currency/BTC", (resp) => {})
<?php
$result = $api->get("/v1/currency/BTC");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/currency/BTC
200 Response
{
"data": {
"currency": {
"can_withdraw": true,
"code": "BTC",
"config": {
"address_version": 0,
"default_signer": 6,
"explorerAddressURL": "https://live.blockcypher.com/btc/address/",
"explorerTransactionURL": "https://live.blockcypher.com/btc/tx/",
"p2sh_address_version": 5,
"price": 9159.72,
"required_confirmations": 2,
"required_generate_confirmations": 100,
"satoshi_per_byte": 15,
"withdraw_fee": "0.0005"
},
"long_name": "Bitcoin",
"metadata": {
"withdraw_notices": []
},
"precision": 8,
"status": "ok",
"type": "bitcoin_like"
}
}
}
Get general information about a specific currency.
Key | Description |
---|---|
can_withdraw | True if this currency can be withdrawn |
code | The currency code as used in market strings etc. |
config | This dictionary is primarily for internal use, and varies from coin to coin. Consistent values are as follows: |
price | The estimated price of the coin in USD |
withdraw_fee | The fee to withdraw this currency from qTrade |
long_name | The full name of the currency |
precision | |
status | The coin's listing and trading status on qTrade |
Path variables
Variable | Description |
---|---|
code | The string ticker code of the currency. Ala 'BTC' |
GET /v1/currency/:code
All Currencies
api.currencies
-> {'BIS': {'can_withdraw':...}}
# Currencies are lazily loaded from the common endpoint, at the same time as markets
# To set the update interval in seconds:
api.market_update_interval = 30
api.get("/v1/currencies").json()
api.get("/v1/currencies", (resp) => {})
<?php
$result = $api->get("/v1/currencies");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/currencies
200 Response
{
"data": {
"currencies": [
{
"can_withdraw": true,
"code": "BTC",
"config": {
"address_version": 0,
"default_signer": 6,
"explorerAddressURL": "https://live.blockcypher.com/btc/address/",
"explorerTransactionURL": "https://live.blockcypher.com/btc/tx/",
"p2sh_address_version": 5,
"price": 9159.72,
"required_confirmations": 2,
"required_generate_confirmations": 100,
"satoshi_per_byte": 15,
"withdraw_fee": "0.0005"
},
"long_name": "Bitcoin",
"metadata": {
"withdraw_notices": []
},
"precision": 8,
"status": "ok",
"type": "bitcoin_like"
},
{
"can_withdraw": true,
"code": "BIS",
"config": {
"data_max": 1000,
"default_signer": 54,
"enable_address_data": true,
"explorerAddressURL": "https://bismuth.online/search?quicksearch=",
"explorerTransactionURL": "https://bismuth.online/search?quicksearch=",
"price": 0.11314929085578249,
"required_confirmations": 35,
"withdraw_fee": "0.25"
},
"long_name": "Bismuth",
"metadata": {
"deposit_notices": [],
"hidden": false
},
"precision": 8,
"status": "ok",
"type": "bismuth"
}
]
}
}
Get general information about all available currencies.
Return parameters are as for Currency.
GET /v1/currencies
Market
api.markets['VEO_BTC']
api.get("/v1/market/VEO_BTC").json()
api.get("/v1/market/VEO_BTC", (resp) => {})
<?php
$result = $api->get("/v1/market/VEO_BTC");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/market/VEO_BTC
200 Response
{
"data": {
"market": {
"base_currency": "BTC",
"can_cancel": true,
"can_trade": true,
"can_view": false,
"id": 15,
"maker_fee": "0.005",
"market_currency": "VEO",
"metadata": {},
"taker_fee": "0.005"
},
"recent_trades": [
{
"amount": "1.64360163",
"created_at": "2019-01-31T23:09:31.419131Z",
"id": 51362,
"price": "0.0191"
},
{
"amount": "1.60828469",
"created_at": "2019-01-31T22:05:16.531659Z",
"id": 51362,
"price": "0.02248"
}
]
}
}
Return details about a specific market including info about fees, user permissions/market state and the most recent 200 trades.
Key | Description |
---|---|
maker_fee | The percentage fee taken on the trade value of maker orders |
taker_fee | The percentage fee taken on the trade value on taker orders |
id | A globally unique market identifier as an integer |
metadata | Frontend rendering params |
can_trade | true if trading and order creation is disabled |
base_currency | The code of currency that orders are priced in |
market_currency | The code of currency that is bought or sold |
Path variables
Variable | Description |
---|---|
market_string | Integer ID ('1') or a string pair ('LTC_BTC') |
GET /v1/market/:market_string
All Markets
api.markets
-> {36: {'base_currency':...}, 'DOGE_BTC': {'base_currency':...}}
# Markets are lazily loaded. To set the update interval in seconds:
api.market_update_interval = 30
api.get("/v1/markets").json()
api.get("/v1/markets", (resp) => {})
<?php
$result = $api->get("/v1/markets");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/markets
200 Response
{
"data": {
"markets": [
{
"base_currency": "BTC",
"can_cancel": true,
"can_trade": true,
"can_view": true,
"id": 20,
"maker_fee": "0.0025",
"market_currency": "BIS",
"metadata": {},
"taker_fee": "0.0025"
},
{
"base_currency": "BTC",
"can_cancel": true,
"can_trade": true,
"can_view": true,
"id": 19,
"maker_fee": "0.0075",
"market_currency": "SNOW",
"metadata": {},
"taker_fee": "0.0075"
}
]
}
}
Get general information about all available markets.
Return parameters are as for Market.
GET /v1/markets
Market Trades
api.get('/v1/market/LTC_BTC/trades')
api.get("/v1/market/LTC_BTC/trades").json()
api.get("/v1/market/LTC_BTC/trades", (resp) => {})
<?php
$result = $api->get("/v1/market/LTC_BTC/trades");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/market/LTC_BTC/trades
200 Response
{
"data": {
"trades": [
{
"amount": "0.00760005",
"created_at": "2019-05-21T02:41:30.781308Z",
"id": 51362,
"price": "0.01181539",
"seller_taker": false
},
{
"amount": "4.99515615",
"created_at": "2019-05-21T02:41:30.781308Z",
"id": 51354,
"price": "0.01180695",
"seller_taker": false
}
]
}
}
Return historical trade data on a market.
Key | Description |
---|---|
amount | The amount of the transaction in market currency |
created_at | The time and date of the trade's creation |
price | The price of the trade in base currency |
seller_taker | True if the seller was the taker, false if the buyer was the taker |
Path variables
Variable | Description |
---|---|
market_string | Integer ID ('1') or a string pair ('LTC_BTC') |
Query params
Parameter | Type | Description |
---|---|---|
older_than | Integer | Expects a trade ID and returns trades with an ID < the passed ID |
newer_than | Integer | Expects a trade ID and returns trades with an ID > the passed ID |
GET /v1/market/:market_string/trades?older_than=1000000&newer_than=1
Market Orderbook
api.get("/v1/orderbook/VEO_BTC")
api.get("/v1/orderbook/VEO_BTC").json()
api.get("/v1/orderbook/VEO_BTC", (resp) => {})
<?php
$result = $api->get("/v1/orderbook/VEO_BTC");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/orderbook/VEO_BTC
200 Response
{
"data": {
"buy": {
"0.000009": "150",
"0.0001032": "100",
"0.00020139": "100"
},
"last_change": 1595029625809804,
"sell": {
"0.02249": "0.99720378",
"14": "28",
"5": "100"
}
}
}
Returns the full level 2 order book liquidity aggregated by price. By default the full depth is returned for a given market pair.
Liquidity is returned as two objects (buy
and sell
) where the keys are the price and the values are the amounts available at that price.
The buy
object is returned with prices in ascending order (lowest to highest). The sell
object is the opposite, returned in descending order (highest price to lowest price).
Path variables
Variable | Description |
---|---|
market_string | Integer ID ('1') or a string pair ('LTC_BTC') |
GET /v1/orderbook/:market_string
OHLCV
api.get("/v1/market/LTC_BTC/ohlcv/fourhour")
api.get("/v1/market/LTC_BTC/ohlcv/fourhour").json()
api.get("/v1/market/LTC_BTC/ohlcv/fourhour", (resp) => {})
<?php
$result = $api->get("/v1/market/LTC_BTC/ohlcv/fourhour");
print_r(json_decode($result));
?>
curl https://api.qtrade.io/v1/market/LTC_BTC/ohlcv/fourhour
200 Response
{
"data": {
"slices": [
{
"close": "0.02",
"high": "0.02",
"low": "0.02",
"open": "0.02",
"time": "2018-04-28T04:00:00Z",
"volume": "0.00190564"
},
{
"close": "0.02",
"high": "0.02",
"low": "0.02",
"open": "0.02",
"time": "2018-04-28T08:00:00Z",
"volume": "0"
}
]
}
}
Returns OHLCV data for a specific market. Candlesticks are returned newest to oldest, up to the limit
. The default limit is 1000 candlesticks.
If you need older data you may specify a start
timestamp at an older date. Iteration over older data may be easier by also specifying a limited number of results
Candlestick intervals may be specified by providing an interval
value which returns OHLCV data in chunks of the specified duration. This value is optional and defaults to 5 minute intervals
Valid interval values include:
Intervals | Meaning |
---|---|
fivemin | Five minute slices |
fifteenmin | Fifteen minute slices |
thirtymin | Thirty minute slices |
onehour | One hour slices |
twohour | Two hour slices |
fourhour | Four hour slices |
oneday | One day slices |
Path variables
Variable | Description |
---|---|
market_string | Integer ID ('1') or a string pair ('LTC_BTC') |
interval | OHLCV data is chunked by this interval |
Query params
Parameter | Type | Description |
---|---|---|
start | Integer (timestamp) | Return data only after the provided unix timestamp |
limit | Integer | Return up to this number of candlesticks. Max limit is 1000 |
GET /v1/market/:market_string/ohlcv/:interval
Private
User Info
api.get("/v1/user/me")
api.get("/v1/user/me").json()
api.get("/v1/user/me", (resp) => {})
<?php
$result = $api->get("/v1/user/me");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"user": {
"can_login": true,
"can_trade": true,
"can_withdraw": true,
"email": "hugh@test.com",
"email_addresses": [
{
"address": "hugh@test.com",
"created_at": "2019-10-14T14:41:43.506827Z",
"id": 10000,
"is_primary": true,
"verified": true
},
{
"address": "jass@test.com",
"created_at": "2019-11-14T18:51:23.816532Z",
"id": 10001,
"is_primary": false,
"verified": true
}
],
"fname": "Hugh",
"id": 1000000,
"lname": "Jass",
"referral_code": "6W56QFFVIIJ2",
"tfa_enabled": true,
"verification": "none",
"verified_email": true,
"withdraw_limit": 0
}
}
}
Fetch general information about the authenticated user account.
GET /v1/user/me
Balances
api.balances() # returns only spendable balances
api.balances_merged() # returns both spendable and non-spendable balances merged
api.balances_all() # returns all balances, sorted by spendable and non-spendable
api.get("/v1/user/balances").json()
api.get("/v1/user/balances", (resp) => {})
<?php
$result = $api->get("/v1/user/balances");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"balances": [
{
"balance": "100000000",
"currency": "BCH"
},
{
"balance": "99992435.78253015",
"currency": "LTC"
},
{
"balance": "99927153.76074182",
"currency": "BTC"
}
]
}
}
Current useable account balances for a user account. Doesn't include amounts currently represented in open orders, pending deposits or withdraws.
Query params
Parameter | Type | Description |
---|---|---|
account_id | String | Return data only for the specified account |
GET /v1/user/balances?account_id=1000000-2
User Market View
api.get("/v1/user/market/LTC_BTC")
api.get("/v1/user/market/LTC_BTC").json()
api.get("/v1/user/market/LTC_BTC", (resp) => {})
<?php
$result = $api->get("/v1/user/market/LTC_BTC");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"base_balance": "99927153.76074182",
"closed_orders": [
{
"base_amount": "0.09102782",
"created_at": "2018-04-06T17:59:36.366493Z",
"id": 13252,
"market_amount": "4.99896025",
"market_amount_remaining": "0",
"market_id": 1,
"open": false,
"order_type": "buy_limit",
"price": "9.90682437",
"trades": [
{
"base_amount": "49.37394186",
"base_fee": "0.12343485",
"created_at": "2018-04-06T17:59:36.366493Z",
"id": 10289,
"market_amount": "4.99298105",
"price": "9.88866999",
"taker": true
},
{
"base_amount": "0.05907856",
"base_fee": "0.00014769",
"created_at": "2018-04-06T17:59:36.366493Z",
"id": 10288,
"market_amount": "0.0059792",
"price": "9.88068047",
"taker": true
}
]
}
],
"market_balance": "99992435.78253015",
"open_orders": [
{
"base_amount": "49.45063516",
"created_at": "2018-04-06T17:59:35.867526Z",
"id": 13249,
"market_amount": "5.0007505",
"market_amount_remaining": "5.0007505",
"market_id": 1,
"open": true,
"order_type": "buy_limit",
"price": "9.86398279",
"trades": null
},
{
"created_at": "2018-04-06T17:59:27.347006Z",
"id": 13192,
"market_amount": "5.00245975",
"market_amount_remaining": "0.0173805",
"market_id": 1,
"open": true,
"order_type": "sell_limit",
"price": "9.90428849",
"trades": [
{
"base_amount": "49.37366303",
"base_fee": "0.12343415",
"created_at": "2018-04-06T17:59:27.531716Z",
"id": 10241,
"market_amount": "4.98507925",
"price": "9.90428849",
"taker": false
}
]
}
]
}
}
Returns the currently available base_currency
and market_currency
balances for a user on the given market. These amounts do not include amounts currently represented in open orders, pending deposits or withdraws.
Also returns lists of open_orders
and closed_orders
Path variables
Variable | Description |
---|---|
market_string | Integer ID ('1') or a string pair ('LTC_BTC') |
Query params
Parameter | Type | Description |
---|---|---|
account_id | String | Return data only for the specified account |
GET /v1/user/market/:market_string?account_id=1000000-2
Get Orders
api.orders() # returns all orders made by this account
api.orders(open=True) # returns only open orders
api.orders(open=False) # returns only closed orders
api.get("/v1/user/orders").json()
api.get("/v1/user/orders", (resp) => {})
<?php
$result = $api->get("/v1/user/orders");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"orders": [
{
"base_amount": "0.09102782",
"created_at": "2018-04-06T17:59:36.366493Z",
"id": 13252,
"market_amount": "4.99896025",
"market_amount_remaining": "0",
"market_id": 1,
"open": false,
"order_type": "buy_limit",
"price": "9.90682437",
"trades": [
{
"base_amount": "49.37394186",
"base_fee": "0.12343485",
"created_at": "2018-04-06T17:59:36.366493Z",
"id": 10289,
"market_amount": "4.99298105",
"price": "9.88866999",
"taker": true
},
{
"base_amount": "0.05907856",
"base_fee": "0.00014769",
"created_at": "2018-04-06T17:59:36.366493Z",
"id": 10288,
"market_amount": "0.0059792",
"price": "9.88068047",
"taker": true
}
]
},
{
"base_amount": "49.33046306",
"created_at": "2018-04-06T17:59:12.941034Z",
"id": 13099,
"market_amount": "4.9950993",
"market_amount_remaining": "4.9950993",
"market_id": 1,
"open": true,
"order_type": "buy_limit",
"price": "9.85114439",
"trades": null
}
]
}
}
Fetches the last 200 orders made by your account with all the trades associated.
If you need more than the last 200 orders use the older_than
param. Passing an order ID will return only orders which are older than that order ID.
Examples
"""
Order IDs are strictly increasing, so code like the following
short example may be used to detect new orders.
"""
latest_order_id = 0
while True:
result = api.get("/v1/user/orders", params={"newer_than": latest_order_id}).json()
if result['data']['orders'] != []:
## process the new order ##
latest_order_id = result['data']['orders'][0]['id']
"""
If you're searching for an order older than the latest
200, you can use older_than to iterate over old orders.
"""
orders = api.get("/v1/user/orders").json()
search_price = "4.99896025"
while True:
for order in orders["data"]["orders"]:
if order["price"] == search_price:
return order
oldest_order_id = orders["data"]["orders"][-1]["id"]
orders = api.get("/v1/orders", params={"older_than": oldest_order_id}).json()
Query params
Parameter | Type | Description |
---|---|---|
market_id | Integer | Filter results by market ID. Mutually exclusive with market_string |
market_string | String | Filter results by market string. Mutually exclusive with market_id |
open | Boolean | Filter by opened/closed orders |
account_id | String | Return data only for the specified account |
older_than | Integer | Expects an order ID and returns orders with an ID < the passed ID |
newer_than | Integer | Expects an order ID and returns orders with an ID > the passed ID |
GET /v1/user/orders?market_string=ETH_BTC&open=true&account_id=1000000-2&newer_than=1
Order Details
api.get("/v1/user/order/8806681")
api.get("/v1/user/order/:order_id").json()
api.get("/v1/user/order/:order_id", (resp) => {})
<?php
$result = $api->get("/v1/user/order/:order_id");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"order": {
"base_amount": "0",
"close_reason": "canceled",
"created_at": "2018-11-08T00:15:57.258122Z",
"id": 8806681,
"market_amount": "500",
"market_amount_remaining": "0",
"market_id": 36,
"open": false,
"order_type": "sell_limit",
"price": "0.00000033",
"trades": null
}
}
}
Takes an Order ID and returns data about that order.
Key | Description |
---|---|
market_amount | The amount of market currency involved in the order. This is the order amount for sell orders, or the total traded for buy orders. |
market_amount_remaining | The amount of market currency remaining when this request was processed. |
base_amount | The amount of base currency involved in the order. This is the order value for buy orders, or the total traded for sell orders. |
open | True if the order is currently open. |
trades | A list of trades executed on this order. |
Path variables
Variable | Description |
---|---|
order_id | Integer ID of the order |
GET /v1/user/order/:order_id
Get Trades
api.get('/v1/user/trades') # returns all trades made by this account
api.get('/v1/user/trades', market_id=36) # returns only trades on the DOGE/BTC market
api.get('/v1/user/trades', newer_than=12345) # returns trades more recent than the trade with this ID
api.get('/v1/user/trades', desc=True) # returns newest trades first
api.get("/v1/user/trades").json()
api.get("/v1/user/trades", (resp) => {})
<?php
$result = $api->get("/v1/user/trades");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"trades": [
{
"base_amount": "0.00022751",
"base_fee": "0",
"created_at": "2019-10-14T17:42:42.874812Z",
"id": 63286,
"market_amount": "733.93113296",
"market_id": 36,
"order_id": 8141515,
"price": "0.00000031",
"side": "sell",
"taker": false
},
{
"base_amount": "0.000434",
"base_fee": "0.00000217",
"created_at": "2019-10-14T17:42:42.874812Z",
"id": 63287,
"market_amount": "1400",
"market_id": 36,
"order_id": 8141515,
"price": "0.00000031",
"side": "sell",
"taker": true
},
{
"base_amount": "0.000135",
"base_fee": "0",
"created_at": "2019-10-19T11:10:19.387393Z",
"id": 64129,
"market_amount": "500",
"market_id": 36,
"order_id": 8209249,
"price": "0.00000027",
"side": "buy",
"taker": false
}
]
}
}
By default, fetch the oldest 200 trades made by your master account.
If you want to iterate or need more than the first 200 trades use of the newer_than
, older_than
, and desc
params will be helpful. The newer_than
and older_than
params expect a trade ID, and results will only include trades which are newer/older than the provided trade ID.
Query params
Parameter | Type | Description |
---|---|---|
market_id | Integer | Filter results by market ID. Mutually exclusive with market_string |
market_string | String | Filter results by market string. Mutually exclusive with market_id |
desc | Boolean | Returns newest trades first when true |
account_id | String | Return data only for the specified account |
older_than | Integer | Expects a trade ID and returns trades with an ID < the passed ID |
newer_than | Integer | Expects a trade ID and returns trades with an ID > the passed ID |
GET /v1/user/trades?desc=true&market_string=ETH_BTC&account_id=1000000-2
Cancel Order
api.post("/v1/user/cancel_order", id=109)
req = {'id': 109}
api.post("/v1/user/cancel_order", json=req)
req = {'id': 109}
api.post("/v1/user/cancel_order", JSON.stringify(req), (resp) => {})
<?php
$req = array(
"id" => 109,
)
$result = $api->post("/v1/user/cancel_order", json_encode($req));
print_r(json_decode($result));
?>
200 Response
api.post("/v1/user/cancel_order", id=109)
req = {'id': 109}
api.post("/v1/user/cancel_order", json=req)
req = {'id': 109}
api.post("/v1/user/cancel_order", JSON.stringify(req), (resp) => {})
<?php
$req = array(
"id" => 109,
)
$result = $api->post("/v1/user/cancel_order", json_encode($req));
print_r(json_decode($result));
?>
404 Response
{
"errors": [
{
"code": "order_not_found",
"title": "That order no longer exists"
}
]
}
Takes an Order ID.
POST Body
Variable | Example | Description |
---|---|---|
id | 420 | Integer ID of the order to cancel |
POST /v1/user/cancel_order
Create a Withdraw
api.post("/v1/user/withdraw",
address='n4D4LZGnh82gpgFgqoLr6phN7yZMMroAWE',
amount='1.51235432',
currency='LTC')
req = { 'address': 'n4D4LZGnh82gpgFgqoLr6phN7yZMMroAWE',
'amount': '1.51235432',
'currency': 'LTC'}
api.post("/v1/user/withdraw", json=req).json()
req = { 'address': 'n4D4LZGnh82gpgFgqoLr6phN7yZMMroAWE',
'amount': '1.51235432',
'currency': 'LTC'}
api.post("/v1/user/withdraw", JSON.stringify(req), (resp) => {})
<?php
$req = array(
"currency" => "LTC",
"amount" => "1.51235432",
"address" => "n4D4LZGnh82gpgFgqoLr6phN7yZMMroAWE",
)
$result = $api->post("/v1/user/withdraw", json_encode($req));
print_r(json_decode($result));
?>
201 Response
{
"data": {
"code": "initiated",
"id": 3,
"result": "Withdraw initiated. Please allow 3-5 minutes for our system to process."
}
}
Creates a request with Withdraw currency to a specified address. Currency is removed from the balance upon success, the corresponding network transaction may be delayed for up to 5 minutes.
Requires email or 2FA confirmation (if enabled), or an approved withdraw address.
POST Body
Variable | Example | Description |
---|---|---|
amount | 1.2345 | String. Exact amount, including decimal "1.2345" |
currency | LTC | String. Currency code to withdraw |
address | n4D4LZGnh82gpgFgqoLr6phN7yZMMroAWE | String. Address to receive funds |
POST /v1/user/withdraw
Withdraw Details
api.get("/v1/user/withdraw/2")
api.get("/v1/user/withdraw/2").json()
api.get("/v1/user/withdraw/2", (resp) => {})
<?php
$result = $api->get("/v1/user/withdraw/2");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"withdraw": {
"address": "mw67t7AE88SBSRWYw1is3JaFbtXVygwpmB",
"amount": "1",
"cancel_requested": false,
"created_at": "2019-02-01T06:06:16.218062Z",
"currency": "LTC",
"id": 2,
"network_data": {},
"relay_status": "",
"status": "needs_create",
"user_id": 0
}
}
}
Takes an Withdraw ID and returns data about that Withdraw
Path variables
Variable | Description |
---|---|
withdraw_id | Integer ID of the withdraw |
GET /v1/user/withdraw/:withdraw_id
Withdraw History
api.get("/v1/user/withdraws")
api.get("/v1/user/withdraws").json()
api.get("/v1/user/withdraws", (resp) => {})
<?php
$result = $api->get("/v1/user/withdraws");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"withdraws": [
{
"address": "mw67t7AE88SBSRWYw1is3JaFbtXVygwpmB",
"amount": "1",
"cancel_requested": false,
"created_at": "2019-02-01T06:06:16.218062Z",
"currency": "LTC",
"id": 2,
"network_data": {},
"relay_status": "",
"status": "needs_create",
"user_id": 0
}
]
}
}
Returns a list of the user's Withdraws and metadata including id
, amount
,
currency
, address
, status
, network_data
, created_at
values
Query params
Parameter | Type | Description |
---|---|---|
account_id | String | Return data only for the specified account |
GET /v1/user/withdraws?account_id=1000000-2
Deposit Details
api.get("/v1/user/deposit/ab5e1720944065ad64917929082191270896edc1b17d18e921aa5b1b26e18ab4")
api.get("/v1/user/deposit/ab5e1720944065ad64917929082191270896edc1b17d18e921aa5b1b26e18ab4").json()
api.get("/v1/user/deposit/ab5e1720944065ad64917929082191270896edc1b17d18e921aa5b1b26e18ab4", (resp) => {})
<?php
$result = $api->get("/v1/user/deposit/ab5e1720944065ad64917929082191270896edc1b17d18e921aa5b1b26e18ab4");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"deposit": [
{
"address": "1CK6KHY6MHgYvmRQ4PAafKYDrg1ejbH1cE",
"amount": "1",
"created_at": "2019-03-02T04:05:51.090427Z",
"currency": "BTC",
"id": "ab5e1720944065ad64917929082191270896edc1b17d18e921aa5b1b26e18ab4",
"network_data": {},
"relay_status": "",
"status": "credited"
}
]
}
}
Takes a Deposit ID and returns data about that Deposit
Path variables
Variable | Description |
---|---|
deposit_id | String ID of the deposit |
GET /v1/user/deposit/:deposit_id
Deposit History
api.get("/v1/user/deposits")
api.get("/v1/user/deposits").json()
api.get("/v1/user/deposits", (resp) => {})
<?php
$result = $api->get("/v1/user/deposits");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"deposits": [
{
"address": "1Kv3CKUigVPsxGCkkaoyLKrZHZ7WLq8jNK",
"amount": "0.25",
"created_at": "2019-01-08T21:15:18.775592Z",
"currency": "BTC",
"id": "1:855e291e4acd61c21fcbf1bc31aa2578fa8eb3b388d9e979077567a71b58f088",
"network_data": {
"confirms": 2,
"confirms_required": 2,
"txid": "855e291e4acd61c21fcbf1bc31aa2578fa8eb3b388d9e979077567a71b58f088",
"vout": 1
},
"relay_status": "",
"status": "credited"
}
]
}
}
Returns a list of the user's Deposits and metadata including id
, amount
,
currency
, address
, status
, network_data
, created_at
values.
Query params
Parameter | Type | Description |
---|---|---|
account_id | String | Return data only for the specified account |
GET /v1/user/deposits?account_id=1000000-2
Deposit Address
api.post("/v1/user/deposit_address/LTC")
req = {}
api.post("/v1/user/deposit_address/LTC", json=req).json()
req = {}
api.post("/v1/user/deposit_address/LTC", JSON.stringify(req), (resp) => {})
<?php
$req = array(
)
$result = $api->post("/v1/user/deposit_address/LTC", json_encode($req));
print_r(json_decode($result));
?>
200 Response
{
"data": {
"currency_status": "disabled"
}
}
200 Response
{
"data": {
"currency_status": "delisted"
}
}
200 Response
{
"data": {
"address": "mhBYubznoJxVEst6DNr6arZHK6UYVTsjqC",
"currency_status": "ok"
}
}
200 Response
{
"data": {
"address": "mhBYubznoJxVEst6DNr6arZHK6UYVTsjqC",
"currency_status": "degraded"
}
}
Returns a deposit address for sending money to your exchange account. This address should rarely change, but it is good practice to fetch it before sending currency every time.
The returned currency_status
key may be one of the following values:
Status | Returns address | Use case |
---|---|---|
ok |
Yes | Normal operation |
degraded |
Yes | Down for maintenance. Funds will be credited once maintenance is completed |
disabled |
No | Deposits temporarily disabled due to network issues. Typically due to excessive forking, stalled chain, or consesus issues |
offline |
No | Offline for other reason |
delisted |
No | Currency is delisted and deposits are no longer accepted |
Path variables
Variable | Description |
---|---|
currency | Currency code ala "LTC" |
POST /v1/user/deposit_address/:currency
Transfers
api.get("/v1/user/transfers")
api.get("/v1/user/transfers").json()
api.get("/v1/user/transfers", (resp) => {})
<?php
$result = $api->get("/v1/user/transfers");
print_r(json_decode($result));
?>
200 Response
{
"data": {
"transfers": [
{
"amount": "0.5",
"created_at": "2018-12-10T00:06:41.066665Z",
"currency": "BTC",
"id": 9,
"reason_code": "referral_payout",
"reason_metadata": {
"note": "January referral earnings"
},
"sender_email": "qtrade",
"sender_id": 218
}
]
}
}
Returns a list of the user's Transfers and metadata. Transfers are a special internal movement of funds between qTrade users. User created Transfers are not currently supported
Query params
Parameter | Type | Description |
---|---|---|
account_id | String | Return data only for the specified account |
GET /v1/user/transfers?account_id=1000000-2
Create Sell Limit
api.order('sell_limit', '0.01', amount=1, market_id=1)
api.order('sell_limit', '0.01', value=.01, market_string='LTC_BTC')
req = {'amount': '1', 'market_id': 1, 'price': '0.01'}
api.post("/v1/user/sell_limit", json=req).json()
req = {'amount': '1', 'market_id': 1, 'price': '0.01'}
api.post("/v1/user/sell_limit", JSON.stringify(req), (resp) => {})
<?php
$req = array(
"amount" => "1",
"price" => "0.01",
"market_id" => 1,
)
$result = $api->post("/v1/user/sell_limit", json_encode($req));
print_r(json_decode($result));
?>
200 Response
{
"data": {
"order": {
"created_at": "2018-04-06T20:46:52.899248Z",
"id": 13253,
"market_amount": "1",
"market_amount_remaining": "0",
"market_id": 1,
"open": false,
"order_type": "sell_limit",
"price": "0.01",
"trades": [
{
"base_amount": "0.27834267",
"base_fee": "0.00069585",
"created_at": "0001-01-01T00:00:00Z",
"id": 0,
"market_amount": "0.02820645",
"price": "9.86805058",
"taker": true
},
{
"base_amount": "9.58970687",
"base_fee": "0.02397426",
"created_at": "0001-01-01T00:00:00Z",
"id": 0,
"market_amount": "0.97179355",
"price": "9.86804952",
"taker": true
}
]
}
}
}
Creates an order to sell a currency at the specified price. Amount will be removed from your balance immediately. Returns the created order id.
POST Body
Variable | Example | Description |
---|---|---|
amount | "1.2345" | String. Exact amount in market currency, including decimal |
price | "0.1123" | String. Price in base currency of the market |
market_id | 36 | Integer ID of the market. Mutually exclusive with market_string |
market_string | "DOGE_BTC" | String identifier of the market. Mutually exclusive with market_id |
account_id | String | Create order for the specified account |
POST /v1/user/sell_limit
Create Buy Limit
api.order('buy_limit', '0.1', amount=10, market_id=1)
api.order('buy_limit', '0.1', value=1, market_string='LTC_BTC')
req = {'amount': '10', 'market_id': 1, 'price': '0.1'}
api.post("/v1/user/buy_limit", json=req).json()
req = {'amount': '10', 'market_id': 1, 'price': '0.1'}
api.post("/v1/user/buy_limit", JSON.stringify(req), (resp) => {})
<?php
$req = array(
"amount" => "10",
"price" => "0.1",
"market_id" => 1,
)
$result = $api->post("/v1/user/buy_limit", json_encode($req));
print_r(json_decode($result));
?>
200 Response
{
"data": {
"order": {
"base_amount": "1.0025",
"created_at": "2018-04-06T20:47:11.966139Z",
"id": 13254,
"market_amount": "10",
"market_amount_remaining": "10",
"market_id": 1,
"open": true,
"order_type": "buy_limit",
"price": "0.1",
"trades": []
}
}
}
Creates an order to buy a currency at the specified price on the specified market. Amount will be removed from your balance immediately. Returns the created order id.
The maximum fee will be escrowed from your account's balance when the order is created. Usually this is the market's taker fee. The fee will be returned to the user's account if it is not applicable, e.g. if the order executed as maker.
POST Body
Variable | Example | Description |
---|---|---|
amount | "1.2345" | String. Exact amount in market currency, including decimal |
price | "0.1123" | String. Price in base currency of the market |
market_id | 36 | Integer ID of the market. Mutually exclusive with market_string |
market_string | "DOGE_BTC" | String identifier of the market. Mutually exclusive with market_id |
account_id | String | Create order for the specified account |
POST /v1/user/buy_limit
Rate Limits
{
"X-Ratelimit-Limit": "60",
"X-Ratelimit-Reset": "56",
"X-Ratelimit-Remaining": "59",
...
}
A good rule of thumb is to limit your requests to 1 / second. The rate limit is enforced by limiting the number of requests in a specific time period. The limit is reset after that time period has elapsed. This means your rate limit within that time period is burstable, and not strictly limited to 1/second. You can monitor the current rate limit status by checking the response headers of your requests. Outlined below are the headers we return and how they work.
If you'd like a higher rate limit please contact support and explain your use case.
Header | How it is used |
---|---|
X-Ratelimit-Limit | The number of maximum requests available in the time period |
X-RateLimit-Reset | How many seconds until your rate limit resets |
X-Ratelimit-Remaining | How many requests you have left for the time period |
CORS
For increased user security we've limited valid CORS origins for private API routes, and some public API routes. Only the qtrade.io domain origin is valid for those API requests, and this means private API requests performed in a browser (ie, via javascript) will fail.
If your app needs private API access we recommend performing your API requests on the server side. For example, if you want to display your qTrade deposit address to someone visiting your website, make the request to the deposit endpoint on the server and return that data to your client in your HTTP response.
Open CORS Endpoint | URL |
---|---|
Currencies | /currencies , /currency/:CODE |
Tickers | /tickers , /ticker/:market_string |
Markets | /markets , /market/:market_string |
Market Orderbook | /orderbook/:market_string |
Market Trades | /market/:market_string/trades |
Postman Collection
For convenience you can download a Postman collection to play around with the API.
- Import the collection
- Import the Environment
- Set the
hmac_key
andhmac_key_id
environment variables to match an API key you generated - Execute API calls!
Get the Collection and Environment
Errors
Response 403
{
"errors": [
{
"code": "invalid_auth",
"title": "Invalid HMAC signature"
}
]
}
Errors return with a JSON object explaining the cause, if applicable.
The qTrade API returns the following error codes:
Error Code | Meaning |
---|---|
400 | Bad Request -- Your request is invalid. Typically bad JSON or missing values. |
401 | Unauthorized -- Your API key didn't validate. |
403 | Forbidden -- Your API key doesn't have permission to do that. |
404 | Not Found -- The specified item (market, order, api key, etc) was not found. |
429 | Too Many Requests -- You're making API calls too rapidly, slow down! |
500 | Internal Server Error -- We had a problem with our server. Try again later. |
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later. |