Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
bitmart-api
Advanced tools
Complete & robust Node.js SDK for BitMart's REST APIs and WebSockets, with TypeScript declarations.
Complete JavaScript & Node.js SDK for BitMart REST APIs & WebSockets:
npm install --save bitmart-api
Most methods pass values as-is into HTTP requests. These can be populated using parameters specified by BitMart's API documentation, or check the type definition in each class within this repository.
const { RestClient, FuturesClientV2 } = require('bitmart-api');
const client = new RestClient({
apiKey: 'yourAPIKeyHere',
apiSecret: 'yourAPISecretHere',
apiMemo: 'yourAPIMemoHere',
});
client
.getAccountBalancesV1()
.then((result) => {
console.log('getAccountBalancesV1 result: ', result);
})
.catch((err) => {
console.error('getAccountBalancesV1 error: ', err);
});
// For futures, use the FuturesClientV2 - it's mapped to the new V2 futures sub domain
const futuresV2Client = new FuturesClientV2({
apiKey: 'yourAPIKeyHere',
apiSecret: 'yourAPISecretHere',
apiMemo: 'yourAPIMemoHere',
});
const balances = await futuresV2Client.getFuturesAccountAssets();
console.log('Balances: ', JSON.stringify(balances, null, 2));
// create websocket client
// If public client, doesn't need API keys
const client = new WebsocketClient();
// If private client, needs API keys
const client = new WebsocketClient({
apiKey: 'yourAPIKeyHere',
apiSecret: 'yourAPISecretHere',
apiMemo: 'yourAPIMemoHere',
});
client.on('open', (data) => {
console.log('connected ', data?.wsKey);
});
// Data received
client.on('update', (data) => {
console.info('data received: ', JSON.stringify(data));
});
// Something happened, attempting to reconenct
client.on('reconnect', (data) => {
console.log('reconnect: ', data);
});
// Reconnect successful
client.on('reconnected', (data) => {
console.log('reconnected: ', data);
});
// Connection closed. If unexpected, expect reconnect -> reconnected.
client.on('close', (data) => {
console.error('close: ', data);
});
// Reply to a request, e.g. "subscribe"/"unsubscribe"/"authenticate"
client.on('response', (data) => {
console.info('response: ', data);
});
client.on('exception', (data) => {
console.error('exception: ', data);
});
client.on('authenticated', (data) => {
console.error('authenticated: ', data);
});
// subscribing to topics
// Spot User Orders
client.subscribe('spot/user/order:BTC_USDT', 'spot');
// Ticker Channel
// client.subscribe('futures/ticker', 'futures');
// Depth Channel
// client.subscribe('futures/depth20:BTCUSDT', 'futures');
// Trade Channel
// client.subscribe('futures/trade:BTCUSDT', 'futures');
// KlineBin Channel
// client.subscribe('futures/klineBin1m:BTCUSDT', 'futures');
// Or have multiple topics in one array:
client.subscribe(
[
'futures/klineBin1m:BTCUSDT',
'futures/klineBin1m:ETHUSDT',
'futures/klineBin1m:XRPUSDT',
'futures/klineBin1m:BMXUSDT',
'futures/klineBin1m:SOLUSDT',
],
'futures',
);
This can be set two levels:
Authentication involves HMAC signing on the request, using API credentials. Internally, this SDK uses the Web Crypto API. The REST client also supports injecting a custom sign function, should you wish to use an alternative (such as node's native & faster createHmac).
Refer to the fasterHmacSign.ts example for a demonstration.
Check out my related JavaScript/TypeScript/Node.js projects:
This connector is fully compatible with both TypeScript and pure JavaScript projects, while the connector is written in TypeScript. A pure JavaScript version can be built using npm run build
, which is also the version published to npm.
The version on npm is the output from the build
command and can be used in projects without TypeScript (although TypeScript is definitely recommended).
Note: The build will output both ESM and CJS, although node should automatically import the correct entrypoint for your environment.
Have my projects helped you? Share the love, there are many ways you can show your thanks:
0xA3Bda8BecaB4DCdA539Dc16F9C54a592553Be06C
Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items.
FAQs
Complete & robust Node.js SDK for BitMart's REST APIs and WebSockets, with TypeScript declarations.
The npm package bitmart-api receives a total of 28 weekly downloads. As such, bitmart-api popularity was classified as not popular.
We found that bitmart-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.