Skip to content

Commit

Permalink
Release v3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alplabin committed Jun 19, 2024
1 parent c778a4e commit 843b3c5
Show file tree
Hide file tree
Showing 19 changed files with 361 additions and 424 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 3.4.0 - 2024-06-19
### Changed
- Updated dependencies
- Resolved multiple websocket stream request issue

## 3.3.0 - 2024-04-04

### Added
Expand Down
2 changes: 1 addition & 1 deletion docs_src/gettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ There are 2 types of error may be returned from the API server and the user has
const { Spot } = require('@binance/connector')

const client = new Spot('', '', {
wsURL: 'wss://testnet.binance.vision' // If optional base URL is not provided, wsURL defaults to wss://stream.binance.com:9443
wsURL: 'wss://stream.testnet.binance.vision' // If optional base URL is not provided, wsURL defaults to wss://stream.binance.com:9443
})

const callbacks = {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/market/historicalTrades.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const callbacks = {
const apiKey = ''

// wsURL is optional, by default it's set to the production site: 'wss://ws-api.binance.com:443/ws-api/v3'.
const websocketAPIClient = new WebsocketAPI(apiKey, null, { logger, callbacks, wsURL: 'wss://testnet.binance.vision/ws-api/v3' })
const websocketAPIClient = new WebsocketAPI(apiKey, null, { logger, callbacks, wsURL: 'wss://ws-api.testnet.binance.vision/ws-api/v3' })

// disconnect after 20 seconds
setTimeout(() => websocketAPIClient.disconnect(), 20000)
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/cancelOCOOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/cancelOpenOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/cancelOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/cancelReplaceOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/getOCOOpenOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/getOCOOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/getOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/newOCOOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/newOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/openOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/websocketAPI/spot/trade/testNewOrder.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const apiKey = process.env.BINANCE_API_KEY || ''
const apiSecret = process.env.BINANCE_API_SECRET || ''
const wsURL = 'wss://testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3
const wsURL = 'wss://ws-api.testnet.binance.vision/ws-api/v3' // we setup wsURL to testnet. The default value set to production site: wss://ws-api.binance.com/ws-api/v3

const callbacks = {
open: (client) => {
Expand Down
9 changes: 6 additions & 3 deletions examples/websocketStream/spot/combinedStreams.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ const callbacks = {
// Connect to websocket server in combine mode, the stream name will be returned in response messages
const websocketStreamClient = new WebsocketStream({ logger, callbacks, combinedStreams: true })

// subscribe to kline stream
// subscribe to bnbusdt kline stream
websocketStreamClient.kline('bnbusdt', '1m')

// subscribe to trade stream
setTimeout(() => { websocketStreamClient.trade('bnbusdt') }, 3000)
// subscribe to ethusdt kline stream
setTimeout(() => { websocketStreamClient.kline('ethusdt', '1m') }, 3000)

// subscribe to btcusdt kline stream
setTimeout(() => { websocketStreamClient.kline('btcusdt', '1m') }, 3000)

// disconnect from websocket server
setTimeout(() => websocketStreamClient.disconnect(), 10000)
16 changes: 16 additions & 0 deletions examples/websocketStream/spot/multiSubscription.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { Console } = require('console')
const WebsocketStream = require('../../../src/websocketStream')

const logger = new Console({ stdout: process.stdout, stderr: process.stderr })

const callbacks = {
open: () => logger.debug('Connected to WebSocket server'),
close: () => logger.debug('Disconnected from WebSocket server'),
message: (data) => logger.info(data)
}

const websocketStreamClient = new WebsocketStream({ logger, callbacks })

websocketStreamClient.subscribe(['bnbusdt@ticker', 'btcusdt@ticker'])

setTimeout(() => websocketStreamClient.disconnect(), 6000)
Loading

0 comments on commit 843b3c5

Please sign in to comment.