Official Python client for Ticksupply market data API
Project description
Ticksupply Python Client
Official Python client library for the Ticksupply market data API.
Installation
pip install ticksupply
Quick Start
Synchronous Usage
from ticksupply import Client
# API key from TICKSUPPLY_API_KEY environment variable
client = Client()
# Or with explicit API key
client = Client(api_key="key_xxx.secret")
# List available exchanges
for exchange in client.exchanges.list():
print(f"{exchange.code}: {exchange.display_name}")
# Search for instruments
result = client.exchanges.list_instruments("binance", search="BTC", limit=10)
for inst in result.items:
print(f"{inst.symbol}: {inst.base}/{inst.quote}")
# Create subscription
sub = client.subscriptions.create(datastream_id=12345)
# Get, pause, resume, delete
sub = client.subscriptions.get("sub_xxx")
client.subscriptions.pause("sub_xxx")
client.subscriptions.resume("sub_xxx")
client.subscriptions.delete("sub_xxx")
# Get activity spans
spans = client.subscriptions.list_spans("sub_xxx")
for span in spans:
print(f"{span.started_at} - {span.ended_at or 'ongoing'}")
Asynchronous Usage
import asyncio
from ticksupply import AsyncClient
async def main():
async with AsyncClient() as client:
# List exchanges
exchanges = await client.exchanges.list()
for exchange in exchanges:
print(f"{exchange.code}: {exchange.display_name}")
# Iterate over all subscriptions
async for sub in client.subscriptions.list_all():
print(f"{sub.id}: {sub.status}")
asyncio.run(main())
Configuration
The client can be configured via constructor arguments or environment variables:
| Parameter | Environment Variable | Default |
|---|---|---|
api_key |
TICKSUPPLY_API_KEY |
(required) |
base_url |
- | https://api.ticksupply.com/v1 |
timeout |
- | 30.0 seconds |
max_retries |
- | 3 |
Error Handling
from ticksupply import Client
from ticksupply.exceptions import (
NotFoundError,
RateLimitError,
AuthenticationError,
)
client = Client()
try:
sub = client.subscriptions.get("invalid-uuid")
except NotFoundError as e:
print(f"Subscription not found: {e.message}")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except AuthenticationError as e:
print(f"Invalid API key: {e.message}")
API Reference
Client Resources
client.exchanges- List exchanges, instruments, stream types, and datastreamsclient.subscriptions- Manage data stream subscriptionsclient.exports- Create and download historical data exportsclient.availability- Check data availability
Exchanges
# List all exchanges
exchanges = client.exchanges.list()
# Get instruments for an exchange
instruments = client.exchanges.list_instruments("binance", search="BTC", limit=10)
Subscriptions
# List subscriptions
page = client.subscriptions.list(limit=10)
# Auto-paginate through all
for sub in client.subscriptions.list_all():
print(sub.id)
# Create subscription
sub = client.subscriptions.create(datastream_id=12345)
# Get, pause, resume, delete
sub = client.subscriptions.get("sub_xxx")
client.subscriptions.pause("sub_xxx")
client.subscriptions.resume("sub_xxx")
client.subscriptions.delete("sub_xxx")
# Get activity spans
spans = client.subscriptions.list_spans("sub_xxx")
for span in spans:
print(f"{span.started_at} - {span.ended_at or 'ongoing'}")
Exports
from datetime import datetime, timezone
# Create export
job = client.exports.create(
datastream_id=12345,
start_time=datetime(2025, 1, 1, tzinfo=timezone.utc),
end_time=datetime(2025, 1, 2, tzinfo=timezone.utc),
)
# List exports
page = client.exports.list()
# Get export status
job = client.exports.get("exp_xxx")
# Get download URLs (when status is "succeeded")
download = client.exports.get_download("exp_xxx")
print(f"Files: {download.count}, Total: {download.total_bytes} bytes")
for artifact in download.artifacts:
print(f" {artifact.filename}: {artifact.url}")
Availability
# Check data availability for a datastream
avail = client.availability.get(datastream_id=12345)
print(f"Datastream: {avail.datastream.exchange}/{avail.datastream.instrument}")
for range_ in avail.ranges:
print(f"{range_.from_ns} - {range_.to_ns}: ~{range_.rows_estimate} rows")
Development
# Create virtual environment (one time)
python3 -m venv .venv
# Install dev dependencies
.venv/bin/pip install -e ".[dev]"
# Run tests
.venv/bin/pytest
# Linting
.venv/bin/ruff check
.venv/bin/ruff format src/ tests/
# Type checking
.venv/bin/mypy src/
# All checks
.venv/bin/ruff check && .venv/bin/mypy src/ && .venv/bin/pytest
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ticksupply-0.1.0.tar.gz.
File metadata
- Download URL: ticksupply-0.1.0.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4aa46f11f960e23ad4b9badcedb4daa8427fc66b5ed7144b84e294baf2a424ad
|
|
| MD5 |
f6750f049216a0356a3fdc134802fa2a
|
|
| BLAKE2b-256 |
b3b1afa5b57539e20e9c9fd14a345bb4bbd164dc0c9374bb1c027e0ede1fe084
|
Provenance
The following attestation bundles were made for ticksupply-0.1.0.tar.gz:
Publisher:
publish.yml on Ticksupply/ticksupply-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ticksupply-0.1.0.tar.gz -
Subject digest:
4aa46f11f960e23ad4b9badcedb4daa8427fc66b5ed7144b84e294baf2a424ad - Sigstore transparency entry: 953520728
- Sigstore integration time:
-
Permalink:
Ticksupply/ticksupply-python@992ec6b77f8da45a80e5432a00181d9280a63fb1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Ticksupply
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@992ec6b77f8da45a80e5432a00181d9280a63fb1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ticksupply-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ticksupply-0.1.0-py3-none-any.whl
- Upload date:
- Size: 24.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
392bfd51721c6fbec37d1c77ad1357f678de338f5560f5b38728c15917b996a0
|
|
| MD5 |
8f44f23b3d877b892ec3a495a38e3742
|
|
| BLAKE2b-256 |
4cfefb8050f7deeb08c6843e6197f7e4b7a7c40f84506083d63dd60f409d2932
|
Provenance
The following attestation bundles were made for ticksupply-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Ticksupply/ticksupply-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ticksupply-0.1.0-py3-none-any.whl -
Subject digest:
392bfd51721c6fbec37d1c77ad1357f678de338f5560f5b38728c15917b996a0 - Sigstore transparency entry: 953520730
- Sigstore integration time:
-
Permalink:
Ticksupply/ticksupply-python@992ec6b77f8da45a80e5432a00181d9280a63fb1 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/Ticksupply
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@992ec6b77f8da45a80e5432a00181d9280a63fb1 -
Trigger Event:
push
-
Statement type: