worm-sdk
Official Python client for the Worm prediction markets API.
Features
- Full coverage of the Worm REST API — markets, events, search, spot orders, margin, redeems, and account data
- Typed responses with Pydantic models
- HMAC authentication for private endpoints
- Optional Solana wallet signing for order, margin, and redeem flows
- Cursor-based pagination helpers
- HTTP/2 via httpx
Requirements
- Python 3.10 or later
Installation
pip install worm-sdk
Install from source:
git clone https://github.com/wormwtf/worm-sdk.git
cd worm-sdk
pip install -e .
For wallet signing (orders, margin, redeems):
pip install "worm-sdk[signing]"
Quickstart
Fetch public market data — no credentials required:
from worm_sdk import WormClient
with WormClient() as client:
page = client.markets.list(sort="trending", limit=5)
for market in page.items:
print(market.title, market.condition_id)
Authentication
Worm uses HMAC-signed API keys. Create a key once with a Solana wallet, then reuse the key and secret for all authenticated calls.
from worm_sdk import WormClient
from worm_sdk.auth import SolanaWalletSigner
# One-time setup — store the returned credentials securely
signer = SolanaWalletSigner("YOUR_SOLANA_PRIVATE_KEY")
credentials = WormClient.create_api_key(signer)
# Authenticated client
client = WormClient(
api_key=credentials.api_key,
api_secret=credentials.secret,
signer=signer, # optional; needed for place/redeem/open_position helpers
)
profile = client.account.get_summary()
print(profile.username)
SolanaWalletSigner accepts a base58 string, 128-character hex keypair, or raw 64-byte keypair bytes. You can also provide any object that implements SignerProtocol (Ledger, KMS, etc.).
Set credentials via environment variables when running the examples:
export WORM_API_KEY="..."
export WORM_API_SECRET="..."
export WORM_PRIVATE_KEY="..." # only for signing flows
Usage
WormClient exposes namespaced APIs:
| Namespace | Auth | Description |
|---|---|---|
client.markets |
— | Market listings, order books, candles, prices, trades |
client.events |
— | Event listings and detail |
client.search |
— | Search markets and events |
client.sports |
— | Sports and league catalog |
client.orders |
✓ | Spot order lifecycle |
client.trades |
✓ | Your trade history |
client.account |
✓ | Profile, portfolio, P&L |
client.margin |
✓ / — | Margin estimate (public); positions, requests, settlements |
client.redeems |
✓ | Redeem resolved positions |
client.api_keys |
✓ | List and revoke API keys |
List endpoints return a CursorPage[T] with items, next_cursor, and limit:
page = client.markets.list(limit=20)
while page.next_cursor:
page = client.markets.list(limit=20, cursor=page.next_cursor)
Convenience methods combine draft, sign, and submit in one call when a signer is configured:
from worm_sdk import OrderSide, OrderType
client.orders.place(
market_condition_id="...",
is_yes=True,
side=OrderSide.BUY,
order_type=OrderType.LIMIT,
amount="10",
price="0.55",
)
See the examples/ directory for complete scripts covering markets, orders, margin, redeems, and more.
Error handling
from worm_sdk import AuthenticationRequired, WormAPIError
try:
client.orders.list(limit=1)
except WormAPIError as exc:
print(exc.error_code, exc.slug, exc.message)
except AuthenticationRequired:
print("Pass api_key and api_secret to WormClient")
Configuration
client = WormClient(
api_key="...",
api_secret="...",
base_url="https://api.worm.wtf", # default
timeout=30.0,
signer=signer,
)
Inspect rate limits and response metadata on client.last_response after each request.
Development
pip install -e ".[dev,signing]"
pytest
ruff check .
mypy src
Build locally:
python -m build
Releases are published to PyPI automatically when you push a version tag (e.g. v0.9.0) or publish a GitHub Release. Set the PYPI_API_TOKEN repository secret first.
Links
License
MIT — see LICENSE.
Metadata
Release files for worm-sdk 0.11.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 | |
|---|---|---|---|
| worm_sdk-0.11.0.tar.gz | 38.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| worm_sdk-0.11.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 77.4 kB
Release files / worm_sdk-0.11.0.tar.gz
| Download URL | worm_sdk-0.11.0.tar.gz |
|---|---|
| Size | 38.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8525d28ed317486dd4d2a272b1b5197c28e3a516a452f1422d4f3caf601d53fd
|
|
BLAKE2b-256 checksum How to use checksums |
b1c81f88acf337e6f60e3eb38a7d8b275a44aa34696284a753d16032cdea65e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.
Transparency logRelease files / worm_sdk-0.11.0-py3-none-any.whl
| Download URL | worm_sdk-0.11.0-py3-none-any.whl |
|---|---|
| Size | 39.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a56a5a34a64f80464bee02358dcfa9e6cb7a06eabbe4e1ce7a97fee1e1ec9bce
|
|
BLAKE2b-256 checksum How to use checksums |
787eef0c92d3ba1acf3b5d117d01ca347a131fde9fb3c8a14717577374279759
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.
Transparency log