Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
bitget-api-mangonv2
Advanced tools
Node.js connector for Bitget REST APIs and WebSockets, with TypeScript & end-to-end tests.
Node.js connector for the Bitget APIs and WebSockets:
npm install --save bitget-api
Check out my related projects:
Most methods pass values as-is into HTTP requests. These can be populated using parameters specified by Bitget's API documentation, or check the type definition in each class within this repository (see table below for convenient links to each class).
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).
Each REST API group has a dedicated REST client. To avoid confusion, here are the available REST clients and the corresponding API groups:
Class | Description |
---|---|
SpotClient | Spot APIs |
FuturesClient | Futures APIs |
BrokerClient | Broker APIs |
WebsocketClient | Universal client for all Bitget's Websockets |
Examples for using each client can be found in:
If you're missing an example, you're welcome to request one. Priority will be given to github sponsors.
First, create API credentials on Bitget's website.
All REST clients have can be used in a similar way. However, method names, parameters and responses may vary depending on the API category you're using!
Not sure which function to call or which parameters to use? Click the class name in the table above to look at all the function names (they are in the same order as the official API docs), and check the API docs for a list of endpoints/paramters/responses.
const {
SpotClient,
FuturesClient,
BrokerClient,
} = require('bitget-api');
const API_KEY = 'xxx';
const API_SECRET = 'yyy';
const API_PASS = 'zzz';
const client = new SpotClient({
apiKey: API_KEY,
apiSecret: API_SECRET,
apiPass: API_PASS,
},
// requestLibraryOptions
);
// For public-only API calls, simply don't provide a key & secret or set them to undefined
// const client = new SpotClient();
client.getApiKeyInfo()
.then(result => {
console.log("getApiKeyInfo result: ", result);
})
.catch(err => {
console.error("getApiKeyInfo error: ", err);
});
const symbol = 'BTCUSDT_SPBL';
client.getCandles(symbol, '1min');
.then(result => {
console.log("getCandles result: ", result);
})
.catch(err => {
console.error("getCandles error: ", err);
});
For more examples, including how to use websockets with bitget, check the examples and test folders.
Pass a custom logger which supports the log methods silly
, debug
, notice
, info
, warning
and error
, or override methods from the default logger as desired.
const { WebsocketClient, DefaultLogger } = require('bitget-api');
// Disable all logging on the silly level
DefaultLogger.silly = () => {};
const ws = new WebsocketClient(
{
apiKey: 'API_KEY',
apiSecret: 'API_SECRET',
apiPass: 'API_PASS',
},
DefaultLogger,
);
In rare situations, you may want to see the raw HTTP requets being built as well as the API response. These can be enabled by setting the BITGETTRACE
env var to true
.
Build a bundle using webpack:
npm install
npm build
npm pack
The bundle can be found in dist/
. Altough usage should be largely consistent, smaller differences will exist. Documentation is still TODO.
Support my efforts to make algo trading accessible to all - register with my referral links:
Or buy me a coffee using any of these:
1C6GWZL1XW3jrjpPTS863XtZiXL1aTK7Jk
0xd773d8e6a50758e1ada699bb6c4f98bb4abf82da
Contributions are encouraged, I will review any incoming pull requests. See the issues tab for todo items.
FAQs
Node.js connector for Bitget REST APIs and WebSockets, with TypeScript & end-to-end tests.
The npm package bitget-api-mangonv2 receives a total of 7 weekly downloads. As such, bitget-api-mangonv2 popularity was classified as not popular.
We found that bitget-api-mangonv2 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.