Skip to content

Commit

Permalink
Add server selection feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu2301 committed Jul 17, 2022
1 parent cd5957f commit b74e45e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mathieuc/tradingview",
"version": "3.3.0",
"version": "3.3.1",
"description": "Tradingview instant stocks API, indicator alerts, trading bot, and more !",
"main": "main.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ module.exports = class Client {
* @typedef {Object} ClientOptions
* @prop {string} [token] User auth token (in 'sessionid' cookie)
* @prop {boolean} [DEBUG] Enable debug mode
* @prop {'data' | 'prodata' | 'widgetdata'} [server] Server type
*/

/** Client object
Expand All @@ -223,7 +224,8 @@ module.exports = class Client {
constructor(clientOptions = {}) {
if (clientOptions.DEBUG) global.TW_DEBUG = clientOptions.DEBUG;

this.#ws = new WebSocket('wss://data.tradingview.com/socket.io/websocket', {
const server = clientOptions.server || 'data';
this.#ws = new WebSocket(`wss://${server}.tradingview.com/socket.io/websocket`, {
origin: 'https://s.tradingview.com',
});

Expand Down

0 comments on commit b74e45e

Please sign in to comment.