Bitcoin · BIP-39 · BIP-84 · Native Segwit

Bitcoin Wallet API for
Autonomous AI Agents

Generate BIP-84 native segwit (P2WPKH) Bitcoin addresses, check balances via mempool.space, manage UTXOs, and send BTC programmatically — no Bitcoin node required.

Get API Key → Full Wallet Docs
BIP-39 Mnemonics BIP-84 Native Segwit P2WPKH Addresses (bc1q...) mempool.space Balance UTXO Management Fee Estimation No Node Required

Bitcoin for AI Agents — Without Running a Node

Bitcoin is the oldest and most recognized digital asset, but it's also the most complex to integrate for programmatic use. Running a full Bitcoin node requires hundreds of gigabytes of storage, days of initial block download, and ongoing maintenance. Lightweight SPV clients require trust in a third-party server. For an AI agent that just needs to generate a wallet, receive BTC, check a balance, and occasionally send a transaction, both approaches are massive overkill.

Purple Flea's Bitcoin Wallet API abstracts the entire Bitcoin stack. Your agent makes standard REST calls and receives deterministic Bitcoin addresses derived from industry-standard BIP-39 mnemonics and BIP-84 derivation paths. The result is a native segwit address — one that starts with bc1q — which carries the lowest transaction fees of any Bitcoin address format, because the witness data discount applies fully to P2WPKH inputs.

Balance and UTXO data is sourced from mempool.space, the community-run Bitcoin explorer and API that is widely considered the most accurate real-time data source for Bitcoin state. The API returns both confirmed balance (from settled blocks) and unconfirmed mempool balance separately, so your agent can distinguish between funds it can spend immediately versus funds still awaiting confirmation.

For sends, the API constructs a transaction using the agent's UTXOs, applies fee-rate estimation based on current mempool conditions (sat/vByte), signs it server-side, and broadcasts it to the Bitcoin network. Your agent receives the transaction TXID in the response. Change outputs are automatically routed back to the same wallet address, maintaining a clean UTXO set.

BIP-84

Native segwit standard

bc1q

P2WPKH address format

sat/vB

Dynamic fee estimation

UTXO

Coin selection managed

10%

Referral commission

Full Bitcoin Wallet Capabilities

BIP-39 + BIP-84 Derivation

Bitcoin wallets use the BIP-39 mnemonic standard (12 or 24 words) with BIP-84 derivation path m/84'/0'/0'/0/0. This produces a native segwit P2WPKH address, identical to those generated by Electrum in "segwit" mode, Ledger, and Trezor. Your mnemonic is always the canonical recovery method.

P2WPKH Native Segwit Addresses

Native segwit (bech32) addresses starting with bc1q are the most fee-efficient Bitcoin address type. Transactions spending P2WPKH UTXOs are smaller on the wire than P2PKH (legacy) or P2SH-P2WPKH (wrapped segwit), resulting in lower fees at the same priority level.

Balance via mempool.space

Balance lookups call the mempool.space public API: GET /api/address/:address. The response separates confirmed balance (chain_stats.funded_txo_sum - chain_stats.spent_txo_sum) from unconfirmed mempool balance, so your agent always knows exactly what it can spend.

UTXO Management

The API exposes raw UTXO data — each unspent output with its TXID, vout index, value in satoshis, and confirmation count. When sending, the API applies largest-first coin selection by default, with an option for smallest-first (privacy-preserving) or manual UTXO specification for advanced agents.

Dynamic Fee Estimation

Fees are estimated using mempool.space's fee rate API, which provides sat/vByte recommendations for 1-block, 3-block, and 6-block confirmation targets. Your agent can choose priority (high/medium/low) or specify a custom sat/vByte rate. The API returns the estimated fee in both satoshis and BTC before broadcasting.

Server-Side Signing, No Node

Bitcoin transaction construction — UTXO selection, input signing with SIGHASH_ALL, output creation, change address routing — all happens server-side. Your agent never handles raw private keys or constructs raw transaction hex. Broadcast uses multiple Bitcoin network endpoints for reliability.

Bitcoin Wallet Endpoints

Use chain=bitcoin in all requests to route to the Bitcoin network.

POST /agent/register

Register a new agent. Pass "chain": "bitcoin" to receive a bc1q... P2WPKH address and BIP-39 mnemonic.

GET /wallet/balance?wallet_id=&chain=bitcoin

Returns confirmed balance (satoshis + BTC), unconfirmed mempool balance, total UTXO count, and mempool.space data timestamp.

GET /wallet/utxos?wallet_id=&chain=bitcoin

Returns the full list of UTXOs for the agent's Bitcoin address: TXID, vout, value in satoshis, confirmation count, and spendable flag.

POST /wallet/send

Send BTC to any valid Bitcoin address (bech32, P2SH, legacy). Specify amount in BTC (e.g. "0.001") and priority (high/medium/low). Returns TXID on broadcast.

GET /wallet/tx?tx_hash=&chain=bitcoin

Fetch transaction confirmation status: block height, number of confirmations, fee paid in satoshis, and TXID on mempool.space.

Python: Generate BTC Wallet, Check Balance, Send

Python — Generate Bitcoin Wallet
import requests

BASE_URL = "https://api.purpleflea.com"
API_KEY  = "pf_live_your_key_here"
HEADERS  = {"X-API-Key": API_KEY, "Content-Type": "application/json"}

# Register a Bitcoin wallet agent
resp = requests.post(
    f"{BASE_URL}/agent/register",
    headers=HEADERS,
    json={"name": "btc-agent-01", "chain": "bitcoin"}
)
data = resp.json()

wallet_id   = data["wallet_id"]
btc_address = data["address"]    # e.g. "bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq"
mnemonic    = data["mnemonic"]   # BIP-84 compatible — import to Electrum/Ledger

print(f"BTC Address (P2WPKH): {btc_address}")
print(f"Derivation Path:      m/84'/0'/0'/0/0")
# Send BTC to this address to fund the agent
Python — Check Bitcoin Balance (confirmed + mempool)
# Query confirmed and unconfirmed balances
balance = requests.get(
    f"{BASE_URL}/wallet/balance",
    headers=HEADERS,
    params={"wallet_id": wallet_id, "chain": "bitcoin"}
).json()

confirmed    = balance["confirmed"]
unconfirmed  = balance["unconfirmed"]

print(f"Confirmed:   {confirmed['btc']} BTC ({confirmed['satoshis']} sat)")
print(f"Unconfirmed: {unconfirmed['btc']} BTC")
print(f"UTXO count:  {balance['utxo_count']}")

# Get individual UTXOs for manual coin control
utxos = requests.get(
    f"{BASE_URL}/wallet/utxos",
    headers=HEADERS,
    params={"wallet_id": wallet_id, "chain": "bitcoin"}
).json()["utxos"]

for u in utxos:
    print(f"{u['txid'][:16]}... vout={u['vout']} value={u['value']} sat ({u['confirmations']} confs)")
Python — Send BTC with Fee Estimation
# Send 0.001 BTC with medium-priority fee (~3 blocks)
send = requests.post(
    f"{BASE_URL}/wallet/send",
    headers=HEADERS,
    json={
        "wallet_id": wallet_id,
        "chain": "bitcoin",
        "to": "bc1qRecipientAddress...",
        "amount": "0.001",      # in BTC
        "priority": "medium"   # "high" | "medium" | "low"
    }
).json()

print(f"TXID:        {send['tx_hash']}")
print(f"Fee rate:    {send['fee_rate_sats_per_vbyte']} sat/vB")
print(f"Fee total:   {send['fee_satoshis']} satoshis")
print(f"View on mempool.space: https://mempool.space/tx/{send['tx_hash']}")

# Poll for confirmation (Bitcoin: ~10 min per block)
import time
confirmed = False
while not confirmed:
    tx_status = requests.get(
        f"{BASE_URL}/wallet/tx",
        headers=HEADERS,
        params={"tx_hash": send["tx_hash"], "chain": "bitcoin"}
    ).json()
    if tx_status["confirmations"] >= 1:
        print(f"Confirmed! Block: {tx_status['block_height']}")
        confirmed = True
    else:
        time.sleep(60)  # check every minute

mempool.space Integration — Real-Time Bitcoin Data

Purple Flea uses mempool.space as the primary data source for Bitcoin balance and UTXO queries. mempool.space is an open-source Bitcoin explorer and API backed by multiple full nodes, offering real-time mempool visibility, accurate fee estimation, and UTXO data without the need for your own infrastructure.

For balance lookups, the API computes confirmed balance as chain_stats.funded_txo_sum - chain_stats.spent_txo_sum and unconfirmed balance as mempool_stats.funded_txo_sum - mempool_stats.spent_txo_sum. This matches what block explorers display and is accurate to the mempool's current state.

Fee estimation uses mempool.space's /api/v1/fees/recommended endpoint, which provides fastestFee, halfHourFee, and hourFee in sat/vByte. The Purple Flea API maps these to the high/medium/low priority options for simplicity.

Bitcoin in the Multi-Chain Wallet

The same BIP-39 mnemonic phrase that generates your agent's Bitcoin address also controls its Ethereum, Solana, Tron, Monero, and XRP addresses through the Purple Flea multi-chain wallet. A single POST /agent/register call creates wallets on all six chains simultaneously, or you can create chain-specific wallets as needed. See the full wallet API for multi-chain details.

Related APIs & Resources

No node. No complexity.

Give your agent a
Bitcoin wallet in minutes

BIP-84 native segwit, mempool.space balance, fee estimation, and programmable sends — no Bitcoin node, no blockchain SDK, just REST calls.

Get API Key → Read the Docs