Path: blob/master/bitget-node-sdk-api/__test__/api.spec.ts
518 views
import BitgetResetApi from '../src';1import Console from 'console';2import {describe, test} from '@jest/globals'3import {toJsonString} from '../src/lib/util';4import {MixOrderApi} from '../src/lib/v2/MixOrderApi';56const apiKey = '';7const secretKey = "";8const passphrase = '';9describe('ApiTest', () => {10const mixOrderApi = new BitgetResetApi.MixOrderApi(apiKey, secretKey, passphrase);11const mixOrderV2Api = new MixOrderApi(apiKey, secretKey, passphrase);12const bitgetApi = new BitgetResetApi.BitgetApi(apiKey, secretKey, passphrase);1314test('place order', () => {15const qsOrBody = {16'symbol': 'BTCUSDT_UMCBL',17'marginCoin': 'USDT',18'side': 'open_long',19'orderType': 'limit',20'price': '27012',21'size': '0.01',22'timInForceValue': 'normal'23};24return mixOrderApi.placeOrder(qsOrBody).then((data) => {25Console.info(toJsonString(data));26});27})2829test('send post request directly If the interface is not defined in the sdk', () => {30const qsOrBody = {31'symbol': 'BTCUSDT_UMCBL',32'marginCoin': 'USDT',33'side': 'open_long',34'orderType': 'limit',35'price': '27012',36'size': '0.01',37'timInForceValue': 'normal'38};39return bitgetApi.post("/api/mix/v1/order/placeOrder", qsOrBody).then((data) => {40Console.info(toJsonString(data));41});42})4344test('send get request directly If the interface is not defined in the sdk', () => {45const qsOrBody = {'symbol': 'btcusdt_spbl','b':'b','a':'a'};46return bitgetApi.get("/api/spot/v1/market/depth", qsOrBody).then((data) => {47Console.info(toJsonString(data));48});49})5051test('send get request directly If the interface is not defined in the sdk need auth', () => {52const qsOrBody = {'productType': 'umcbl','b':'b','a':'a'};53return bitgetApi.get("/api/mix/v1/account/accounts", qsOrBody).then((data) => {54Console.info(toJsonString(data));55});56})5758test('send get request directly If the interface is not defined in the sdk need auth spot', () => {59const qsOrBody = {};60return bitgetApi.get("/api/spot/v1/account/getInfo", qsOrBody).then((data) => {61Console.info(toJsonString(data));62});63})6465test('send get request directly with encode params', () => {66const qsOrBody = {'symbol': '$AIUSDT','businessType':'spot'};67return bitgetApi.get("/api/v2/common/trade-rate", qsOrBody).then((data) => {68Console.info(toJsonString(data));69});70})71});72737475