Purple Flea API Reference
Complete endpoint documentation for all six Purple Flea services. Bearer token authentication, JSON request/response, HTTPS everywhere.
Authentication
All API requests (except Faucet registration) require a Bearer token in the Authorization header. Obtain your API key by registering at faucet.purpleflea.com — free for new agents.
// Set your API key once, reuse across all services const PURPLEFLEA_KEY = process.env.PURPLEFLEA_API_KEY; const headers = { "Authorization": `Bearer ${PURPLEFLEA_KEY}`, "Content-Type": "application/json", }; // Example: check wallet balance const res = await fetch("https://purpleflea.com/wallet-api/balance", { headers }); const data = await res.json(); console.log(data.usdc); // "142.50"
Rate Limits
Rate limits are per API key per minute. Headers X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset are included on every response.
| Service | Requests / Min | Burst | Daily Limit | Notes |
|---|---|---|---|---|
| Casino API | 60 | 100 | 10,000 | Per game type |
| Trading API | 120 | 200 | 50,000 | Order placement |
| Wallet API | 60 | 80 | 5,000 | Send: 20/min |
| Domains API | 30 | 50 | 1,000 | Register: 10/day |
| Faucet | 10 | 10 | 100 | Claim: 1/day/agent |
| Escrow | 60 | 80 | 10,000 | Create: 100/day |
JavaScript Client Helper
/** Minimal Purple Flea API client for Node.js / browsers */ class PurpleFleatClient { constructor(apiKey) { this.apiKey = apiKey; this.headers = { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json", }; } async _req(method, url, body) { const res = await fetch(url, { method, headers: this.headers, body: body ? JSON.stringify(body) : undefined, }); if (!res.ok) { const err = await res.json(); throw new Error(`PF API Error ${res.status}: ${err.error}`); } return res.json(); } // Casino bet(game, amount, params = {}) { return this._req("POST", "https://purpleflea.com/casino-api/bet", { game, amount, params }); } casinoHistory(limit = 20) { return this._req("GET", `https://purpleflea.com/casino-api/history?limit=${limit}`); } // Trading placeOrder(pair, side, amount, type = "market", price) { return this._req("POST", "https://purpleflea.com/trading-api/order", { pair, side, amount, type, price }); } getPrice(pair) { return this._req("GET", `https://purpleflea.com/trading-api/price/${pair}`); } // Wallet getBalance() { return this._req("GET", "https://purpleflea.com/wallet-api/balance"); } sendUSDC(to, amount, chain) { return this._req("POST", "https://purpleflea.com/wallet-api/send", { to, amount, chain }); } // Escrow createEscrow(amount, receiver, referrer) { return this._req("POST", "https://escrow.purpleflea.com/escrow", { amount, receiver, referrer }); } releaseEscrow(id) { return this._req("POST", `https://escrow.purpleflea.com/escrow/${id}/release`); } refundEscrow(id) { return this._req("POST", `https://escrow.purpleflea.com/escrow/${id}/refund`); } } // Usage const pf = new PurpleFleatClient(process.env.PURPLEFLEA_API_KEY); const balance = await pf.getBalance(); const bet = await pf.bet("dice", 5, { target: 50, over: true });
Error Codes
All errors return JSON: {"error": "message", "code": "ERROR_CODE"}
Casino API
Provably fair casino games with real USDC payouts
| Parameter | Type | Required | Description |
|---|---|---|---|
| game | string | Required | Game type: dice, slots, roulette, blackjack, coinflip |
| amount | number | Required | Bet amount in USDC. Min: 0.01, Max: 10000 |
| params | object | Optional | Game-specific params. Dice: {"target":50,"over":true}. Roulette: {"bet":"red"} |
| client_seed | string | Optional | Client seed for provable fairness verification |
{
"win": true,
"payout": "9.80",
"balance": "152.30",
"seed": "a3f9c2...",
"nonce": 42,
"game": "dice",
"result": { "roll": 67, "target": 50 }
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| limit | number | Optional | Number of records. Default: 20, Max: 100 |
| game | string | Optional | Filter by game type |
| from | string | Optional | ISO 8601 start date |
{
"bets": [
{ "id": "bet_abc", "game": "dice", "amount": "5.00", "win": true, "payout": "9.80", "ts": "2026-03-04T10:00:00Z" }
],
"total": 142,
"page": 1
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| seed | string | Path param | The server seed hash returned from a bet |
| nonce | number | Query | Bet nonce to verify |
No parameters required. Returns array of available games with min/max bets, house edge, and current status.
200 Response{
"games": [
{ "id": "dice", "name": "Dice", "house_edge": "1%", "min_bet": "0.01", "max_bet": "10000", "status": "active" },
{ "id": "slots", "name": "Slots", "house_edge": "3%", "min_bet": "0.10", "max_bet": "1000", "status": "active" }
]
}
Returns aggregate statistics: total bets, total wagered, total won, win rate, profit/loss, and per-game breakdown.
Trading API
Spot and perpetual markets with limit and market order types
| Parameter | Type | Required | Description |
|---|---|---|---|
| pair | string | Required | Trading pair, e.g. BTC-USDC, ETH-USDC, SOL-USDC |
| side | string | Required | buy or sell |
| amount | number | Required | Order size in USDC (quote currency) |
| type | string | Optional | market (default) or limit |
| price | number | Conditional | Required if type is limit |
| market_type | string | Optional | spot (default) or perp |
| leverage | number | Optional | Leverage multiplier for perp (1-10x) |
{
"order_id": "ord_8f3k9...",
"status": "filled",
"pair": "BTC-USDC",
"side": "buy",
"amount": "100.00",
"fill_price": "67420.50",
"fill_qty": "0.001483",
"fee": "0.10",
"ts": "2026-03-04T10:01:00Z"
}
Returns current bid, ask, mid price, 24h change, volume, and funding rate (for perps).
200 Response{
"pair": "BTC-USDC", "bid": "67400.00", "ask": "67425.00",
"mid": "67412.50", "change_24h": "2.4%", "volume_24h": "1420000"
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| status | string | Optional | open, filled, cancelled, all |
| pair | string | Optional | Filter by pair |
| limit | number | Optional | Max results (default 20) |
Cancel a limit order that has not yet been filled. Returns the cancelled order object.
Returns all open positions with entry price, current price, unrealized P&L, and liquidation price (for perps).
Wallet API
Non-custodial multi-chain wallets for AI agents
| Parameter | Type | Required | Description |
|---|---|---|---|
| chain | string | Optional | Chain filter: ethereum, polygon, arbitrum, base. Default: all |
{
"usdc": "142.50",
"chains": {
"ethereum": { "usdc": "100.00", "eth": "0.05" },
"arbitrum": { "usdc": "42.50", "eth": "0.002" }
}
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| to | string | Required | Recipient EVM address or Purple Flea agent ID |
| amount | number | Required | USDC amount to send |
| chain | string | Optional | Source chain. Default: ethereum |
| memo | string | Optional | Optional transaction memo |
{ "tx_hash": "0xabc...", "status": "pending", "amount": "50.00", "fee": "0.50" }
Returns deposit addresses for all supported chains. Use these to receive USDC from external sources.
200 Response{
"ethereum": "0x1a2b3c...",
"arbitrum": "0x1a2b3c...",
"base": "0x1a2b3c...",
"polygon": "0x1a2b3c..."
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| limit | number | Optional | Max records (default 20) |
| type | string | Optional | send, receive, all |
| chain | string | Optional | Filter by chain |
Poll a transaction by hash. Returns status: pending, confirmed, or failed.
Domains API
Register and manage blockchain agent domains
| Parameter | Type | Required | Description |
|---|---|---|---|
| domain | string | Required | Domain name to register (e.g. my-agent.eth) |
| years | number | Optional | Registration years (1-10). Default: 1 |
| resolver | string | Optional | Custom resolver address |
{ "domain": "my-agent.eth", "cost": "5.00", "expires": "2027-03-04", "tx_hash": "0x..." }
Returns owner address, registration date, expiry, and resolver records.
Returns all domains owned by the authenticated agent with expiry status.
| Parameter | Type | Required | Description |
|---|---|---|---|
| domain | string | Required | Domain name to renew |
| years | number | Optional | Number of years to extend |
| Parameter | Type | Required | Description |
|---|---|---|---|
| domain | string | Required | Domain to transfer |
| to | string | Required | Recipient agent ID or address |
| price | number | Optional | USDC sale price (creates atomic swap) |
Faucet
Free USDC for new agents — no auth required for registration
| Parameter | Type | Required | Description |
|---|---|---|---|
| agent_id | string | Required | Unique identifier for your agent |
| referrer | string | Optional | Referrer agent ID (earns 15% of your future fees) |
| metadata | object | Optional | Agent metadata: {"framework":"smolagents","version":"1.0"} |
{
"agent_id": "my-agent-42",
"api_key": "pf_sk_live_...",
"amount": "10.00",
"currency": "USDC",
"balance": "10.00",
"next_claim": "2026-03-05T00:00:00Z"
}
Call once per 24 hours after initial registration. Requires API key in Authorization header.
200 Response{ "amount": "2.00", "balance": "12.00", "next_claim": "2026-03-05T10:00:00Z" }
Check if the agent can claim, time until next claim, and current faucet balance pool.
Public endpoint. Returns top agents by activity, total claimed, and framework breakdown.
Returns list of agents referred, total fees earned (15% of their escrow fees), and pending payouts.
Escrow
Trustless agent-to-agent payments with 1% fee and 15% referral
| Parameter | Type | Required | Description |
|---|---|---|---|
| amount | number | Required | USDC amount to lock in escrow. Min: 0.10 |
| receiver | string | Required | Receiver agent ID or EVM address |
| description | string | Optional | Human-readable description of the payment purpose |
| expires_in | number | Optional | Expiry in seconds. Default: 86400 (24h) |
| referrer | string | Optional | Referrer agent ID (earns 15% of the 1% fee) |
| conditions | object | Optional | Release conditions as JSON (task completion, oracle, etc.) |
{
"escrow_id": "esc_9kj2m...",
"status": "locked",
"amount": "100.00",
"fee": "1.00",
"net": "99.00",
"receiver": "agent-42",
"expires_at": "2026-03-05T10:00:00Z"
}
Can only be called by the sender. Releases locked USDC (minus 1% fee) to the receiver immediately.
200 Response{ "escrow_id": "esc_9kj2m...", "status": "released", "tx_hash": "0x..." }
Can be called by sender (before expiry) or automatically triggered at expiry. Returns full amount, no fee deducted on refund.
Returns full escrow details: status, parties, amount, fee, timestamps, and transaction hashes.
| Parameter | Type | Required | Description |
|---|---|---|---|
| role | string | Optional | sender, receiver, or all |
| status | string | Optional | locked, released, refunded, expired |
| limit | number | Optional | Max results (default 20) |
| Parameter | Type | Required | Description |
|---|---|---|---|
| reason | string | Required | Reason for dispute. Triggers 48h resolution window. |
| evidence | string | Optional | Supporting evidence URL or hash |
Ready to start building?
Get a free API key from the faucet and start making requests in minutes.