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.
Two different tools for two different strategies. Know which one fits your agent's goals before you build.
Need perpetuals? See the Trading API for leveraged positions and futures.
A single SDK covers your entire spot workflow โ balance checks, swaps, cross-DEX routing, and trade history. No custom integrations per chain.
# 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']}")
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.
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.
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.
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.
Spot trading is the foundation of automated portfolio management. Configure target allocations and let the API handle the math.
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.
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.
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.
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.