Spot Markets

Spot Trading API
for AI Agents

Not every strategy needs leverage. Spot trading lets agents accumulate assets, rebalance portfolios, and hold long-term positions without liquidation risk. Buy BTC, hold SOL, swap USDC for ETH โ€” across 8 blockchains, routed through the best available DEX liquidity.

Start Trading โ†’ View Docs

Spot vs Perpetuals

Two different tools for two different strategies. Know which one fits your agent's goals before you build.

Property
Spot Trading
Perpetuals
Asset ownership
Yes โ€” you own the token outright
No โ€” synthetic position only
Liquidation risk
None โ€” position can go to zero, you keep the asset
Yes โ€” undercollateralized positions are liquidated
Funding rates
No โ€” hold indefinitely for free
Yes โ€” paid every 8 hours, can be significant
Leverage
1x only (what you deposit, you own)
Up to 50x โ€” maximizes capital efficiency
Multi-chain
Yes โ€” 8 chains, 200+ tokens
Single margin account (Ethereum)
Best for
Accumulation, DCA, rebalancing, long-term holds
High-frequency, directional bets, hedging

Need perpetuals? See the Trading API for leveraged positions and futures.

Buy, Sell, and Swap

A single SDK covers your entire spot workflow โ€” balance checks, swaps, cross-DEX routing, and trade history. No custom integrations per chain.

spot_swap_example.py Python
# pip install purpleflea
import purpleflea

wallet = purpleflea.WalletClient(api_key="YOUR_KEY")

# Check balances
balances = wallet.get_balances(agent_id="agent_001")
print(f"ETH balance: {balances['ETH']} ETH")
print(f"USDC balance: {balances['USDC']} USDC")

# Buy ETH with USDC (best rate across DEXes)
swap = wallet.swap(
    agent_id="agent_001",
    from_token="USDC",
    to_token="ETH",
    amount=500,          # Spend $500 USDC
    slippage_bps=50,     # Max 0.5% slippage
    chain="ethereum"
)

print(f"Swapped: {swap['from_amount']} USDC โ†’ {swap['to_amount']} ETH")
print(f"Effective price: ${swap['price_usd']:.2f}")
print(f"Route: {swap['dex_route']}")  # e.g. "Uniswap V3 โ†’ Curve"

# Dollar-cost average โ€” schedule recurring buys
dca = wallet.schedule_dca(
    agent_id="agent_001",
    from_token="USDC",
    to_token="ETH",
    amount_per_run=100,
    frequency="daily",
    chain="ethereum"
)
print(f"DCA configured: {dca['dca_id']} โ€” next buy: {dca['next_run']}")

Supported Chains

One SDK, eight blockchains. Your agent can hold BTC as a store of value, trade SOL for speed, and settle in USDC on Polygon โ€” all from the same API key.

โšก
Ethereum
ETH, USDC, USDT, WBTC, DAI, LINK, UNI, AAVE, +140 ERC-20s
Deepest liquidity
โ‚ฟ
Bitcoin
BTC (native). Buy, hold, send. Non-custodial via Purple Flea wallet abstraction.
Store of value
โ—Ž
Solana
SOL, USDC, BONK, JTO, JUP, PYTH, RAY, +80 SPL tokens
Fastest swaps
๐ŸŸก
BNB Chain
BNB, USDT, BUSD, CAKE, and BEP-20 ecosystem tokens
Low gas
๐Ÿ”ต
Polygon
MATIC/POL, USDC, USDT, WETH, WBTC. Near-zero fees for micro-swaps.
Micro-payments
๐Ÿ”ด
Tron
TRX, USDT (TRC-20), USDD. Dominant for USDT transfers in Asia.
USDT hub
๐Ÿ”๏ธ
Avalanche
AVAX, USDC, USDT, JOE, GMX. C-chain EVM compatible.
DeFi native
๐Ÿ”ท
Base
ETH, USDC, cbBTC, DEGEN. Coinbase L2 โ€” cheap ETH-family transactions.
L2 efficiency

DEX Aggregation

Purple Flea routes every swap through multiple DEX aggregators in parallel to find the best effective price at time of execution. Your agent never manually picks a DEX โ€” we do that automatically.

How Routing Works
When your agent calls wallet.swap(), Purple Flea queries all available DEXes and aggregators simultaneously, calculates the effective output (after gas and fees), picks the winner, and executes. The entire process takes under 2 seconds.

For large orders, Purple Flea splits the trade across multiple venues (e.g., 60% Uniswap V3, 40% Curve) to minimize price impact. This is called smart order routing and it is included at no extra cost.
Slippage Protection
Set slippage_bps to define your maximum acceptable price deviation in basis points. If the market moves beyond your tolerance before execution, the transaction reverts and your agent's funds are returned with no gas charge.
Integrated DEX Venues
New DEXes added automatically as liquidity migrates. Your code never needs updating.

Portfolio Rebalancing

Spot trading is the foundation of automated portfolio management. Configure target allocations and let the API handle the math.

Target Allocation Rebalancing
Define your agent's target portfolio (e.g., 40% BTC, 40% ETH, 20% USDC). Call wallet.rebalance() and Purple Flea calculates the minimum set of swaps needed to restore target weights โ€” then executes them all in one batch, minimizing gas.
Dollar-Cost Averaging (DCA)
Schedule recurring swaps โ€” daily, weekly, or hourly โ€” with wallet.schedule_dca(). Purple Flea executes at the configured time, picks the best DEX route, and logs the result. DCA is one of the most effective long-term accumulation strategies for autonomous agents.
Take-Profit / Stop-Loss
Set price triggers on any spot position. When ETH reaches your target price, the API automatically swaps back to USDC. When it drops below your stop-loss, the same. No polling required from your agent โ€” Purple Flea's price oracle fires the swap server-side.
Multi-Chain Portfolio View
wallet.get_portfolio(agent_id) returns a unified USD-denominated view of all holdings across all 8 chains โ€” no manual chain-by-chain queries needed. Updated every 30 seconds.
8
Supported chains
200+
Tradeable tokens
<0.3%
Average slippage
<2s
Quote to execution
Ready to Build?

Start Building Your Spot Trading Agent

Get a free API key and execute your first cross-DEX swap within minutes. No KYC, no minimums, no lock-in. Scale to institutional volumes when ready.