275 Perpetual Markets via Hyperliquid
Give your AI agent programmatic access to the world's deepest on-chain perpetual futures exchange. No KYC. No intermediaries. Pure API-first infrastructure built for autonomous systems.
Overview
Purple Flea wraps Hyperliquid's perpetual futures decentralised exchange into a clean, well-documented REST API purpose-built for AI agents, autonomous bots, and algorithmic trading systems. Instead of managing private key infrastructure, WebSocket subscriptions, and raw on-chain transactions, your agent makes simple HTTP calls and Purple Flea handles all the complexity underneath.
Perpetual futures are derivative contracts that track the price of an underlying asset — Bitcoin, Ethereum, Solana, and 272 others — without ever expiring. Unlike traditional futures with quarterly settlement dates, perpetuals remain open indefinitely, held in place by a funding rate mechanism that periodically exchanges small payments between long and short holders to keep the contract price anchored to the spot price. For AI agents, this is ideal: there is no roll-over logic, no calendar management, no expiry to monitor. Your agent opens a position and holds it exactly as long as its strategy dictates — seconds, hours, or months.
Because markets run 24 hours a day, 7 days a week, an autonomous agent never misses a setup due to market hours. Hyperliquid processes trades on its own high-performance Layer 1 blockchain, achieving sub-second settlement finality with on-chain order books — a level of transparency and speed that centralised exchanges cannot match. Purple Flea surfaces this infrastructure through a uniform API surface so that any language, framework, or agent runtime can participate.
Leverage allows agents to control positions larger than their deposited collateral, amplifying both gains and losses. A 10x leveraged position on BTC-PERP means that a 1% move in Bitcoin translates to a 10% change in your position value — a powerful tool for momentum strategies and short-term arbitrage when applied with disciplined risk management. The API exposes leverage as a simple integer parameter on every order, making it trivial for an agent to implement dynamic position sizing.
Purple Flea currently supports 275 perpetual markets, spanning major cryptocurrencies
(BTC-PERP, ETH-PERP, SOL-PERP, BNB-PERP, AVAX-PERP), mid-cap DeFi tokens, memecoins, and newly
listed assets added as market demand emerges. The full market list is available via the
GET /markets endpoint
and updated in real time.
API Reference
Every endpoint accepts and returns JSON. Authenticate with your API key in the
X-PF-Key header.
Base URL: https://api.purpleflea.com/v1
| Method | Endpoint | Description |
|---|---|---|
| GET | /markets | List all 275 perpetual markets with metadata |
| POST | /order | Open a new position (market or limit) |
| GET | /positions | Retrieve all open positions and unrealised PnL |
| DELETE | /order/:id | Close or cancel an order by ID |
| GET | /account | Account balance, equity, margin usage, and PnL |
curl -X GET https://api.purpleflea.com/v1/markets \
-H "X-PF-Key: pf_live_your_api_key_here"
{
"markets": [
{
"symbol": "BTC-PERP",
"base": "BTC",
"mark_price": 67842.50,
"index_price": 67819.10,
"funding_rate": 0.000082,
"open_interest": 2847391042,
"max_leverage": 50
},
{
"symbol": "ETH-PERP",
"base": "ETH",
"mark_price": 3521.77,
"index_price": 3519.40,
"funding_rate": 0.000061,
"open_interest": 1204857221,
"max_leverage": 50
}
// ... 273 more markets
],
"total": 275
}
curl -X POST https://api.purpleflea.com/v1/order \ -H "X-PF-Key: pf_live_your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "market": "BTC-PERP", "side": "long", "size_usd": 5000, "leverage": 10, "order_type": "market", "margin_mode": "isolated" }'
{
"order_id": "ord_8f3a92bc1d4e",
"market": "BTC-PERP",
"side": "long",
"size_usd": 5000,
"entry_price": 67849.20,
"leverage": 10,
"margin_required": 500,
"liquidation_price": 61200.00,
"status": "open",
"timestamp": "2025-03-15T14:23:01.482Z"
}
{
"positions": [
{
"order_id": "ord_8f3a92bc1d4e",
"market": "BTC-PERP",
"side": "long",
"size_usd": 5000,
"entry_price": 67849.20,
"mark_price": 68102.40,
"unrealised_pnl": 18.64,
"unrealised_pnl_pct": 3.73,
"funding_paid": -0.41
}
]
}
{
"balance_usdc": 12500.00,
"equity": 12518.64,
"available_margin": 12018.64,
"used_margin": 500.00,
"total_realised_pnl": 342.17,
"total_unrealised_pnl": 18.64
}
Market Coverage
From the world's most liquid crypto assets to emerging tokens, Purple Flea gives your agent exposure to the full breadth of perpetual futures markets.
The flagship perpetual. Bitcoin perpetuals carry the deepest liquidity in crypto derivatives, with billions in daily volume. Funding rates are typically low and stable, making BTC-PERP the go-to market for trend-following agents and longer-duration position holders.
Ethereum perpetuals are the second most liquid market on Hyperliquid. ETH-PERP often leads directional moves and provides excellent arbitrage opportunities against ETH spot and options markets. Ideal for DeFi-aware agents that cross-reference on-chain signals.
Solana perpetuals have grown into one of the highest-volume altcoin markets. High volatility and active retail participation create frequent momentum setups. SOL-PERP is a popular choice for breakout detection agents and volatility-harvesting strategies.
BNB-PERP, AVAX-PERP, MATIC-PERP, ARB-PERP, OP-PERP, DOGE-PERP, LINK-PERP, UNI-PERP, AAVE-PERP, and hundreds more. New markets are added as trading activity and community demand warrant. Every market accessible through the same uniform API.
Funding rates are the mechanism that keeps perpetual futures prices tethered to spot.
Every eight hours, the long side pays the short side (or vice versa) a small fee based on the
premium between mark price and index price. A positive funding rate means longs pay shorts —
the market is in contango, heated by buyers. A negative rate means shorts pay longs — the market
is in backwardation. Purple Flea returns the current funding rate, next funding timestamp, and
annualised funding yield in every GET /markets
response, giving funding-rate arbitrage agents all the data they need.
Mark price vs index price: mark price is calculated from a smoothed order book mid-price, while index price aggregates spot prices from multiple major exchanges. Liquidations are triggered based on mark price — not last traded price — preventing market manipulation from cascading liquidations. Your agent receives both values in every position update.
No KYC, no identity verification. Because Hyperliquid is a decentralised protocol, there is no central authority to request identification documents. AI agents by their nature cannot undergo KYC procedures. Purple Flea preserves this property: an agent authenticates with its API key and USDC collateral, nothing more. This is foundational for agent-native financial infrastructure.
Leverage & Risk
Purple Flea exposes the full Hyperliquid leverage range with both isolated and cross-margin modes, giving your agent granular control over capital allocation and portfolio-level risk.
In isolated margin, each position is siloed with its own collateral. A position can only lose the margin allocated to it — a loss on BTC-PERP cannot drain your ETH-PERP margin. This is the recommended mode for multi-strategy agents running independent sub-systems, as it enforces hard capital boundaries between positions. Use isolated margin when each strategy has its own risk budget.
Cross margin pools all available account equity as collateral for all open positions. This prevents individual position liquidations during temporary drawdowns at the cost of greater correlated risk. Suitable for agents that run a single unified strategy across multiple correlated markets — for example, a delta-neutral market-making agent that hedges BTC-PERP long with ETH-PERP short and benefits from shared margin efficiency.
Positions approaching their liquidation price receive a partial de-leveraging before
full liquidation, reducing market impact. The API returns a real-time
liquidation_price
with every position, allowing agents to implement proactive risk management — adding margin,
reducing size, or setting stop-loss orders — well before a forced close occurs.
Quantitatively optimal bet sizing via the Kelly Criterion requires an edge estimate and an odds ratio. Purple Flea's API returns historical win rates per strategy tag, current funding yield (a free edge for short-funding plays), and real-time mark vs index spread data. An autonomous agent can continuously recalculate Kelly fractions and resize positions accordingly on every signal — treating leverage as a dynamic variable rather than a static configuration.
Referral Economics
When your agent or your users trade through Purple Flea, 20% of all trading fees flow back to you permanently — on every single trade, forever.
Hyperliquid charges a maker fee of 0.02% and a taker fee of 0.05% per trade. Purple Flea shares 20% of the collected fee revenue with the referring developer or agent operator. As trading volume compounds over time — particularly for agents that trade continuously — referral income becomes a meaningful passive revenue stream that requires zero ongoing effort.
Consider the mathematics with conservative assumptions. An agent executing moderate momentum trades generates roughly $100,000 in daily notional volume. At Hyperliquid's 0.05% taker fee, that volume generates $50 in fees per day. Your 20% referral share on those fees equals $10 per day — $300 per month, $3,650 per year — from a single agent. Onboard ten active agents and the monthly passive income is $3,000. Onboard a hundred and it is $30,000 per month. The referral program is designed to reward developers who build valuable agent tooling and attract serious trading volume to the platform.
Referral attribution is permanent. Once a wallet is linked to your referral code at
account creation, every trade that wallet ever makes — today, next year, five years from now —
generates your commission. There is no time limit, no cap, and no clawback. Track your
referral earnings in real time through the GET /referral/stats
endpoint, which returns daily, weekly, and all-time commission totals with per-wallet breakdowns.
Python SDK
The official Purple Flea Python SDK wraps every endpoint with full type annotations, automatic retry logic, and async support. Install with pip and be trading within minutes.
pip install purpleflea
from purpleflea import TradingClient client = TradingClient(api_key="pf_live_your_api_key_here") # Check account balance before trading account = client.get_account() print(f"Available margin: ${account.available_margin:.2f}") # Open a $5,000 BTC long at 10x leverage (isolated margin) order = client.create_order( market="BTC-PERP", side="long", size_usd=5000, leverage=10, order_type="market", margin_mode="isolated" ) print(f"Order opened: {order.order_id}") print(f"Entry price: ${order.entry_price:,.2f}") print(f"Liquidation: ${order.liquidation_price:,.2f}")
import asyncio from purpleflea import AsyncTradingClient async def momentum_agent(): client = AsyncTradingClient(api_key="pf_live_your_api_key_here") while True: markets = await client.get_markets() btc = next(m for m in markets if m.symbol == "BTC-PERP") # Simple funding-rate signal: short when funding is very positive if btc.funding_rate > 0.0003: await client.create_order( market="BTC-PERP", side="short", size_usd=1000, leverage=3 ) await asyncio.sleep(60) # poll every minute asyncio.run(momentum_agent())
Use Cases
The Purple Flea Trading API is the execution layer for an entire generation of autonomous financial agents. Here are the most common patterns we see developers shipping today.
Detects price breakouts using moving average crossovers, RSI divergence, or volume spikes, then enters directional positions with pre-set take-profit and stop-loss orders. The agent runs continuously, scanning all 275 markets every minute for qualifying setups.
Monitors the spread between mark price and index price across markets. When BTC-PERP trades at a persistent premium to spot, the agent shorts BTC-PERP while buying spot BTC, capturing the basis as it converges. Funding-rate arbitrage adds a second independent yield stream.
Places symmetric bid/ask limit orders around the mid-price in high-volume markets, earning the maker rebate on every fill while managing inventory risk through dynamic skewing. Cross-margin mode enables efficient capital use across multiple maker books simultaneously.
A portfolio manager agent allocates capital across multiple sub-agents, each running a distinct strategy on a distinct market. The parent agent monitors aggregate exposure, enforces portfolio-level VaR limits, and rebalances position sizes using Kelly Criterion fractions derived from each sub-agent's live Sharpe ratio.
LLM-powered agents with tool access to the Purple Flea Trading API can reason about market conditions in natural language and execute trades as tool calls. See our LangChain integration guide and CrewAI integration guide for drop-in tool definitions.
The Purple Flea MCP server exposes trading endpoints as Model Context Protocol tools, letting Claude agents browse markets, open positions, and monitor PnL through structured tool calls without writing a single line of integration code. See the Claude MCP guide.
Systematically identifies the markets with the highest positive funding rates, opens short positions to receive funding payments, and dynamically rebalances as rates shift. A low-risk, yield-focused strategy well suited to agents with a conservative risk mandate.