npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bitmart-api

v2.0.4

Published

Complete & robust Node.js SDK for BitMart's REST APIs and WebSockets, with TypeScript declarations.

Downloads

223

Readme

Node.js & Typescript BitMart API SDK

Build & Test npm version npm size npm downloads last commit CodeFactor Telegram

connector logo

Complete JavaScript & Node.js SDK for BitMart REST APIs & WebSockets:

  • Complete integration with all BitMart APIs.
  • TypeScript support (with type declarations for most API requests & responses)
  • Robust WebSocket integration with configurable connection heartbeats & automatic reconnect then resubscribe workflows.
  • Browser-friendly HMAC signature mechanism.
  • Automatically supports both ESM and CJS projects.

Installation

npm install --save bitmart-api

Issues & Discussion

Usage

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.

REST APIs

  • Create API credentials within your account on BitMart's website, if you haven't done so already.
  • Import/require the module
  • Create an instance of the REST client
  • Call the function corresponding to the API call and handle the returned promise.
const { RestClient } = 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);
});

Recv Window

This can be set two levels:

  • Per method: if provided in a method, will be used instead of the global default
  • Global default: this will apply by default to any api call that supports recvWindow, if no recvWindow is provided in the method call.

Custom Sign

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.


Related projects

Check out my related projects:

Structure

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.

  • src - the whole SDK written in TypeScript
  • dist - ESM & CJS builds of the SDK in JavaScript (this is published to npm)
  • examples - some implementation examples & demonstrations.

Contributions & Thanks

Donations

tiagosiebler

If you found this project interesting or useful, do consider sponsoring me on github. Thank you!

Contributions & Pull Requests

Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items.

Star History

Star History Chart