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

Want to go off the rails and interact with the Escrow contract directly from an EOA? We got you:

pip install talarion[eoa]

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.4.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.4-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: talarion-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 f91d03b358eec69d728f5db2c4e47103a6056ac3201cf1d01dafc7c302c7a050
MD5 86ef5621acece7ecb2484c0ff2482234
BLAKE2b-256 7a01bc410ace1dc6d02568bc1529e20a17275b45a4366f4b269038cad8cd43ee

See more details on using hashes here.

File details

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

File metadata

  • Download URL: talarion-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 11.3 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1bef2d13be0946ca80e74c73e29fe21b76a27d10a6abce29f3946608c3c9f01d
MD5 95612da86abe9a99f0f4cf491d270fd4
BLAKE2b-256 8b921d394c0dd443d8bd05d3ac54c0fc8b82da961d6e4ec1406733cc413ad481

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