UNPKG

quadriga-node-api

Version:

An async/await Node.js api wrapper for QuadrigaCX

141 lines (97 loc) 3.91 kB
# quadriga-node-api This is an open source project created to utilize the QuadrigaCX API to support automated, algorithmic trading. The project was made and tested for Node 8.0+. There are no guarentees towards the stability or effectiveness of this project. Comments, contributions, stars and donations are, however, all welcome. ## Installation `npm install quadriga-node-api` ## Getting Started To begin using the API wrapper, require it, create a config object that contains your API key, Secret key and Account Id provided by QuadrigaCX and then run the custom init() function with your config object as a parameter. Example code is as follows: ```javascript const api = require('quadriga-node-api') const config = { apiKey: 'xXXXXX', secretKey: 'xxxxxxxxXXXXXXXXXXXXXxxXXXXXXXXXXXXXxxxXXX', clienId: 'xxxxxxx' } api.init(config) ``` Public endpoints can be accessed without config. Example: ```javascript const api = require('quadriga-node-api') api.init() ``` However, none of the Private endpoints will work. ## Using the API Wrapper Once the API wrapper object is created, you can call any of the associated functions. You can use the api object either indirectly through async/await or directly as a Promise with .then .catch calls. Simple examples: ```javascript // async/await indirect approach async function getAccountBalances() { try { let response = await api.accountBalances() console.log(response.data) } catch (err) { console.log(err) } } // Promise based direct approach api.accountBalances().then(r=>console.log(r.data)).catch(e=>console.log(e)) ``` ## Public Endpoints (REST) Public endpoints do not require an API key, Secret Key or Account Id. `api.tradingInfo(symbol)` symbol = 'string' (e.g. 'btc_usd') OPTIONAL `api.orderBook(params)` ```javascript params = { book: 'string' (e.g. 'btc_usd') Default: 'btc_cad' OPTIONAL group: integer (0 - false; 1 - true) Default: 1 OPTIONAL } ``` `api.transactions(params)` ```javascript params = { book: string (e.g. 'btc_usd') Default: 'btc_cad' OPTIONAL time: string (e.g. 'minute') Default: 'hour' OPTIONAL } ``` ## Private Endpoints (REST) Private endpoints require an API key, Secret Key and Account Id provided as a config variable during api.init(config) as described above. `api.accountBalances()` `api.userTransactions(params)` ```javascript 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 } ``` `api.openOrders(symbol)` symbol = string (e.g. 'btc_cad') Default: 'btc_cad' OPTIONAL `api.lookupOrder(id)` id = string || array (of 64 characters long hexadecimal string taken from the list of orders) `api.cancelOrder(id)` id = string (a 64 characters long hexadecimal string) MANDATORY `api.placeOrder(side, params)` ```javascript //Place a buy/sell, limit/market order (if no price is provided as param, it will side: string ('buy' || 'sell') params = { amount: float MANDATORY price: float MANDATORY FOR LIMIT ORDER book: string (e.g. 'btc_cad') Default: 'btc_cad' OPTIONAL } ``` `api.deposit(coin)` coin = string (e.g. 'bitcoin' || 'bitcoincash') lowercase & MANDATORY `api.withdraw(coin, params)` ```javascript coin = string (e.g. 'bitcoin' || 'bitcoincash' || 'ether') lowercase & MANDATORY params = { amount: float MANDATORY address: string MANDATORY } ``` ## Donation Addresses BTC: 3KX8P6caBdhtLuPJk7Lu7onprCJiQELxCQ ETH: 0x8d88ffbb6e74531652e916eb9b52c40da9e5f686 LTC: LhZKNPBUgQHb4J9KNEWTj8boJy2mKnNEVC Contact me for any other specific cryptocurrencies you'd prefer to use. ## License This project is open source and uses the ISC license. Feel free to utilize in whatever way you see fit.