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.
Release files for predmarket 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| predmarket-0.1.0.tar.gz | 8.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| predmarket-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.4 kB
Release files / predmarket-0.1.0.tar.gz
| Download URL | predmarket-0.1.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0525db2b83649244f8c51f6cc919c2762be972c94ed24b55290c1a93812e3750
|
|
BLAKE2b-256 checksum How to use checksums |
77fd69abce9613e6ec82e06c204ca2551817563ffc9b8146a9d1831c26ba0ee4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.19
|
Release files / predmarket-0.1.0-py3-none-any.whl
| Download URL | predmarket-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
373f9179dbe8f79a828a0e862a1a29b77800532f97e6e18721d5999ad12a2801
|
|
BLAKE2b-256 checksum How to use checksums |
dcfa09cd80a0bee27e153fcbeeaee8e0e6be95ddbba5fb8b5732d08de5eb59b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.19
|