UNPKG

quadriga-node-api

Version:

An async/await Node.js api wrapper for QuadrigaCX

136 lines (125 loc) 3.43 kB
const axios = require('axios') const Private = {} /* Get account balances (signed) */ Private.accountBalances = async function() { let url = this.baseURL + 'balance' let nonce = Date.now() let params = { key: this.apiKey, nonce: nonce, signature: this.sign(nonce) } return axios.post(url, params) } /* Get user transactions (signed) params = { offset: integer (skip n transactions) Default: 0 OPTIONAL limit: integer (limit to n transactions) Default: 50 OPTIONAL sort: 'desc' || 'asc' Default: desc OPTIONAL book: string (e.g. 'btc_cad') Default: 'btc_cad' OPTIONAL } */ Private.userTransactions = async function(params) { let url = this.baseURL + 'user_transactions' let nonce = Date.now() params.key = this.apiKey params.nonce = nonce params.signature = this.sign(nonce) return axios.post(url, params) } /* Get open orders (signed) symbol = string (e.g. 'btc_cad') Default: 'btc_cad' OPTIONAL */ Private.openOrders = async function(symbol) { let url = this.baseURL + 'open_orders' let nonce = Date.now() let params = { key: this.apiKey, nonce: nonce, signature: this.sign(nonce) } params.book = symbol return axios.post(url, params) } /* Lookup specific order(s) (signed) id = string || array (of 64 characters long hexadecimal string taken from the list of orders) */ Private.lookupOrder = async function(id) { let url = this.baseURL + 'lookup_order' let nonce = Date.now() let params = { key: this.apiKey, nonce: nonce, signature: this.sign(nonce) } params.id = id return axios.post(url, params) } /* Cancel a specific order by id (signed) id = string (a 64 characters long hexadecimal string) MANDATORY */ Private.cancelOrder = async function(id) { let url = this.baseURL + 'cancel_order' let nonce = Date.now() let params = { key: this.apiKey, nonce: nonce, signature: this.sign(nonce) } params.id = id return axios.post(url, params) } /* Place a buy/sell, limit/market order (if no price is provided as param, it will execute as a market order) side: string ('buy' || 'sell') params = { amount: float MANDATORY price: float MANDATORY FOR LIMIT ORDER book: string (e.g. 'btc_cad') Default: 'btc_cad' OPTIONAL } */ Private.placeOrder = async function(side, params) { let url = this.baseURL + side let nonce = Date.now() params.key = this.apiKey params.nonce = nonce params.signature = this.sign(nonce) return axios.post(url, params) } /* Get bitcoin deposit address for funding the account coin = string (e.g. 'bitcoin' || 'bitcoincash') lowercase & MANDATORY */ Private.deposit = async function(coin) { let url = this.baseURL + coin + '_deposit_address' let nonce = Date.now() let params = { key: this.apiKey, nonce: nonce, signature: this.sign(nonce) } return axios.post(url, params) } /* Withdraws bitcoin based on provided params, returns OK or error coin = string (e.g. 'bitcoin' || 'bitcoincash' || 'ether') lowercase & MANDATORY params = { amount: float MANDATORY address: string MANDATORY } */ Private.withdraw = async function(coin, params) { let url = this.baseURL + coin + '_withdrawal' let nonce = Date.now() params.key = this.apiKey params.nonce = nonce params.signature = this.sign(nonce) return axios.post(url, params) } module.exports = Private