Skip to main content

Python SDK for the Talarion prediction market maker API

Project description

Talarion SDK

Trade against language models on custom prediction markets. This is the official Python client for the Talarion API — async, typed, and ready to roll.

Installation

pip install talarion

Everything's included — async API client, EOA transaction builders, the works. Requires Python 3.10+.

Quick Start

import asyncio
from datetime import datetime, timezone, timedelta
from talarion import TalarionClient

async def main():
    async with TalarionClient(api_key="tlrn_...") as client:
        # Spin up a brand new prediction market
        instrument = await client.generate_instrument(
            query="Will BTC hit 100k?",
            resolution_time=datetime.now(timezone.utc) + timedelta(days=7),
        )

        # Get a price quote
        quote = await client.get_quote(
            instrument.instrument_id,
            buy_yes=True,
            amount=10.0,
            user_id="user-123",
        )
        print(f"Price: {quote.price}, Amount: {quote.amount}")

asyncio.run(main())

That's it. You just created a market and got a quote. Our proprietary mm is on the other side.

EOA Direct Interaction

For EOA wallets that skip the Safe/relay flow and talk to the Escrow contract directly. All defaults point at Polygon mainnet — zero config needed:

import asyncio
from talarion import TalarionClient
from talarion.eoa import build_approve_usdc_tx, build_create_trade_tx, sign_and_send

RPC = "https://polygon-rpc.com"
PK = "0xYourPrivateKey"
EOA = "0xYourWalletAddress"

# One-time USDC approval (defaults to Polygon USDC + Talarion Escrow)
approve_tx = build_approve_usdc_tx()
sign_and_send(approve_tx, PK, RPC)

async def main():
    async with TalarionClient(api_key="tlrn_...") as client:
        # Submit an order — for EOAs, operation_sequence comes back as None
        result = await client.submit_order(
            instrument_id="instr_abc123",
            user_id="user-123",
            caller_address=EOA,
            amount=10.0,
            price=0.65,
            buy_yes=True,
        )

        # Build the on-chain tx from the submit result and fire it off
        trade_tx = build_create_trade_tx(result)
        tx_hash = sign_and_send(trade_tx, PK, RPC)
        print(f"Trade created: {tx_hash}")

asyncio.run(main())

Docs

Full reference with examples, type definitions, and the EOA module API lives at docs.talarion.tech/sdk.

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

talarion-0.1.5.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

talarion-0.1.5-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file talarion-0.1.5.tar.gz.

File metadata

  • Download URL: talarion-0.1.5.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for talarion-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ffd030ee5db44096c048f157f709d5321fd6fdf4fd2b42ac216e2f0078634439
MD5 6c4783f9f7af25c439abaaa7fc8f469b
BLAKE2b-256 54d3ccaba7b933feb4a941152562a82db851ae1ecb917f75b809e0a365a80b9d

See more details on using hashes here.

File details

Details for the file talarion-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: talarion-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for talarion-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cb5038db5188a2df47386739672a53682077d766ddc77498be14edc2301ca8f5
MD5 afb403879abcd6883d4ba3b3115d1f93
BLAKE2b-256 8276595e484192558928ee964b49b4c289d11227f7ab6bca0e22a7f607afadfd

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