Wallet API • Trading API • Powered by Hyperliquid

Bitcoin API
for AI Agents

Trade BTC, hold BTC, swap BTC — everything your agent needs to interact with Bitcoin. Native SegWit wallets via the Wallet API. BTC perpetual futures up to 50x leverage via the Trading API. Cross-chain swaps BTC → ETH → USDC. Non-custodial. No KYC.

BTC Wallet — Wallet API
BTC Perps — Trading API
Cross-Chain Swaps — Wallet API

Everything Bitcoin.
One API key.

Purple Flea exposes Bitcoin across two APIs. Your Wallet API key handles custody and swaps. Your Trading API key handles perpetuals. Both are available the moment you register.

Wallet API

BTC Wallet

A native SegWit Bitcoin address derived deterministically from your agent's BIP32 seed. Receive, send, and monitor BTC on-chain.

  • Native SegWit bc1q... address
  • Check confirmed & unconfirmed balance
  • Send BTC to any address type
  • UTXO-aware fee estimation
  • Mempool.space balance verification
Trading API

BTC Perp Trading

Long or short BTC perpetual futures on Hyperliquid — the deepest on-chain perp exchange. Up to 50x leverage on BTC-USD and BTC/USDC.

  • BTC-USD perpetual futures
  • BTC/USDC pair available
  • Up to 50x leverage
  • Isolated or cross margin
  • Market, limit, stop orders
Wallet API

BTC Cross-Chain Swaps

Swap BTC to ETH, USDC, SOL, or TRX in a single API call. Purple Flea routes through the best available bridge and DEX liquidity.

  • BTC → ETH, BTC → USDC (ERC-20)
  • BTC → SOL, BTC → USDT (TRC-20)
  • Best-route bridge aggregation
  • Slippage protection built-in
  • Quote before committing

Register, fund, go.

Your agent is up and running with a Bitcoin address in under two minutes. No forms, no KYC, no infrastructure.

1

Register at wallet.purpleflea.com

Create an account with an email address. No KYC or identity verification required. An API key (pf_sk_...) and BIP32 mnemonic are generated immediately.

2

Get your BTC address

Call GET /wallet/address?chain=btc to retrieve your agent's native SegWit address. It is derived from path m/84'/0'/0'/0/0 of your HD wallet. Share it to receive BTC.

3

Fund your wallet

Send any amount of BTC to your bc1q... address from any exchange or wallet. Balances are confirmed after 1 on-chain confirmation.

4

Trade, hold, or swap

Use the Wallet API to send BTC or bridge to another chain. Use the Trading API with your agent's USDC balance to open BTC perpetual positions on Hyperliquid.

GET /wallet/address — get BTC address
GET https://api.purpleflea.com/wallet/address?chain=btc X-API-Key: pf_sk_... # Response { "chain": "btc", "address": "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq", "derivation_path": "m/84'/0'/0'/0/0", "address_type": "native_segwit" } # Check balance GET https://api.purpleflea.com/wallet/balance?chain=btc X-API-Key: pf_sk_... { "chain": "btc", "address": "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq", "balance_btc": "0.04821500", "balance_sats": 4821500, "unconfirmed_sats": 0, "usd_value": "4724.37" }

Verify via mempool.space

Agents can independently verify their BTC balance on-chain using the public mempool.space API — no trust required.

btc_balance_check.py
import requests def check_btc_balance_mempool(address: str) -> dict: """ Independently verify BTC balance via mempool.space. Returns confirmed and unconfirmed sats. """ url = f"https://mempool.space/api/address/{address}" data = requests.get(url).json() confirmed_sats = ( data["chain_stats"]["funded_txo_sum"] - data["chain_stats"]["spent_txo_sum"] ) unconfirmed_sats = ( data["mempool_stats"]["funded_txo_sum"] - data["mempool_stats"]["spent_txo_sum"] ) return { "confirmed_sats": confirmed_sats, "confirmed_btc": confirmed_sats / 1e8, "unconfirmed_sats": unconfirmed_sats, } # Usage addr = "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq" bal = check_btc_balance_mempool(addr) print(f"Confirmed: {bal['confirmed_btc']:.8f} BTC") print(f"Pending: {bal['unconfirmed_sats']} sats")

mempool.space is a fully open, permissionless Bitcoin blockchain explorer. Agents can use it to verify their BTC balance at any time without relying solely on Purple Flea's API response.

The balance formula is straightforward: confirmed = funded_txo_sum − spent_txo_sum from chain_stats. Unconfirmed transactions appear in mempool_stats using the same formula.

mempool.space API response
{ "chain_stats": { "funded_txo_sum": 14821500, "spent_txo_sum": 10000000, // confirmed balance = 4821500 sats }, "mempool_stats": { "funded_txo_sum": 500000, "spent_txo_sum": 0 // pending inbound = +500000 sats } }

Accept BTC, Auto-Convert to USDC

An agent that monitors for incoming BTC payments and automatically bridges to USDC on Ethereum via the Purple Flea swap endpoint.

btc_accept_and_convert.py
import requests, time, os API_KEY = os.environ["PURPLEFLEA_API_KEY"] BASE_URL = "https://api.purpleflea.com" HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"} def get_btc_balance() -> dict: return requests.get( f"{BASE_URL}/wallet/balance", params={"chain": "btc"}, headers=HEADERS ).json() def verify_balance_on_chain(address: str) -> int: """Cross-check via mempool.space before swapping.""" data = requests.get( f"https://mempool.space/api/address/{address}" ).json() cs = data["chain_stats"] return cs["funded_txo_sum"] - cs["spent_txo_sum"] def swap_btc_to_usdc(btc_amount: float) -> dict: """Swap BTC to USDC on Ethereum via Purple Flea bridge.""" return requests.post( f"{BASE_URL}/wallet/bridge", json={ "from_chain": "btc", "to_chain": "eth", "from_asset": "BTC", "to_asset": "USDC", "amount": str(btc_amount), }, headers=HEADERS ).json() def run_payment_agent(): info = get_btc_balance() address = info["address"] last_sats = verify_balance_on_chain(address) # on-chain truth print(f"Listening on {address} ({last_sats} sats confirmed)") while True: time.sleep(60) current_sats = verify_balance_on_chain(address) if current_sats > last_sats: received_sats = current_sats - last_sats received_btc = received_sats / 1e8 print(f"Received {received_sats} sats ({received_btc:.8f} BTC)") result = swap_btc_to_usdc(received_btc) print(f"Swapped to USDC: {result}") last_sats = current_sats if __name__ == "__main__": run_payment_agent()

BTC Perpetual Futures

Long or short BTC with up to 50x leverage via Hyperliquid, the deepest on-chain perp DEX. Access BTC-USD and BTC/USDC markets from your agent.

BTC-USD & BTC/USDC

Trade BTC perpetuals settled in USD or USDC. Both pairs available with full order book depth powered by Hyperliquid's on-chain matching engine.

Up to 50x Leverage

Go long or short BTC with up to 50x leverage. Manage position size, margin mode (isolated / cross), and liquidation price through the API.

All Order Types

Market orders for instant execution. Limit orders for precise entry. Stop-loss and take-profit orders to automate your agent's risk management.

POST /trading/order — open a BTC-USD long

POST /trading/order
# Open a 2x leveraged BTC-USD long ($1000 notional) { "market": "BTC-USD", "side": "buy", "order_type":"market", "size_usd": 1000, "leverage": 2, "margin": "isolated" } # Response { "order_id": "hl_ord_8f3k2p...", "market": "BTC-USD", "side": "buy", "fill_price": "97420.50", "size_btc": "0.01026", "notional_usd": 1000, "leverage": 2, "margin_used_usd": 500, "status": "filled" }

BTC Momentum Trading Bot

A simple agent that trades BTC-USD perpetuals on Hyperliquid based on short-term price momentum. Uses the Purple Flea Trading API.

btc_momentum_bot.py
import requests, time, os from collections import deque API_KEY = os.environ["PURPLEFLEA_TRADING_KEY"] BASE_URL = "https://api.purpleflea.com" HEADERS = {"X-API-Key": API_KEY, "Content-Type": "application/json"} MARKET = "BTC-USD" WINDOW = 10 # look-back candles for momentum SIZE_USD = 500 # notional per trade def get_btc_price() -> float: r = requests.get( f"{BASE_URL}/trading/ticker", params={"market": MARKET}, headers=HEADERS ).json() return float(r["mark_price"]) def get_open_position() -> dict | None: r = requests.get( f"{BASE_URL}/trading/positions", params={"market": MARKET}, headers=HEADERS ).json() return r.get("position") def place_order(side: str, size_usd: int, leverage: int = 3): return requests.post( f"{BASE_URL}/trading/order", json={ "market": MARKET, "side": side, "order_type":"market", "size_usd": size_usd, "leverage": leverage, "margin": "isolated", }, headers=HEADERS ).json() def close_position(position: dict): close_side = "sell" if position["side"] == "long" else "buy" return requests.post( f"{BASE_URL}/trading/order", json={ "market": MARKET, "side": close_side, "order_type": "market", "reduce_only":True, }, headers=HEADERS ).json() def run_momentum_bot(): prices = deque(maxlen=WINDOW) position = None print(f"Starting BTC momentum bot on {MARKET}...") while True: price = get_btc_price() prices.append(price) print(f"BTC: ${price:,.2f} history={len(prices)}/{WINDOW}") if len(prices) == WINDOW: momentum = (prices[-1] - prices[0]) / prices[0] position = get_open_position() if momentum > 0.005 and not position: print(f"Momentum +{momentum:.3%} — going LONG") place_order("buy", SIZE_USD) elif momentum < -0.005 and not position: print(f"Momentum {momentum:.3%} — going SHORT") place_order("sell", SIZE_USD) elif position and abs(momentum) < 0.001: print("Momentum faded — closing position") close_position(position) time.sleep(300) # 5-min candles if __name__ == "__main__": run_momentum_bot()

Transparent fee structure.

No hidden spreads. No subscription fees. You pay only when your agent transacts.

Operation API Fee Notes
BTC address & balance Wallet API Free No charge for reads
Send BTC on-chain Wallet API 0.5% + network fee Network fee passed through at cost (sat/vB). Native SegWit minimises vbytes.
BTC cross-chain swap Wallet API 0.75% Includes bridge fee. Slippage protection on all routes.
BTC-USD / BTC/USDC perp — maker Trading API 0.01% Hyperliquid maker rebate partially offset against Purple Flea fee
BTC-USD / BTC/USDC perp — taker Trading API 0.04% Market orders and aggressive limit orders
Account registration Both Free No KYC, no monthly cost

Non-custodial, by design.

Purple Flea never holds your Bitcoin. All BTC wallets are derived from a BIP32 HD seed that only you control.

BIP32 HD Derivation

Your BTC address is derived at path m/84'/0'/0'/0/0 from a 24-word BIP39 mnemonic generated at registration. You own the mnemonic — you own the funds.

Self-Recovery Guaranteed

Any standard BIP84 wallet (Sparrow, Electrum, hardware wallets) can recover your funds from the mnemonic alone, with no dependency on Purple Flea remaining operational.

Encrypted Key Storage

Private keys are stored AES-256 encrypted at rest. Decryption occurs only in ephemeral memory at transaction signing time and is never logged or cached.

On-Chain Balance Verification

Use mempool.space to independently verify your confirmed BTC balance at any time. No trust required beyond Bitcoin itself.

BIP32 derivation overview
# Your mnemonic (24 words) — you keep this secret # Stored encrypted; exportable from wallet.purpleflea.com mnemonic = "abandon abandon abandon ... art" # HD wallet derivation paths # Bitcoin (native SegWit, BIP-84) btc_path = "m/84'/0'/0'/0/0" # Ethereum / EVM eth_path = "m/44'/60'/0'/0/0" # Solana sol_path = "m/44'/501'/0'/0'" # Tron trx_path = "m/44'/195'/0'/0/0" # All addresses come from the same seed — # one mnemonic, six chains, zero custody. # Recovery: import mnemonic into any # BIP32/BIP84-compliant wallet to access BTC. # Sparrow, Electrum, Ledger, Trezor all work.

Purple Flea derives all wallet addresses from a single BIP39 mnemonic. The Bitcoin address uses the BIP-84 derivation path for native SegWit. You can export your mnemonic from the dashboard and verify addresses independently.


Explore more APIs.

Your agent deserves
a Bitcoin stack.

Native BTC wallet. 50x perp leverage. Cross-chain swaps to any major asset. One API key. No KYC.