Skip to main content

Python client for Telonex prediction market data API

Project description

telonex

Python SDK for Telonex - prediction market data provider.

PyPI version Python 3.9+ License: MIT

Installation

pip install telonex

For DataFrame support:

pip install telonex[dataframe]  # pandas support
pip install telonex[polars]     # polars support
pip install telonex[all]        # both

Quick Start

Download Data to Disk

from telonex import download

# Download using asset_id
download(
    api_key="your-api-key",
    exchange="polymarket",
    channel="quotes",
    asset_id="21742633143463906290569050155826241533067272736897614950488156847949938836455",
    from_date="2025-01-01",
    to_date="2025-01-07",
    download_dir="./data",
)

# Download using slug + outcome
download(
    api_key="your-api-key",
    exchange="polymarket",
    channel="book_snapshot_5",
    slug="will-trump-win-2024",
    outcome="Yes",
    from_date="2025-01-01",
    to_date="2025-01-07",
)

Load Directly into DataFrame

from telonex import get_dataframe

# Load into pandas DataFrame
df = get_dataframe(
    api_key="your-api-key",
    exchange="polymarket",
    channel="quotes",
    slug="will-trump-win-2024",
    outcome="Yes",
    from_date="2025-01-01",
    to_date="2025-01-07",
)

# Load into polars DataFrame
df = get_dataframe(
    api_key="your-api-key",
    exchange="polymarket",
    channel="quotes",
    asset_id="21742633...",
    from_date="2025-01-01",
    to_date="2025-01-07",
    engine="polars",
)

Async Support

import asyncio
from telonex import download_async

async def main():
    await download_async(
        api_key="your-api-key",
        exchange="polymarket",
        channel="book_snapshot_5",
        asset_id="21742633...",
        from_date="2025-01-01",
        to_date="2025-01-07",
    )

asyncio.run(main())

Check Data Availability

from telonex import get_availability

# Check what date ranges are available (no API key required)
availability = get_availability(
    exchange="polymarket",
    asset_id="21742633143463906290569050155826241533067272736897614950488156847949938836455",
)

# Returns a dict with channel availability
for channel, dates in availability["channels"].items():
    print(f"{channel}: {dates['from_date']} to {dates['to_date']}")

Identifier Options

You can identify the data you want using one of these combinations:

Option Parameters Example
Asset ID asset_id asset_id="21742633..."
Market ID + Outcome market_id, outcome market_id="0xabc...", outcome="Yes"
Market ID + Outcome ID market_id, outcome_id market_id="0xabc...", outcome_id=0
Slug + Outcome slug, outcome slug="will-trump-win", outcome="Yes"
Slug + Outcome ID slug, outcome_id slug="will-trump-win", outcome_id=0

Available Channels

Channel Description
quotes Trade quotes/prices
book_snapshot_5 Order book snapshots (top 5 levels)
book_snapshot_25 Order book snapshots (top 25 levels)
book_snapshot_full Full order book snapshots
transactions On-chain transactions

Parameters

download() / download_async()

Returns: List[str] - List of downloaded file paths

Parameter Type Default Description
api_key str required Telonex API key
exchange str required Exchange name (e.g., "polymarket")
channel str required Data channel
from_date str required Start date (inclusive), YYYY-MM-DD
to_date str required End date (exclusive), YYYY-MM-DD
download_dir str "./datasets" Directory to save files
concurrency int 5 Max concurrent downloads
verbose bool False Enable verbose logging

get_dataframe()

Returns: pandas.DataFrame or polars.DataFrame

Same parameters as above, plus:

Parameter Type Default Description
engine str "pandas" DataFrame engine ("pandas" or "polars")
cache_dir str None Cache directory (temp dir if None)

get_availability() / get_availability_async()

Returns: dict - Availability info with channel date ranges

Parameter Type Default Description
exchange str required Exchange name (e.g., "polymarket")
asset_id str None Asset/token ID
market_id str None Market ID (requires outcome)
slug str None Market slug (requires outcome)
outcome str None Outcome label (e.g., "Yes")
outcome_id int None Outcome index (0 or 1)

Note: No API key required for availability endpoints.

Error Handling

from telonex import (
    download,
    get_availability,
    AuthenticationError,
    NotFoundError,
    RateLimitError,
    EntitlementError,
)

# Download errors
try:
    download(...)
except AuthenticationError:
    print("Invalid API key")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except EntitlementError as e:
    print(f"Access denied. Downloads remaining: {e.downloads_remaining}")

Caching

Downloaded files are cached locally. If a file already exists, it won't be re-downloaded. To force re-download, delete the cached file or use a different download_dir.

License

MIT License - see LICENSE for details.

Links

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

telonex-0.1.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

telonex-0.1.2-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file telonex-0.1.2.tar.gz.

File metadata

  • Download URL: telonex-0.1.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for telonex-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ae621591daf165bfd5b9ad33f6bd4d265b8b41c424952a40517a4fdbaa65c7d7
MD5 d1945381b97cf63c64f8e6d7b9fffbd5
BLAKE2b-256 aa00e237d40340b27d25f4f59d02417e6bfe86651f6ab61f9afba811a2133433

See more details on using hashes here.

File details

Details for the file telonex-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: telonex-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for telonex-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 48fb73590a54e43da7137747f4a200f6928d48a6c48333e62ee00d3c48893e7e
MD5 96c5bfd597f8ae6e4b022beeff0c207b
BLAKE2b-256 1b54728eaa078a1d0e23790d7af661e19082cccd395138da34325da3afe4e405

See more details on using hashes here.

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