Skip to main content

Unified data API for Kalshi and Polymarket. Core schema + clean SDk.

Project description

A Unified SDK for Prediction Markets

predmarket is an asyncio-native Python-based library that communicates directly with prediction markets (Kalshi and Polymarket).

Both Kalshi and Polymarket provide public-facing APIs with high rate limits. predmarket aims to unify these two APIs into one install, one format, and one library to learn. The goal to be abstract enough to be intuitive, but not lose any power of the individual APIs.

Currently, Websocket support is under development. A working implementation of Polymarket's CLOB WS API is available, while Kalshi's is still being developed.

Install

uv add predmarket or pip install predmarket

Basic Usage

REST

from predmarket import KalshiRest, PolymarketRest
from httpx import AsyncClient

async def main()
    async with AsyncClient() as client:

        # Initialize fetchers. Each with exact same public-facing API.
        kalshi = KalshiRest(client)
        polymarket = PolymarketRest(client)

        # Fetch available Questions (e.g. "When will Elon Musk get to Mars?", known as events in native API)
        kalshi_questions = await kalshi.fetch_questions()
        polymarket_questions = await polymarket.fetch_questions(limit=10, asc=True) # Polymarket-specific query params

        # Fetch available Contracts  (e.g. "Will Elon Musk get to Mars before 2026?", these are individual "solutions" for a given question , Markets in native APIs)
        kalshi_contracts = await kalshi.fetch_contracts()
        polymarket_contracts = await polymarket.fetch_contracts() # Polymarket-specific query params

WS

from predmarket import PolymarktWS # Kalshi is NOT currently supported, but will be very solutions

async def main():
    async with PolymarketWS.connect() as socket:
        polymarket = PolymarketWS(socket)
        for row in polymarket.stream(["AB.....XYZ"]): # Example of fetching real markets later in docs
            print(row) # Row is a pydantic model. Autocomplete!

More Information

predmarket is under rapid development. Expect breaking changes unless indiciated otherwise.

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

predmarket-0.1.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

predmarket-0.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file predmarket-0.1.0.tar.gz.

File metadata

  • Download URL: predmarket-0.1.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.19

File hashes

Hashes for predmarket-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0525db2b83649244f8c51f6cc919c2762be972c94ed24b55290c1a93812e3750
MD5 0fd4a96544c5a005de7956b98d6c48fa
BLAKE2b-256 77fd69abce9613e6ec82e06c204ca2551817563ffc9b8146a9d1831c26ba0ee4

See more details on using hashes here.

File details

Details for the file predmarket-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: predmarket-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.19

File hashes

Hashes for predmarket-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 373f9179dbe8f79a828a0e862a1a29b77800532f97e6e18721d5999ad12a2801
MD5 af10e4d60d4876620095947403f6e67f
BLAKE2b-256 dcfa09cd80a0bee27e153fcbeeaee8e0e6be95ddbba5fb8b5732d08de5eb59b1

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