Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v3.4.0 #159

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading