The official Python client for all Purple Flea APIs. One install gives you sync and async access to crypto wallets, perpetual futures trading, provably fair casino games, and domain registration. Python 3.9+. Fully typed. Async-native.
Install the base SDK with pip. Optional extras pull in framework-specific integrations for LangChain and CrewAI.
The core package has zero heavyweight dependencies — just httpx,
pydantic, and the Python standard library.
The SDK ships two first-class clients. Use the synchronous PurpleFlea client
for scripts and notebooks. Use AsyncPurpleFlea inside asyncio
applications, FastAPI endpoints, and LangGraph agents where every network call should be non-blocking.
Every Purple Flea product maps to a sub-module on the client. Each sub-module is also importable directly for use in typed function signatures and dependency injection.
| Module | Import path | Description | Tag |
|---|---|---|---|
| client.wallet | purpleflea.wallet | Check balances, send crypto, swap tokens across 6 chains | Wallet |
| client.trading | purpleflea.trading | Open/close perpetual futures positions across 275 markets | Trading |
| client.casino | purpleflea.casino | Provably fair coin flip, dice, roulette, and slots | Casino |
| client.domains | purpleflea.domains | Search, register, and manage ENS and .flea domains | Domains |
Every SDK method raises a typed exception on failure. All exceptions inherit from
PurpleFleaError so you can catch broadly or handle specific cases.
Each exception carries a machine-readable code field,
an HTTP status, and a human-readable message.
Purple Flea sends signed webhooks for transaction confirmations, trade settlements, game outcomes, and domain events. The SDK ships a helper that verifies the HMAC-SHA256 signature in one line — use it in any web framework.
Every SDK method is annotated with precise input and return types. All API responses are deserialized
into Pydantic v2 models — you get IDE autocompletion, runtime validation, and
.model_dump() for free serialization back to JSON.
All type annotations use from __future__ import annotations for Python 3.9/3.10 compatibility without sacrificing modern syntax.
The SDK ships a py.typed marker file. Both mypy and pyright resolve all types correctly out of the box with no extra configuration.
Built on httpx. The async client supports connection pooling, HTTP/2, and concurrent requests out of the box. No thread pool hacks needed.
Transient 5xx errors and rate limits are retried automatically with exponential backoff. Configure max retries and backoff factor on the client constructor.
Set PURPLEFLEA_API_KEY and the client reads it automatically. No need to pass the key explicitly in production deployments.
All responses parse into Pydantic v2 models with field validation, aliases, and model_dump(). No more wrestling with raw dicts.
Install purpleflea[langchain] or purpleflea[crewai] for pre-built tool wrappers ready to drop into any agent.
The SDK ships with a mock transport for unit testing. Swap in MockTransport and your agent code is testable without hitting the real API.
Free to start. No KYC. pip install and your agent has a wallet, trading desk, casino, and domain registrar.