bitget-openapi-top
v1.0.1
Published
## 安装
Downloads
3
Readme
使用说明
安装
npm i bitget-openapi-top
本地运行
git clone https://github.com/BitgetLimited/v3-bitget-api-sdk.git
cd v3-bitget-api-sdk/bitget-node-sdk-api
npm run install
npm run build
测试用例
| 文件名 | 说明 | | :--------------------------------: | :------------------: | | __test__/mixapi.spec.ts | 合约相关测试用例 | | __test__/spotapi.spec.ts | 现货相关测试用例 | | __test__/websocketTest.spec.ts | 消息推送相关测试用例 | | | |
API示例
const bitgetApi = require('bitget-openapi');
const { test, describe, expect } = require('@jest/globals')
const Console = require('console')
const apiKey = '';
const secretKey = '';
const passphrase = '';
describe('test accounts', () => {
test('accounts', () => {
const mixAccountApi = new bitgetApi.default.MixAccountApi(apiKey,secretKey,passphrase);
mixAccountApi.accounts('umcbl').then((data) => {
Console.info(data);
});
})
})
websocket示例
var bitgetApi = require("bitget-openapi")
var Console = require("console")
const apiKey = '';
const secretKey = '';
const passphrase = '';
//处理消息的实现类
class ListennerObj extends bitgetApi.default.Listenner{
reveice(message){
Console.info('>>>'+message);
}
}
const listenner = new ListennerObj();
const bitgetWsClient = new bitgetApi.default.BitgetWsClient(listenner,apiKey,secretKey,passphrase);
const subArr = new Array();
const subscribeOne = new bitgetApi.default.SubscribeReq('mc','ticker','BTCUSD');
const subscribeTow = new bitgetApi.default.SubscribeReq('SP','candle1W','BTCUSDT');
subArr.push(subscribeOne);
subArr.push(subscribeTow);
bitgetWsClient.subscribe(subArr)