The web browser javascript SDK for iTick API, providing REST API queries and WebSocket real-time data subscription for basics, stocks, indices, futures, funds, forex, and crypto. Used to access real-time financial market data from the iTick API.
- Comprehensive Market Coverage: Access global financial markets including stocks, crypto, forex, indices, futures, and funds
- Real-time Data: WebSocket-based real-time data streaming with automatic reconnection support
- RESTful API: Clean and intuitive REST API for retrieving historical data and snapshots
- Type Safety: Full TypeScript support with comprehensive type definitions
- Auto Reconnection: Built-in automatic reconnection mechanism (5-second interval, configurable unlimited attempts)
- Heartbeat Keep-alive: Automatic ping/pong mechanism (30-second interval) to maintain stable connections
- Modular Design: Independent modules organized by asset type for clearer structure
- Flexible Subscription: Support for subscribing to quotes, order book depth, trades, and candlestick data
| Chrome | Firefox | Safari | Opera | Edge |
|---|---|---|---|---|
![]() | ![]() | ![]() | ![]() | ![]() |
| Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ |
Using npm:
npm install @itick/browser-sdkUsing yarn:
yarn add @itick/browser-sdkUsing pnpm:
pnpm add @itick/browser-sdk<!-- Using unpkg CDN --><scriptsrc="https://unpkg.com/@itick/browser-sdk@latest/dist/itick-sdk.min.js"></script><!-- Or using jsDelivr CDN --><scriptsrc="https://cdn.jsdelivr.net/npm/@itick/browser-sdk@latest/dist/itick-sdk.min.js"></script><script>const{ BaseClient, StockClient, CryptoClient, ForexClient, IndicesClient, FutureClient, FundClient }=window.iTickSDK;</script>import{StockClient}from"@itick/browser-sdk";// Initialize client with API Tokenconsttoken=process.env.ITICK_TOKEN;constclient=newStockClient(token);// Get stock quoteasyncfunctiongetQuote(){try{constresponse=awaitclient.getQuote({region: "US",code: "AAPL"});if(response.code===0&&response.data){console.log("Latest Price:",response.data.ld);console.log("Change %:",response.data.chp);}}catch(error){console.error("Error:",error.message);}}getQuote();import{CryptoClient}from"@itick/browser-sdk";constclient=newCryptoClient(token);// Create WebSocket connection with subscription data - SDK handles connection and automatically subscribes after reconnection, no need to send subscription data againconstsocket=client.createSocket({maxReconnectTimes: 10,// Maximum reconnection attempts, default is 0 (unlimited)pingInterval: 30000,// Ping interval, default 30 secondsreconnectInterval: 5000,// Reconnection interval, default 5 secondssubscribeData: {codes: ["BTCUSDT$BA","ETHUSDT$BA"],types: ["quote","tick"],},});// Create custom WebSocket connectionconstsocket=client.createSocket();// Send subscription data after successful connection or reconnectionsocket.onSocketOpen(()=>{socket.subscribeData({codes: ["BTCUSDT$BA","ETHUSDT$BA"],types: ["quote","tick"],});});// Handle received messagessocket.onSocketMessage((res)=>{console.log("Received data:",res);});// Handle errorssocket.onSocketError((error)=>{console.error("WebSocket error:",error);});// Disconnect when done// socket.disconnectSocket();Financial instrument listings, market holiday information, and trading hours.
import{BaseClient}from"@itick/browser-sdk";constclient=newBaseClient(token);// Get symbol listawaitclient.getSymbolList({type: "stock",region: "US"});awaitclient.getSymbolList({type: "crypto",region: "BA"});awaitclient.getSymbolList({type: "forex",region: "GB"});// Get market holidaysawaitclient.getSymbolHolidays("US");awaitclient.getSymbolHolidays("HK");| Method Name | Parameters | Return Type | Description | Details |
|---|---|---|---|---|
getSymbolList | options: Object- type:enum (Product type, e.g., stock,forex,fund,future,indices) - region:string (Market region code, e.g., US, BA, GB, etc.) | Promise<APIResponse<SymbolListData[]>> | Get financial instrument listings (symbol list) for specified market and asset type. | iTick Symbol List |
getSymbolHolidays | region: string (Market region code, e.g., US, HK, etc.) | Promise<APIResponse<HolidayData[]>> | Get holiday information for specified market, including trading hours schedule. | iTick Market Holidays |
Access global stock market data including US stocks, Hong Kong stocks, etc.
import{StockClient}from"@itick/browser-sdk";constclient=newStockClient(token);// Get single stock informationawaitclient.getInfo({region: "US",code: "AAPL"});// Get real-time quoteawaitclient.getQuote({region: "US",code: "AAPL"});// Get order book depthawaitclient.getDepth({region: "US",code: "AAPL"});// Get latest tradeawaitclient.getTick({region: "US",code: "AAPL"});// Get candlestick dataawaitclient.getKline({region: "US",code: "AAPL",interval: "5m",limit: 100,});// Batch queriesawaitclient.getQuotes({region: "US",codes: ["AAPL","MSFT","GOOGL"]});awaitclient.getDepths({region: "US",codes: ["AAPL","MSFT"]});awaitclient.getTicks({region: "US",codes: ["AAPL","MSFT"]});awaitclient.getKlines({region: "US",codes: ["AAPL","MSFT"],interval: "1d",limit: 50,});// IPO informationawaitclient.getIPO({region: "US",code: "RIVN"});// Stock split informationawaitclient.getSplit({region: "US",code: "AAPL"});| Method Name | Parameters | Return Type | Description | Details |
|---|---|---|---|---|
getInfo | params: Object- region: string (Market code, e.g., US, HK, etc.)- code: string (Stock code, e.g., AAPL)- exchange?:string (Optional, Exchange code e.g., NYSE, NASDAQ) | Promise<APIResponse<StockInfo>> | Get basic stock information | iTick Stock Info |
getIPO | params: Object- region: string (Market code, e.g., US, HK, etc.)- code: string (Stock code, e.g., AAPL) | Promise<APIResponse<StockIPO>> | Get stock IPO information | iTick Stock IPO |
getSplit | params: Object- region: string (Market code, e.g., US, HK, etc.)- code: string (Stock code, e.g., AAPL) | Promise<APIResponse<StockSplit>> | Get stock ex-rights and dividend information | iTick Stock Split |
getTick | params: Object- region: string (Market code, e.g., US, HK, etc.)- code: string (Stock code, e.g., AAPL) | Promise<APIResponse<TickData>> | Get latest trade data for a single stock | iTick Stock Real-time Tick |
getQuote | params: Object- region: string (Market code, e.g., US, HK, etc.)- code: string (Stock code, e.g., AAPL) | Promise<APIResponse<QuoteData>> | Get latest quote for a single stock | iTick Stock Real-time Quote |
getDepth | params: Object- region: string (Market code, e.g., US, HK, etc.)- code: string (Stock code, e.g., AAPL) | Promise<APIResponse<DepthData>> | Get latest order book depth for a single stock | iTick Stock Real-time Depth |
getKline | options: GetKlineOptions- region: string (Market code)- code: string (Stock code)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineData[]>> | Get candlestick data for a single stock | iTick Stock K-line |
getTicks | params: Object- region: string (Market code)- codes: string[] | string (Stock code list) | Promise<APIResponse<TickDataMap>> | Get latest trade data for multiple stocks | iTick Stock Batch Ticks |
getQuotes | params: Object- region: string (Market code)- codes: string[] | string (Stock code list) | Promise<APIResponse<QuoteDataMap>> | Get latest quotes for multiple stocks | iTick Stock Batch Quotes |
getDepths | params: Object- region: string (Market code)- codes: string[] | string (Stock code list) | Promise<APIResponse<DepthDataMap>> | Get latest order book depth for multiple stocks | iTick Stock Batch Depths |
getKlines | options: GetKlinesOptions- region: string (Market code)- codes: string[] | string (Stock code list)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineDataMap>> | Get candlestick data for multiple stocks | iTick Stock Batch K-lines |
createSocket | options?: CreateSocketOptions (Optional, WebSocket connection options) | SocketClient | Create WebSocket connection for real-time data subscription | iTick WebSocket Stocks |
Access crypto market data from multiple exchanges.
import{CryptoClient}from"@itick/browser-sdk";constclient=newCryptoClient(token);// Get real-time dataawaitclient.getQuote({region: "BA",code: "BTCUSDT"});awaitclient.getDepth({region: "BA",code: "ETHUSDT"});awaitclient.getTick({region: "BA",code: "BTCUSDT"});// Get candlestick dataawaitclient.getKline({region: "BA",code: "BTCUSDT",interval: "1h",limit: 100,});// Batch queriesawaitclient.getQuotes({region: "BA",codes: ["BTCUSDT","ETHUSDT"]});| Method Name | Parameters | Return Type | Description | Details |
|---|---|---|---|---|
getTick | params: Object- region: string (Market code, e.g., BA, BT, PB, etc.)- code: string (Symbol code, e.g., BTCUSDT) | Promise<APIResponse<TickData>> | Get latest trade data for a single crypto | iTick Crypto Real-time Tick |
getQuote | params: Object- region: string (Market code, e.g., BA, BT, PB, etc.)- code: string (Symbol code, e.g., BTCUSDT) | Promise<APIResponse<QuoteData>> | Get latest quote for a single crypto | iTick Crypto Real-time Quote |
getDepth | params: Object- region: string (Market code, e.g., BA, BT, PB, etc.)- code: string (Symbol code, e.g., BTCUSDT) | Promise<APIResponse<DepthData>> | Get latest order book depth for a single crypto | iTick Crypto Real-time Depth |
getKline | options: GetKlineOptions- region: string (Market code)- code: string (Symbol code)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineData[]>> | Get candlestick data for a single crypto | iTick Crypto K-line |
getTicks | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<TickDataMap>> | Get latest trade data for multiple crypto | iTick Crypto Batch Ticks |
getQuotes | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<QuoteDataMap>> | Get latest quotes for multiple crypto | iTick Crypto Batch Quotes |
getDepths | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<DepthDataMap>> | Get latest order book depth for multiple crypto | iTick Crypto Batch Depths |
getKlines | options: GetKlinesOptions- region: string (Market code)- codes: string[] | string (Symbol code list)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineDataMap>> | Get candlestick data for multiple crypto | iTick Crypto Batch K-lines |
createSocket | options?: CreateSocketOptions (Optional, WebSocket connection options) | SocketClient | Create WebSocket connection for real-time data subscription | iTick WebSocket Crypto |
Access foreign exchange market data.
import{ForexClient}from"@itick/browser-sdk";constclient=newForexClient(token);awaitclient.getQuote({region: "GB",code: "EURUSD"});awaitclient.getDepth({region: "GB",code: "GBPUSD"});awaitclient.getTick({region: "GB",code: "USDJPY"});awaitclient.getKline({region: "GB",code: "EURUSD",interval: "1d",limit: 50,});| Method Name | Parameters | Return Type | Description | Details |
|---|---|---|---|---|
getTick | params: Object- region: string (Market code, e.g., GB, etc.)- code: string (Symbol code, e.g., EURUSD) | Promise<APIResponse<TickData>> | Get latest trade data for a single currency pair | iTick Forex Real-time Tick |
getQuote | params: Object- region: string (Market code, e.g., GB, etc.)- code: string (Symbol code, e.g., EURUSD) | Promise<APIResponse<QuoteData>> | Get latest quote for a single currency pair | iTick Forex Real-time Quote |
getDepth | params: Object- region: string (Market code, e.g., GB, etc.)- code: string (Symbol code, e.g., EURUSD) | Promise<APIResponse<DepthData>> | Get latest order book depth for a single currency pair | iTick Forex Real-time Depth |
getKline | options: GetKlineOptions- region: string (Market code)- code: string (Symbol code)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineData[]>> | Get candlestick data for a single currency pair | iTick Forex K-line |
getTicks | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<TickDataMap>> | Get latest trade data for multiple currency pairs | iTick Forex Batch Ticks |
getQuotes | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<QuoteDataMap>> | Get latest quotes for multiple currency pairs | iTick Forex Batch Quotes |
getDepths | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<DepthDataMap>> | Get latest order book depth for multiple currency pairs | iTick Forex Batch Depths |
getKlines | options: GetKlinesOptions- region: string (Market code)- codes: string[] | string (Symbol code list)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineDataMap>> | Get candlestick data for multiple currency pairs | iTick Forex Batch K-lines |
createSocket | options?: CreateSocketOptions (Optional, WebSocket connection options) | SocketClient | Create WebSocket connection for real-time data subscription | iTick WebSocket Forex |
Access global stock index data.
import{IndicesClient}from"@itick/browser-sdk";constclient=newIndicesClient(token);awaitclient.getQuote({region: "US",code: "SPX"});awaitclient.getDepth({region: "US",code: "NDX"});awaitclient.getKline({region: "US",code: "DJI",interval: "1w",limit: 20});| Method Name | Parameters | Return Type | Description | Details |
|---|---|---|---|---|
getTick | params: Object- region: string (Market code, e.g., US, GB, etc.)- code: string (Symbol code, e.g., DJI, SPX) | Promise<APIResponse<TickData>> | Get latest trade data for a single index | iTick Indices Real-time Tick |
getQuote | params: Object- region: string (Market code, e.g., US, GB, etc.)- code: string (Symbol code, e.g., DJI, SPX) | Promise<APIResponse<QuoteData>> | Get latest quote for a single index | iTick Indices Real-time Quote |
getDepth | params: Object- region: string (Market code, e.g., US, GB, etc.)- code: string (Symbol code, e.g., DJI, SPX) | Promise<APIResponse<DepthData>> | Get latest order book depth for a single index | iTick Indices Real-time Depth |
getKline | options: GetKlineOptions- region: string (Market code)- code: string (Symbol code)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineData[]>> | Get candlestick data for a single index | iTick Indices K-line |
getTicks | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<TickDataMap>> | Get latest trade data for multiple indices | iTick Indices Batch Ticks |
getQuotes | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<QuoteDataMap>> | Get latest quotes for multiple indices | iTick Indices Batch Quotes |
getDepths | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<DepthDataMap>> | Get latest order book depth for multiple indices | iTick Indices Batch Depths |
getKlines | options: GetKlinesOptions- region: string (Market code)- codes: string[] | string (Symbol code list)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineDataMap>> | Get candlestick data for multiple indices | iTick Indices Batch K-lines |
createSocket | options?: CreateSocketOptions (Optional, WebSocket connection options) | SocketClient | Create WebSocket connection for real-time data subscription | iTick WebSocket Indices |
Access futures market data.
import{FutureClient}from"@itick/browser-sdk";constclient=newFutureClient(token);awaitclient.getQuote({region: "US",code: "ES"});awaitclient.getDepth({region: "US",code: "NQ"});awaitclient.getKline({region: "US",code: "CL",interval: "5m",limit: 100});| Method Name | Parameters | Return Type | Description | Details |
|---|---|---|---|---|
getTick | params: Object- region: string (Market code, e.g., US, CN, HK, etc.)- code: string (Symbol code, e.g., CL, GC) | Promise<APIResponse<TickData>> | Get latest trade data for a single futures contract | iTick Futures Real-time Tick |
getQuote | params: Object- region: string (Market code, e.g., US, CN, HK, etc.)- code: string (Symbol code, e.g., CL, GC) | Promise<APIResponse<QuoteData>> | Get latest quote for a single futures contract | iTick Futures Real-time Quote |
getDepth | params: Object- region: string (Market code, e.g., US, CN, HK, etc.)- code: string (Symbol code, e.g., CL, GC) | Promise<APIResponse<DepthData>> | Get latest order book depth for a single futures contract | iTick Futures Real-time Depth |
getKline | options: GetKlineOptions- region: string (Market code)- code: string (Symbol code)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineData[]>> | Get candlestick data for a single futures contract | iTick Futures K-line |
getTicks | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<TickDataMap>> | Get latest trade data for multiple futures contracts | iTick Futures Batch Ticks |
getQuotes | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<QuoteDataMap>> | Get latest quotes for multiple futures contracts | iTick Futures Batch Quotes |
getDepths | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<DepthDataMap>> | Get latest order book depth for multiple futures contracts | iTick Futures Batch Depths |
getKlines | options: GetKlinesOptions- region: string (Market code)- codes: string[] | string (Symbol code list)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineDataMap>> | Get candlestick data for multiple futures contracts | iTick Futures Batch K-lines |
createSocket | options?: CreateSocketOptions (Optional, WebSocket connection options) | SocketClient | Create WebSocket connection for real-time data subscription | iTick WebSocket Futures |
Access mutual fund and ETF data.
import{FundClient}from"@itick/browser-sdk";constclient=newFundClient(token);awaitclient.getQuote({region: "US",code: "VOO"});awaitclient.getDepth({region: "US",code: "QQQ"});awaitclient.getKline({region: "US",code: "SPY",interval: "1d",limit: 100,});| Method Name | Parameters | Return Type | Description | Details |
|---|---|---|---|---|
getTick | params: Object- region: string (Market code, e.g., US, HK, etc.)- code: string (Symbol code, e.g., SPY, QQQ) | Promise<APIResponse<TickData>> | Get latest trade data for a single fund | iTick Fund Real-time Tick |
getQuote | params: Object- region: string (Market code, e.g., US, HK, etc.)- code: string (Symbol code, e.g., SPY, QQQ) | Promise<APIResponse<QuoteData>> | Get latest quote for a single fund | iTick Fund Real-time Quote |
getDepth | params: Object- region: string (Market code, e.g., US, HK, etc.)- code: string (Symbol code, e.g., SPY, QQQ) | Promise<APIResponse<DepthData>> | Get latest order book depth for a single fund | iTick Fund Real-time Depth |
getKline | options: GetKlineOptions- region: string (Market code)- code: string (Symbol code)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineData[]>> | Get candlestick data for a single fund | iTick Fund K-line |
getTicks | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<TickDataMap>> | Get latest trade data for multiple funds | iTick Fund Batch Ticks |
getQuotes | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<QuoteDataMap>> | Get latest quotes for multiple funds | iTick Fund Batch Quotes |
getDepths | params: Object- region: string (Market code)- codes: string[] | string (Symbol code list) | Promise<APIResponse<DepthDataMap>> | Get latest order book depth for multiple funds | iTick Fund Batch Depths |
getKlines | options: GetKlinesOptions- region: string (Market code)- codes: string[] | string (Symbol code list)- interval: KlineType (Candlestick period type)- limit: number (Number of data points returned, max 500)- et?: string | number (Optional, end timestamp) | Promise<APIResponse<KlineDataMap>> | Get candlestick data for multiple funds | iTick Fund Batch K-lines |
createSocket | options?: CreateSocketOptions (Optional, WebSocket connection options) | SocketClient | Create WebSocket connection for real-time data subscription | iTick WebSocket Funds |
quote: Real-time quotedepth: Order book depthtick: Latest tradekline@1morkline@1: 1-minute candlestickkline@5morkline@2: 5-minute candlestickkline@15morkline@3: 15-minute candlestickkline@30morkline@4: 30-minute candlestickkline@1horkline@5: 1-hour candlestickkline@2horkline@6: 2-hour candlestick (crypto only)kline@4horkline@7: 4-hour candlestick (crypto only)kline@1dorkline@8: Daily candlestickkline@1workline@9: Weekly candlestickkline@1Morkline@10: Monthly candlestick
constsocket=client.createSocket({maxReconnectTimes: 10,// Maximum reconnection attempts (0 = unlimited)reconnectInterval: 5000,// Reconnection interval (milliseconds)pingInterval: 30000,// Ping interval (milliseconds)subscribeData: {codes: ["AAPL$US","MSFT$US"],types: ["quote","tick","kline@1m"],},});// Connection openedsocket.onSocketOpen(()=>{console.log("Connected!");});// Receive messagessocket.onSocketMessage((data)=>{console.log("Received data:",data);});// Error occurredsocket.onSocketError((error)=>{console.error("Error:",error);});// Connection closedsocket.onSocketClose(()=>{console.log("Disconnected");});// Check connection statusconstisConnected=socket.checkSocketConnected();// Disconnectsocket.disconnectSocket();// Subscribe after connectionsocket.subscribeSocket({ac: "subscribe",types: ["quote","depth"],codes: ["TSLA$US","NVDA$US"],});// Unsubscribesocket.subscribeSocket({ac: "unsubscribe",types: ["tick"],codes: ["AAPL$US"],});try{constresponse=awaitclient.getQuote({region: "US",code: "AAPL"});if(response.code!==0){console.error("API Error:",response.msg);return;}// Process dataconsole.log(response.data);}catch(error){if(errorinstanceofError){console.error("Network Error:",error.message);}}Full TypeScript support with comprehensive type definitions:
importtype{APIResponse,QuoteData,SocketKlineData,SocketTickData,SocketDepthData,SocketQuoteData,}from"@itick/browser-sdk";// Type-safe responseconstresponse: APIResponse<QuoteData> = await client.getQuote({region: "US",code: "AAPL",});
// Type-safe WebSocket messages
socket.onSocketMessage((response) =>{const{code,data,msg,resAc} = response;
if (data?.type === "quote") {constquoteData: SocketQuoteData=data;}
if (data?.type === "kline@1") {constklineData: SocketKlineData=data;}
if (data?.type === "tick") {consttickData: SocketTickData=data;}
if (data?.type === "depth") {constdepthData: SocketDepthData=data;}});- Official API Documentation - Complete API reference
- REST API Guide - Detailed REST endpoints
- WebSocket Guide - Real-time data streaming
- GitHub Repository - Source code and issue tracking
MIT License - see the LICENSE file for details.
Contributions are welcome! Feel free to submit a Pull Request.
- Website: https://itick.org
- Email: support@itick.org
- Issues: GitHub Issues
Made with ❤️ by the iTick Team




