TickerLayer Python client
The Python client for the TickerLayer 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.
- Sync and async clients with the same methods, typed responses.
- Errors carry the HTTP status and the API's error code.
- Retries the per-second rate limit, a 503 and network errors with backoff; never retries the monthly quota.
- The stream reconnects and resubscribes on its own.
Get a free API key at tickerlayer.com/signup.
Install
pip install tickerlayer
Python 3.9 or newer.
REST
from tickerlayer import TickerLayer
tl = TickerLayer() # reads TICKERLAYER_API_KEY, or pass TickerLayer("your key")
quote = tl.quote("stocks", "US:KO")
# {'symbol': 'US:KO', 'bid': 93.87, 'ask': 93.99, 'bid_size': 100, 'ask_size': 200, 'timestamp': 1792500685080}
btc = tl.snapshot("crypto", "BTCUSD")
print(btc["last_price"], btc["change_percent"])
bars = tl.bars("stocks", "US:KO", start="2026-10-13", end="2026-10-17", sort="asc")
for bar in bars["results"]:
print(bar["t"], bar["c"])
Symbols: 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.
| Method | Route |
|---|---|
quote(asset, symbol, **params) |
GET /{asset}/quote/{symbol} |
last_trade(asset, symbol, **params) |
GET /{asset}/trade/last/{symbol} |
snapshot(asset, symbol) |
GET /{asset}/snapshot/{symbol} |
previous_bar(asset, symbol, interval=None) |
GET /{asset}/agg/{symbol}/prev |
bars(asset, symbol, start=, end=, multiplier=1, timespan="day", limit=, offset=, sort=) |
GET /{asset}/agg/{symbol}/{multiplier}/{timespan}/{from}/{to} |
symbols(asset=None, **params) |
GET /{asset}/symbols, or GET /symbols |
symbol_coverage(symbols) |
POST /symbols/coverage |
perpetual_mark(symbol, **params) |
GET /perpetuals/mark/{symbol} |
bond_yield(symbol), bond_snapshot(symbol) |
GET /bond/last/{symbol}, GET /bond/snapshot/{symbol} |
market_status(**params), market_status_bulk(items) |
GET /markets/status, GET /markets/status/bulk |
market_sessions(**params), market_holidays(**params) |
GET /markets/sessions, GET /markets/holidays |
fundamentals(symbol), fundamentals_list(**params), economic_events(**params) |
GET /fundamentals/... |
overnight_symbols(), overnight_quote(symbol), overnight_snapshot(symbols=) |
GET /overnight/... |
get(path, params) |
any other GET route |
asset is one of crypto, forex, stocks, indices, etfs, commodities, perpetuals. Route options are keyword arguments, for example tl.quote("etfs", "US500ETF", spread="full"). Every route and parameter is in the REST reference and the OpenAPI 3.1 spec.
Async
import asyncio
from tickerlayer import AsyncTickerLayer
async def main():
async with AsyncTickerLayer() as tl:
quote, btc = await asyncio.gather(tl.quote("stocks", "US:KO"), tl.snapshot("crypto", "BTCUSD"))
print(quote["bid"], btc["last_price"])
asyncio.run(main())
Errors
A failed request raises TickerLayerError with status (0 when there was no answer), code (for example REST_RATE_LIMIT_EXCEEDED, REST_QUOTA_EXCEEDED), body and retry_after in seconds.
from tickerlayer import TickerLayerError
try:
tl.quote("stocks", "US:KO")
except TickerLayerError as err:
if err.status == 404:
print("not in the catalog")
else:
raise
Options: TickerLayer(api_key, timeout=15.0, max_retries=2, base_url=..., http_client=...).
WebSocket stream
import asyncio
from tickerlayer import AsyncTickerLayer
async def main():
tl = AsyncTickerLayer()
async with tl.stream() as stream:
await stream.subscribe(["stocks.quotes", "stocks.trades"], ["US:KO", "US:JPM"])
await stream.subscribe("crypto.quotes", ["BTCUSD", "ETHUSD"])
async for frame in stream:
if frame["type"] == "quote":
print(frame["symbol"], float(frame["bid"]), float(frame["ask"]), frame["ts"])
asyncio.run(main())
- 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.
- Frames are dicts as the server sends them. Quote and trade prices are strings on some channels (
"bid": "93.87") and numbers on others, so read them withfloat(). The stream reference lists every channel and frame. - Subscribe options are keyword arguments:
snapshot,view,spread,intervalandsessionon the bar channels, and the rest of the documented options. - Reconnects wait longer after each failed attempt, up to 30 seconds (
tl.stream(max_reconnect_delay=...)), and start over once a connection has stayed up for a minute. After a server release the client is back within a second. A refused key ends the stream with aTickerLayerError.tl.stream(reconnect=False)turns reconnects off. stream()is available onTickerLayertoo; the stream itself always runs in asyncio.
Links
License
MIT
Metadata
Release files for tickerlayer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tickerlayer-0.1.0.tar.gz | 13.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tickerlayer-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.6 kB
Release files / tickerlayer-0.1.0.tar.gz
| Download URL | tickerlayer-0.1.0.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2c940b7fda0427531921a5d61abf56d22d1a7eacb38dfb35e83d9cb25ce2dd7e
|
|
BLAKE2b-256 checksum How to use checksums |
281671ae128dd936cbddd25efb7f5b6630d06c5ac88fedca2159b6e4fe6f66e4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Release files / tickerlayer-0.1.0-py3-none-any.whl
| Download URL | tickerlayer-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3134dc885d7b0ee763496aa2e5de3d491c44d8e0a683de5ae7770f99dfc42cc9
|
|
BLAKE2b-256 checksum How to use checksums |
2555ad2fa7eb35a3b7f28f0adb0cce0b9246223eb69407576713629b34d44ba2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.14
|
Security for tickerlayer 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.