{"_id":"tickerlayer","_rev":"2-46409df06946808d6e52f616b1fdea0a","name":"tickerlayer","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.0-stage":{"name":"tickerlayer","version":"0.0.0-stage","_id":"tickerlayer@0.0.0-stage","stub":true,"maintainers":[{"name":"tickerlayer","email":"info@tickerlayer.com"}],"dist":{"shasum":"2aad6bfa6364a5201d0478d8dac093e508f4895b","tarball":"https://registry.npmjs.org/tickerlayer/-/tickerlayer-0.0.0-stage.tgz","fileCount":2,"integrity":"sha512-hy/tJTta9iInSXKcr/uZXNy9UXrhFc3/V0r5BoA7dqer707GByByICehPEirm2mNBCTmal+cA/jplwGvDmY+7w==","signatures":[{"sig":"MEUCICiRyP+SHwqE6OU51gr0lXAxcJ1Oc4nZNtPRyrMkbhlKAiEAnSDQa8/Vmuy2L0DwjFuVP1jj7PE5WB5gBi029m/We4M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":333},"_npmUser":{"name":"tickerlayer","email":"info@tickerlayer.com"},"description":"Temporary package placeholder for staged publishing","directories":{}},"0.1.0":{"_id":"tickerlayer@0.1.0","bugs":{"email":"info@tickerlayer.com"},"dist":{"shasum":"4f08edee8220131b4a4ec410de92e5cb81647838","tarball":"https://registry.npmjs.org/tickerlayer/-/tickerlayer-0.1.0.tgz","fileCount":15,"integrity":"sha512-QA9cFw6c0AbMdQX1qwM1s9orH9Ap4jUapkS7VWeRmhi0r99ZwSf799hgMIsGsqnBl2YkHjiOAjvNlwUYnQRJfg==","signatures":[{"sig":"MEQCIE55RRjI5RvrcigU5wrtzVaTiDt7KmpwxNxE3a9xxB1vAiA2LT3EWHaQvIBIz/0BvnzckP1QwJGUPmY46ins1UXHJw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCS83Vi4DncM/R5g6PGoWJsOyhUkpX2QR0dd5D322qSOAIhAJLyeqCOtrKx6eXEiwL29cS7OLNIUu7VU/SWSS1AchHU"}],"unpackedSize":36681},"main":"./dist/index.js","name":"tickerlayer","type":"module","types":"./dist/index.d.ts","author":{"url":"https://tickerlayer.com","name":"TickerLayer","email":"info@tickerlayer.com"},"engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./package.json":"./package.json"},"gitHead":"e98a41ae51951abbe0b28229db451a1a50e1f261","license":"MIT","scripts":{"test":"node --test test/*.test.mjs","build":"rm -rf dist && ../../node_modules/.bin/tsc -p tsconfig.json","prepublishOnly":"npm run build && npm test"},"version":"0.1.0","_npmUser":{"name":"tickerlayer","email":"info@tickerlayer.com"},"homepage":"https://tickerlayer.com/docs","keywords":["tickerlayer","market-data","stock-api","stocks","forex","crypto","etf","commodities","indices","perpetual-futures","bond-yields","real-time","websocket","financial-data","api-client"],"_npmVersion":"10.8.2","description":"JavaScript and TypeScript client for the TickerLayer market data API: REST and WebSocket for stocks, forex, crypto, indices, ETFs, commodities, perpetual futures and bond yields.","directories":{},"maintainers":[{"name":"tickerlayer","email":"info@tickerlayer.com"}],"sideEffects":false,"_nodeVersion":"20.20.2","_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tickerlayer_0.1.0_1792501925500_0.6878508550597404"}}},"time":{"created":"2026-10-20T13:11:07.885Z","modified":"2026-10-20T13:12:05.834Z","0.0.0-stage":"2026-10-20T13:11:07.885Z","0.1.0":"2026-10-20T13:12:05.598Z"},"description":"JavaScript and TypeScript client for the TickerLayer market data API: REST and WebSocket for stocks, forex, crypto, indices, ETFs, commodities, perpetual futures and bond yields.","maintainers":[{"name":"tickerlayer","email":"info@tickerlayer.com"}],"readme":"# TickerLayer JavaScript client\n\nThe JavaScript and TypeScript client for the [TickerLayer](https://tickerlayer.com) market data API. One API key covers stocks, forex, crypto, indices, ETFs, commodities, perpetual futures and government bond yields, over REST and a WebSocket stream, with one symbol format and one response shape.\n\n- No dependencies. Works on Node.js 18 and newer, Deno, Bun and in browsers.\n- Typed responses, errors with the HTTP status and the API's error code.\n- Retries the per-second rate limit, a 503 and network errors with backoff; never retries the monthly quota.\n- The stream reconnects and resubscribes on its own.\n\nGet a free API key at [tickerlayer.com/signup](https://tickerlayer.com/signup).\n\n## Install\n\n```bash\nnpm install tickerlayer\n```\n\n## REST\n\n```js\nimport { TickerLayer } from 'tickerlayer';\n\nconst tl = new TickerLayer({ apiKey: process.env.TICKERLAYER_API_KEY });\n\nconst quote = await tl.quote('stocks', 'US:KO');\n// { symbol: 'US:KO', bid: 93.87, ask: 93.99, bid_size: 100, ask_size: 200, timestamp: 1792500685080 }\n\nconst btc = await tl.snapshot('crypto', 'BTCUSD');\nconsole.log(btc.last_price, btc.change_percent);\n\nconst bars = await tl.bars('stocks', 'US:KO', { multiplier: 1, timespan: 'day', from: '2026-10-13', to: '2026-10-17', sort: 'asc' });\nfor (const bar of bars.results) console.log(new Date(bar.t).toISOString().slice(0, 10), bar.c);\n```\n\nSymbols: stocks as `COUNTRY:TICKER` (`US:KO`, `DE:BMW`), crypto and forex as pairs (`BTCUSD`, `EURUSD`), commodities like `XAUUSD`, ETFs like `US500ETF`, indices like `US500`, perpetual contracts like `XAUUSDT`, bonds as `COUNTRY:TENOR` (`US:10Y`). Timestamps are Unix milliseconds.\n\n| Method | Route |\n| --- | --- |\n| `quote(asset, symbol, params?)` | `GET /{asset}/quote/{symbol}` |\n| `lastTrade(asset, symbol, params?)` | `GET /{asset}/trade/last/{symbol}` |\n| `snapshot(asset, symbol)` | `GET /{asset}/snapshot/{symbol}` |\n| `previousBar(asset, symbol, { interval? })` | `GET /{asset}/agg/{symbol}/prev` |\n| `bars(asset, symbol, { multiplier, timespan, from, to, limit?, offset?, sort? })` | `GET /{asset}/agg/{symbol}/{multiplier}/{timespan}/{from}/{to}` |\n| `symbols(asset?, params?)` | `GET /{asset}/symbols`, or `GET /symbols` |\n| `symbolCoverage(symbols)` | `POST /symbols/coverage` |\n| `perpetualMark(symbol, params?)` | `GET /perpetuals/mark/{symbol}` |\n| `bondYield(symbol)`, `bondSnapshot(symbol)` | `GET /bond/last/{symbol}`, `GET /bond/snapshot/{symbol}` |\n| `marketStatus(params)`, `marketStatusBulk(items)` | `GET /markets/status`, `GET /markets/status/bulk` |\n| `marketSessions(params)`, `marketHolidays(params)` | `GET /markets/sessions`, `GET /markets/holidays` |\n| `fundamentals(symbol)`, `fundamentalsList(params?)`, `economicEvents(params?)` | `GET /fundamentals/...` |\n| `overnightSymbols()`, `overnightQuote(symbol)`, `overnightSnapshot(params?)` | `GET /overnight/...` |\n| `get(path, params?)` | any other GET route |\n\n`asset` is one of `crypto`, `forex`, `stocks`, `indices`, `etfs`, `commodities`, `perpetuals`. Route options go in `params`, for example `tl.quote('etfs', 'US500ETF', { spread: 'full' })`. Every route and parameter is in the [REST reference](https://tickerlayer.com/docs/rest) and the [OpenAPI 3.1 spec](https://tickerlayer.com/openapi.json).\n\n### Errors\n\nA failed request throws a `TickerLayerError` with `status` (0 when there was no answer), `code` (for example `REST_RATE_LIMIT_EXCEEDED`, `REST_QUOTA_EXCEEDED`), `body` and `retryAfterMs`.\n\n```js\nimport { TickerLayerError } from 'tickerlayer';\n\ntry {\n  await tl.quote('stocks', 'US:KO');\n} catch (err) {\n  if (err instanceof TickerLayerError && err.status === 404) console.log('not in the catalog');\n  else throw err;\n}\n```\n\nOptions: `new TickerLayer({ apiKey, timeoutMs: 15000, maxRetries: 2, baseUrl, fetch })`.\n\n## WebSocket stream\n\n```js\nconst stream = tl.stream();\n\nstream.subscribe({ channels: ['stocks.quotes', 'stocks.trades'], symbols: ['US:KO', 'US:JPM'] });\nstream.subscribe({ channels: ['crypto.quotes'], symbols: ['BTCUSD', 'ETHUSD'] });\n\nstream.on('message', (frame) => {\n  if (frame.type === 'quote') console.log(frame.symbol, Number(frame.bid), Number(frame.ask), frame.ts);\n  if (frame.type === 'error') console.error(frame.code, frame.message);\n});\n\n// later\nstream.close();\n```\n\n- Subscribe once: the client sends it as soon as the server is ready and again after every reconnect. More than 500 symbols are split into several messages.\n- Frames are passed through as the server sends them. Quote and trade prices are strings on some channels (`\"bid\": \"93.87\"`) and numbers on others, so read them with `Number()`. The [stream reference](https://tickerlayer.com/docs/websocket) lists every channel and frame.\n- Subscribe options go next to `channels` and `symbols`: `snapshot`, `view`, `spread`, `interval` and `session` on the bar channels, and the rest of the documented options.\n- Events: `ready`, `message`, `close`, `reconnecting` and `error`. `on()` returns a function that removes the listener.\n- Reconnects wait longer after each failed attempt, up to 30 seconds (`tl.stream({ maxReconnectDelayMs })`), and start over once a connection has stayed up for a minute. After a server release the client is back within a second. `tl.stream({ reconnect: false })` turns this off.\n\nOn Node.js 18 and 20, which have no built-in WebSocket, install `ws` and pass it:\n\n```js\nimport WebSocket from 'ws';\nconst tl = new TickerLayer({ apiKey: process.env.TICKERLAYER_API_KEY, WebSocket });\n```\n\n## Keep your key on the server\n\nRequests send the key in the `x-api-key` header and the stream sends it in its URL. In a browser app, call TickerLayer from your backend so the key never reaches the page.\n\n## Links\n\n- [Documentation](https://tickerlayer.com/docs)\n- [Pricing](https://tickerlayer.com/pricing)\n- [MCP server for AI agents](https://tickerlayer.com/mcp)\n\n## License\n\nMIT\n","readmeFilename":"README.md","homepage":"https://tickerlayer.com/docs","keywords":["tickerlayer","market-data","stock-api","stocks","forex","crypto","etf","commodities","indices","perpetual-futures","bond-yields","real-time","websocket","financial-data","api-client"],"author":{"url":"https://tickerlayer.com","name":"TickerLayer","email":"info@tickerlayer.com"},"bugs":{"email":"info@tickerlayer.com"},"license":"MIT"}