Skip to main content

Unified SDK for prediction market data aggregation across Polymarket, Kalshi, Manifold, Metaculus, and PredictIt

Project description

PolyPoll SDK

Unified SDK for prediction market data aggregation across multiple platforms.

Supported Platforms

  • Polymarket - Crypto prediction markets on Polygon
  • Kalshi - US regulated prediction markets
  • Manifold Markets - Play-money forecasting
  • Metaculus - Expert forecasting
  • PredictIt - US political markets

Installation

pip install polypoll-sdk

# With REST API server support
pip install polypoll-sdk[server]

# With all optional dependencies
pip install polypoll-sdk[all]

Quick Start

import asyncio
from polypoll_sdk import PolyPollSDK

async def main():
    # Initialize SDK (no API keys needed for core features)
    sdk = PolyPollSDK()

    # Get markets from all platforms
    markets = await sdk.get_all_markets()
    print(f"Found {len(markets)} markets")

    # Get markets from specific platform
    polymarket = await sdk.get_markets(platform="polymarket")

    # Search for markets
    trump_markets = await sdk.search_markets("trump")

    # Group markets by event across platforms
    groups = await sdk.get_grouped_markets(min_similarity=80.0)
    print(f"Found {len(groups)} unique events across platforms")

    # Detect arbitrage opportunities
    arbitrage = await sdk.get_arbitrage_opportunities()
    for opp in arbitrage[:5]:
        print(f"Arbitrage: {opp.profit_pct:.1f}% profit")
        print(f"  {opp.strategy}")

asyncio.run(main())

Features

Layer 1: Data Aggregation

# Get all markets from all platforms
markets = await sdk.get_all_markets()

# Get markets from specific platform
kalshi = await sdk.get_markets(platform="kalshi")

# Search markets by keyword (uses fuzzy matching)
crypto = await sdk.search_markets("bitcoin", platforms=["polymarket", "kalshi"])

Layer 2: Cross-Platform Matching

# Find markets on other platforms similar to a given market
similar = await sdk.get_similar_markets(
    market_id="abc123",
    platform="polymarket",
    min_similarity=70
)

for match in similar:
    print(f"{match.market.platform}: {match.similarity_score:.0f}%")

Layer 3: Market Grouping (Group ID System)

Automatically group markets representing the same event across different platforms:

# Get all markets grouped by event (80% similarity threshold)
groups = await sdk.get_grouped_markets(min_similarity=80.0)

for group_id, markets in groups.items():
    platforms = set(m.platform for m in markets)
    if len(platforms) > 1:  # Cross-platform group
        print(f"\nGroup: {group_id}")
        for m in markets:
            print(f"  [{m.platform}] {m.title} ({m.yes_price:.0%})")

# Get markets by specific group ID
trump_markets = await sdk.get_markets_by_group("politics_2024_trump_election_a3f2c1")

# Get grouping statistics
stats = sdk.get_grouping_stats()
print(f"Cross-platform groups: {stats['cross_platform_groups']}")

Group ID Format: {category}_{year}_{topic_slug}_{hash[:6]}

  • Example: politics_2024_trump_election_a3f2c1

Layer 4: Arbitrage Detection

# Find cross-platform arbitrage opportunities
opportunities = await sdk.get_arbitrage_opportunities(
    min_profit=1.0,  # Minimum 1% profit
    min_similarity=80  # High similarity threshold
)

for opp in opportunities:
    print(f"{opp.profit_pct:.1f}% profit: {opp.strategy}")

Layer 5: AI Research (Coming Soon)

# Coming in future release:
# research = await sdk.deep_research("Will GPT-5 be released?")
# ai_odds = await sdk.get_ai_odds(market_id="...")

Layer 6: Validation (Coming Soon)

# Coming in future release:
# validation = await sdk.validate(question="Will BTC hit $100k?")
# status = await sdk.check_status(market_id="...")

REST API Server

Deploy the SDK as a standalone REST API service:

# Install with server support
pip install polypoll-sdk[server]

# Run the server
polypoll-server

# Or with uvicorn directly
uvicorn polypoll_sdk.server:app --host 0.0.0.0 --port 8080

API Endpoints

Endpoint Description
GET / API info
GET /health Health check
GET /markets Get all markets
GET /markets/{platform} Get markets from platform
GET /search?q={query} Search markets
GET /groups Get grouped markets
GET /groups/{group_id} Get markets by group ID
GET /groups/stats Get grouping statistics
GET /similar/{market_id} Find similar markets
GET /arbitrage Detect arbitrage opportunities

Example API Calls

# Get all markets
curl http://localhost:8080/markets

# Search for markets
curl "http://localhost:8080/search?q=trump&limit=10"

# Get grouped markets
curl "http://localhost:8080/groups?min_similarity=80"

# Find arbitrage opportunities
curl "http://localhost:8080/arbitrage?min_profit=1.0"

UnifiedMarket Schema

All markets are normalized to a common schema:

@dataclass
class UnifiedMarket:
    # Core
    platform: str       # polymarket, kalshi, etc.
    market_id: str
    title: str
    url: str

    # Pricing (0-1)
    yes_price: float
    no_price: float

    # Cross-Platform Grouping
    group_id: Optional[str]  # e.g., "politics_2024_trump_election_a3f2c1"

    # Volume
    volume: float
    volume_24h: float
    liquidity: Optional[float]

    # Status
    status: MarketStatus  # open, closed, resolved
    is_resolved: bool
    close_time: Optional[datetime]

    # Metadata
    category: Optional[str]
    description: Optional[str]
    image_url: Optional[str]

Environment Variables

# Optional API keys
EXA_API_KEY=your-exa-key        # For AI research (coming soon)
GROQ_API_KEY=your-groq-key      # For AI research (coming soon)
KALSHI_API_KEY=your-kalshi-key  # For Kalshi private data

# Server configuration
HOST=0.0.0.0
PORT=8080

Development

# Clone repository
git clone https://github.com/OpenOracleWeb3/polypoll-sdk.git
cd polypoll-sdk

# Create virtual environment
python -m venv .venv
source .venv/bin/activate

# Install with all dev dependencies
pip install -e ".[all]"

# Run tests
pytest

# Run server in development
uvicorn polypoll_sdk.server:app --reload

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

polypoll_sdk-0.1.1.tar.gz (24.7 kB view details)

Uploaded Source

Built Distribution

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

polypoll_sdk-0.1.1-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

Details for the file polypoll_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: polypoll_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 24.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for polypoll_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 256f8baa02d54ee1fffb6bf9c4309e9abbfcd474ce3203d7d9711ad0f3184bdc
MD5 24503d3762139015d0d39b2f84f0c857
BLAKE2b-256 ad322f550da04928036862a9d13a29c8c5e019deb1bba131cfb1e892b75f60a2

See more details on using hashes here.

File details

Details for the file polypoll_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: polypoll_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 36.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for polypoll_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 acce9db66f0ca0d36be79f5d8b83d84be0415466baed4653966d08a67c65b718
MD5 44cd7360a17f4e80cfedaa71b8b0cf55
BLAKE2b-256 b60e933a4f5728c940abf22b784dc191efbd260e674972fea5b70a3695cf9a71

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