UNPKG

@itick/browser-sdk

Version:

Official iTick API SDK for browser. Real-time & historical data for global Stocks, Forex, Crypto, Indices, Futures, Funds, Precious Metals. REST (OHLCV/K-line) + low-latency WebSocket. Promise-based, TypeScript-ready. For quant trading & fintech

47 lines 1.54 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Client = void 0; const index_1 = require("./index"); const SocketClient_1 = __importDefault(require("./SocketClient")); /** * Core Client Class * Provides basic functionality for WebSocket connections and HTTP requests */ class Client { constructor(token, options = {}) { this.token = token; this.baseURL = options.baseURL ?? 'https://api.itick.org'; this.wssURL = options.wssURL ?? 'wss://api.itick.org'; } /** * Send GET request */ async _get(path, params = {}) { try { const url = (0, index_1.buildApiUrl)(this.baseURL, path); const response = await (0, index_1.makeHttpRequest)(url, { method: 'GET', headers: { 'accept': 'application/json', 'token': this.token }, params, }); if (response.status >= 400) { throw new Error(`HTTP Error: ${response.status}`); } return response.data; } catch (error) { throw error; } } _createSocket(path, options) { return new SocketClient_1.default(this.token, { wssURL: this.wssURL, wsPath: path, ...options }); } } exports.Client = Client; //# sourceMappingURL=client.js.map