Skip to main content

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 datastreams
  • client.subscriptions - Manage data stream subscriptions
  • client.exports - Create and download historical data exports
  • client.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ticksupply-0.1.0.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ticksupply-0.1.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

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

Hashes for ticksupply-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4aa46f11f960e23ad4b9badcedb4daa8427fc66b5ed7144b84e294baf2a424ad
MD5 f6750f049216a0356a3fdc134802fa2a
BLAKE2b-256 b3b1afa5b57539e20e9c9fd14a345bb4bbd164dc0c9374bb1c027e0ede1fe084

See more details on using hashes here.

Provenance

The following attestation bundles were made for ticksupply-0.1.0.tar.gz:

Publisher: publish.yml on Ticksupply/ticksupply-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for ticksupply-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 392bfd51721c6fbec37d1c77ad1357f678de338f5560f5b38728c15917b996a0
MD5 8f44f23b3d877b892ec3a495a38e3742
BLAKE2b-256 4cfefb8050f7deeb08c6843e6197f7e4b7a7c40f84506083d63dd60f409d2932

See more details on using hashes here.

Provenance

The following attestation bundles were made for ticksupply-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Ticksupply/ticksupply-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page