Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
btc-markets
Advanced tools
Readme
This library is a node.js wrapper for the private and public methods exposed by the BTC Markets API. You will need to have a registered account with BTC Markets and generated API keys to access the private methods.
Please contact support@btcmarkets.net if you are having trouble opening an account or generating an API key.
npm install btc-markets
This library has bee upgraded to be written in TypeScript and use promises. If you want the old version that used to callbacks, then use v0.0.10.
Other changes are:
The first parameter to each API function is a callback function which is passed error and data objects.
The error object is an instance of VError which is an extension of the standard Error object. The three main properties are:
Do not commit your API keys into public source code repositories. These can be in code, config files or IDE config files used to run tests or processes.
If you can't avoid committing API keys into your repo then use something like git-crypt.
Most cloud providers now offer solutions for securely storing API keys. For example:
And while I'm at it, make sure you enable two-factor authentication. Your account is easy to hack without 2FA enabled. You have been warned!
If you'd like to thank me for this library, you can always donate some of your crypto trading profits to:
The following is from examples.js
//const BTCMarkets = require('btc-markets').default; // if you are using JavaScript
import BTCMarkets from 'btc-markets'; // if you are using TypeScript or Babel
// Either pass your API key and secret as the first and second parameters to examples.js. eg
// node examples.js your-api-key your-api-secret
//
// Or enter them below.
// WARNING never commit your API keys into a public repository.
const key = process.argv[2] || 'your-api-key';
const secret = process.argv[3] || 'your-api-secret';
const client = new BTCMarkets(key, secret);
// get latest prices
const tick = await client.getTick("BTC", "AUD");
// get order book
const orderBook = await client.getOrderBook("BTC", "AUD");
// get market trades since 728992317
const trades = await client.getTrades("BTC", "AUD", 728992317);
// limit buy order for of 0.001 ETH at 50 AUD
const limitOrder = await client.createOrder("ETH", "AUD", 50 * BTCMarkets.numberConverter, 0.001 * BTCMarkets.numberConverter, 'Bid', 'Limit', "10001");
//market sell for 0.001 BTC
const marketOrder = await client.createOrder("BTC", "AUD", null, 0.001 * BTCMarkets.numberConverter, 'Ask', 'Market', null);
// limit buy order for of 0.001 ETH at 50 AUD with 40 AUD stop loss
const stopLossOrder = await client.createOrder("ETH", "AUD", 50 * BTCMarkets.numberConverter, 0.001 * BTCMarkets.numberConverter, 'Bid', 'Stop Limit', "10002", 40 * BTCMarkets.numberConverter);
console.log(`Stop loss order: ${JSON.stringify(stopLossOrder)}`);
// cancel two limit orders with id's 1132477709 and 1133590603
const cancelledOrders = await client.cancelOrders([1132477709, 1133590603]);
const accountBalances = await client.getAccountBalances();
// get trading fee for a trading pair
const tradingFee = await client.getTradingFee("BTC", "AUD");
// get order details
const orderDetails = await client.getOrderDetail([206855175, 23988196]);
// get all trades since the start of time
const tradeHistory = await client.getTradeHistory("BTC", "AUD", undefined, null);
// get 50 orders since the start of time
const orderHistory = await client.getOrderHistory("BTC", "AUD", 50, null);
// get my open orders
const openOrders = await client.getOpenOrders('BTC', 'AUD', 10, null);
// withdrawal 0.05 ETH
const cryptoWithdrawal = await client.withdrawCrypto(0.05 * BTCMarkets.numberConverter, "0x775053A6125cB51e618Eb132f00E93d6033934AD", "ETH");
// withdrawal history
const withdrawHistory = await client.withdrawHistory(10, 0, true);
FAQs
BTC Markets API Client for Node.JS
The npm package btc-markets receives a total of 53 weekly downloads. As such, btc-markets popularity was classified as not popular.
We found that btc-markets demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.