UNPKG

polygon.io

Version:

Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs

16 lines (15 loc) 466 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getWsClient = void 0; const websocket_1 = require("websocket"); const getWsClient = (url, apiKey) => { if (!apiKey) { throw new Error("api key not provided."); } const ws = new websocket_1.w3cwebsocket(url); ws.onopen = () => { ws.send(JSON.stringify({ action: "auth", params: apiKey })); }; return ws; }; exports.getWsClient = getWsClient;