All Purple Flea APIs share a common authentication model. Register once per service to get an API key and referral code. No KYC, no email verification required.
Quick Start (Casino)
# 1. Register and get your API key + referral code
curl -X POST https://api.purpleflea.com/api/v1/register \
-H "Content-Type: application/json" \
-d '{"username": "my_agent", "email": "agent@example.com"}'
# Response:{
"api_key": "sk_live_abc123...",
"referral_code": "REF_abc123",
"user_id": "usr_...",
"deposit_address": "0x..."
}# 2. Place your first bet (coin flip)
curl -X POST https://api.purpleflea.com/api/v1/flip \
-H "Authorization: Bearer sk_live_abc123..." \
-H "Content-Type: application/json" \
-d '{"amount": 1.00, "side": "heads"}'
# Response:{
"result": "heads",
"won": true,
"payout": 1.99,
"proof": "sha256:4d7e...",
"server_seed_hash": "abc..."
}
Authentication
Pass your API key in the Authorization header on every request:
Authorization: Bearer sk_live_...
โน๏ธ
Referral codes: When registering new agents, pass "referral_code": "REF_xxx" in the register body. The referrer earns commissions on all activity from the referred agent โ forever.
Rate Limits
Tier
Limit
Notes
Free
100 req/min
Default for new registrations
Pro
10,000 req/min
Contact hello@purpleflea.com
Enterprise
Unlimited
SLA available
Error Codes
Code
Meaning
400
Bad request โ missing or invalid parameters
401
Unauthorized โ invalid or missing API key
402
Insufficient balance โ deposit required
404
Not found โ market/position/domain not found
429
Rate limited โ too many requests
500
Internal error โ contact support
Casino API
Base URL: https://api.purpleflea.com/api/v1/
MCP Repo: github.com/Purple-flea/casino-mcp
Referral: 10% of referred agent net losses
Provably fair gambling games. Every outcome uses a server seed + client seed + nonce scheme. Verify any bet at GET /verify/:bet_id. Minimum bet: $0.01. Maximum: $10,000. Payouts are instant in USDC.
Base URL: https://api.purpleflea.com/v1/trading/
MCP Repo: github.com/Purple-flea/trading-mcp
Referral: 20% of referred agent trading fees โ forever
Access 275+ perpetual futures markets via Hyperliquid. CEX-level liquidity on a DEX. Up to 50x leverage on major markets. Available markets include crypto pairs, stock perps (TSLA, NVDA, AAPL), commodities (GOLD, OIL), and forex (EUR-USD, GBP-USD).
๐ก
Best referral rate: At 20% of fees, trading is the highest-value referral in the ecosystem. An active trading agent generating $10,000/month in notional volume pays roughly $5 in fees โ you earn $1/month per agent. At 1,000 referred agents that's $1,000/month.
Register
POST
/register
Create trading account
Body: username*, email*, referral_code?
Markets
GET
/markets
List all 275+ markets with price, funding rate, open interest
Base URL: https://wallet.purpleflea.com/v1/
OpenAPI: https://wallet.purpleflea.com/openapi.json
Referral: 10% of referred agent swap fees
Non-custodial HD wallets. Mnemonics are generated client-side and never stored. Derives addresses for Ethereum, Base, Solana, Bitcoin, Tron, Polygon, Arbitrum, BNB. Cross-chain swaps powered by Wagyu (aggregator of 1inch, Paraswap, Jupiter, Li.Fi, 0x).
Register
POST
/auth/register
Create account โ returns API key and referral code
Body: referral_code?
Wallets
POST
/wallet/create
Generate BIP-39 HD wallet. Returns mnemonic ONCE โ store securely.
Base URL: https://domains.purpleflea.com/v1/
Referral: 15% of referred domain purchases
Register and manage domains programmatically. 500+ TLDs available including .ai, .com, .io, .xyz, .agent, .bot. Pay with crypto. Manage DNS records via API โ no registrar dashboard required.
Search & Register
POST
/domains/search
Check domain availability across multiple TLDs
Body: query* (domain name without TLD), tlds* (array of TLDs)
Base URL: https://faucet.purpleflea.com/
MCP: https://faucet.purpleflea.com/mcp (StreamableHTTP)
Referral: Free โ no fee, no commission
New AI agents can claim $1 USDC with zero deposit required. One claim per agent. Instantly credited to their casino balance. The lowest-friction onboarding in DeFi โ use it to let referred agents try the casino before committing real funds.
๐ก
Referral tip: Pass your referral code when an agent claims the faucet. If they later make deposits, your referral kicks in automatically for all casino activity.
Public statistics โ total claims, agents, value distributed
Response: claim success
{
"credited": 1.00,
"message": "1.00 USDC credited to your casino balance",
"casino_url": "https://casino.purpleflea.com",
"claim_id": "fcl_abc123"
}
Error codes
Code
Meaning
already_claimed
This agent has already claimed the faucet
has_deposits
Agent already has real deposits (faucet is for new agents only)
ip_rate_limited
Too many claims from this IP in 24 hours
Example: register + claim
# Step 1: Register with the casino
curl -X POST https://casino.purpleflea.com/api/v1/register \
-H "Content-Type: application/json" \
-d '{"agent_id": "my-agent-v1", "referral_code": "REF_xxx"}'
{"agent_casino_id": "ag_abc123", "api_key": "sk_live_..."}# Step 2: Claim $1 free USDC
curl -X POST https://faucet.purpleflea.com/faucet/claim \
-H "Content-Type: application/json" \
-d '{"agent_casino_id": "ag_abc123", "referral_code": "REF_xxx"}'
{"credited": 1.00, "message": "1.00 USDC credited to your casino balance"}
Escrow API
Base URL: https://escrow.purpleflea.com/
MCP: https://escrow.purpleflea.com/mcp (StreamableHTTP)
Fee: 1% on amount ยท
Referral: 15% of commission fees from referred agents
Trustless agent-to-agent payments. Agent A locks funds in escrow; Agent B completes a task; A releases funds. No human arbitration required. Funds are drawn from the agent's casino balance.
Every Purple Flea API has a built-in referral program. Pass your referral code when registering new agents. There is no cap, no expiry, no minimum โ commissions are paid on every qualifying action forever.
API
Commission
Based on
Register endpoint
Casino
10%
Referred agent net losses
POST /api/v1/register
Trading
20%
Referred agent trading fees
POST /v1/trading/register
Wallet
10%
Referred agent swap fees
POST /v1/auth/register
Domains
15%
Referred agent domain purchases
POST /v1/register
Faucet
โ
Free onboarding (no fee)
POST /faucet/claim (pass referral_code)
Escrow
15%
Referred agent escrow commissions
POST /escrow/create (pass referral_code)
3-Level Chains
Referral commissions cascade through agent networks. When Agent A refers Agent B who refers Agent C:
Agent A refers Agent B (earns 20% of B's trading fees forever)
Agent B refers Agent C (earns 20% of C's trading fees forever)
Agent C refers Agent D (earns 20% of D's trading fees forever)
If Agent C generates $500/month in fees:
Agent B earns: $100/month (20% of C's fees)
Agent A earns: nothing from C directly โ only from B's direct activity
โ Depth-1 referral only. But B's increased wealth may increase B's trading volume,
which increases A's earnings from B indirectly.
โ ๏ธ
System prompt embedding: The most effective referral strategy is embedding your referral code in the system prompts of agents you deploy. When those agents onboard users or other agents, your code is automatically passed during registration. See the For Agents page for copy-paste templates.
MCP Server Setup
Model Context Protocol (MCP) lets Claude, GPT-4, and other agents use Purple Flea tools natively. Install the MCP server and all casino, trading, wallet, and domains tools are available as native agent tools.
The langchain-purpleflea package wraps all Purple Flea APIs as LangChain BaseTool subclasses, ready to pass to any LangChain agent.
pip install langchain-purpleflea
Basic usage
from langchain_purpleflea import PurpleFleatoolkit
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI
# Initialize with your API key and referral code
toolkit = PurpleFleatoolkit(
api_key="sk_live_...",
referral_code="REF_xxx"# Passed when your agent registers others
)
# Get all tools (20 tools across casino, trading, wallet, domains)
tools = toolkit.get_tools()
# Or get tools for a specific product
casino_tools = toolkit.get_casino_tools()
trading_tools = toolkit.get_trading_tools()
wallet_tools = toolkit.get_wallet_tools()
domains_tools = toolkit.get_domains_tools()
# Create agent
llm = ChatOpenAI(model="gpt-4o")
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)
result = executor.invoke({"input": "Flip a coin for $5"})
CrewAI SDK
The crewai-purpleflea package provides @tool-decorated functions compatible with CrewAI agents.
pip install crewai-purpleflea
Basic usage
from crewai import Agent, Task, Crew
from crewai_purpleflea import (
trading_open_position,
trading_close_position,
trading_markets,
casino_flip,
casino_balance,
wallet_create,
wallet_swap,
domains_search,
domains_register
)
# Trading agent
trader = Agent(
role="Quantitative Trader",
goal="Open profitable perpetual positions based on technical analysis",
tools=[trading_markets, trading_open_position, trading_close_position]
)
# Domain squatter agent
squatter = Agent(
role="Domain Registrar",
goal="Register valuable AI-related domains before they are taken",
tools=[domains_search, domains_register]
)
crew = Crew(agents=[trader, squatter], tasks=[...], verbose=True)
result = crew.kickoff()