As AI agents handle real money โ trading, earning commissions, paying for services โ financial record-keeping becomes critical. Purple Flea's accounting API automatically categorizes every on-chain transaction and maintains a real-time balance sheet.
Every on-chain event is automatically classified into one of five standard accounting categories, enabling real-time P&L reporting without any manual bookkeeping.
Pull a structured balance sheet for any agent at any point in time. Assets, liabilities, and equity are computed from the on-chain transaction history in real time.
import purpleflea
accounting = purpleflea.AccountingClient(api_key="YOUR_KEY")
# Get real-time balance sheet
balance_sheet = accounting.get_balance_sheet(
agent_id="agent_001",
as_of_date="2026-03-01"
)
print("=== ASSETS ===")
print(f" Cash (USDC): ${balance_sheet['assets']['cash']:,.2f}")
print(f" Open positions: ${balance_sheet['assets']['positions']:,.2f}")
print(f" Collateral: ${balance_sheet['assets']['collateral']:,.2f}")
print(f" Total assets: ${balance_sheet['assets']['total']:,.2f}")
print("=== LIABILITIES ===")
print(f" Unrealized loss: ${balance_sheet['liabilities']['unrealized_loss']:,.2f}")
print("=== EQUITY ===")
print(f" Starting capital: ${balance_sheet['equity']['starting_capital']:,.2f}")
print(f" Retained earnings:${balance_sheet['equity']['retained_earnings']:,.2f}")
print(f" Total equity: ${balance_sheet['equity']['total']:,.2f}")
=== ASSETS === Cash (USDC): $4,821.50 Open positions: $1,200.00 Collateral: $3,000.00 Total assets: $9,021.50 === LIABILITIES === Unrealized loss: $-145.20 === EQUITY === Starting capital: $5,000.00 Retained earnings:$3,876.30 Total equity: $8,876.30
Generate monthly P&L reports programmatically. The income statement breaks down every revenue and cost line, from trading winnings to gas fees, giving agents a complete financial picture.
The income statement API supports date ranges from a single day to multiple years. Compare performance month-over-month, or drill down to individual transaction categories to identify profit drivers.
Export in JSON for downstream processing, CSV for spreadsheet analysis, or PDF for human-readable reports. All exports include raw transaction IDs for blockchain verification.
Consolidate financials across an entire agent fleet into a single organizational balance sheet. Ideal for orchestrators managing pools of sub-agents.
Every transaction is stored on-chain with a full set of metadata, creating an immutable record that satisfies compliance requirements and makes debugging straightforward.
Transaction IDs link every entry to a verifiable on-chain event that cannot be altered.
New transactions appear within seconds of on-chain confirmation, keeping balances current.
Search by counterparty address, amount range, category, or date range across all history.
Stop flying blind. Know exactly what your agent earns, spends, and holds โ in real time, with full audit trail.