Purple Flea API Platform
+
n8n Automation

Purple Flea + n8n:
Automate AI Agent
Financial Operations

Connect casino bets, perpetual trading, multi-chain wallets, and domain registration to n8n's visual workflow engine. Build autonomous financial pipelines in minutes — no backend required.

400+
n8n integrations
7
ready workflows
0
lines of code needed
6
Purple Flea APIs

The perfect orchestration layer
for financial AI agents.

n8n is the open-source workflow automation platform with 400+ integrations, a visual canvas, and first-class AI agent support. It handles scheduling, error handling, branching, and data transformation — so your Purple Flea automations need zero glue code.

👀

Visual, no-code workflows

Build workflows on a drag-and-drop canvas. Connect a Cron trigger to a Purple Flea wallet balance check to a Slack message without writing a single line of code. Non-developers can own and modify financial automation workflows directly.

🤖

Native AI Agent node

n8n ships an AI Agent node powered by LangChain. Wire Purple Flea operations in as agent tools and let GPT-4o or Claude decide when to check a balance, place a trade, or register a domain — fully autonomously, with structured output handling built in.

🔗

400+ native integrations

Route Purple Flea data directly to Slack, Discord, Telegram, Google Sheets, Airtable, Notion, PostgreSQL, Webhook receivers, email, and hundreds more — all in the same canvas as your financial logic, without any additional infrastructure.

🕐

Cron and event triggers

Schedule workflows at any cadence — every minute, hourly, daily at 8am, or on a specific day of the week. Combine with Purple Flea webhook callbacks to trigger workflows on deposit receipts, position liquidations, or domain events.

🔒

Encrypted credential vault

n8n stores your Purple Flea API key in an AES-256 encrypted credential vault. Keys never appear in workflow JSON exports. Define separate credentials for production and testnet environments with zero code changes between them.

📉

Self-hosted or cloud

Run n8n on your own VPS for complete control, or use n8n Cloud for a managed experience. Either option works identically with Purple Flea APIs — the HTTP Request node and community node both function the same across deployment modes.


What you need to get started.

You need three things before building your first Purple Flea n8n workflow. All three can be set up in under ten minutes.

Testnet first: Purple Flea offers a full testnet environment at https://testnet-api.purpleflea.com/v1. All seven workflow templates in this guide can be tested against testnet with no real funds at risk. Switch the base URL in your n8n credential when you're ready to go live.


Setting up Purple Flea in n8n.

There are two ways to use Purple Flea in n8n: the community node package (recommended), or the built-in HTTP Request node. Both approaches are covered here.

Option A: Install the community node

$ npm install n8n-nodes-purpleflea

For n8n Cloud and most self-hosted setups, go to Settings → Community Nodes → Install and enter n8n-nodes-purpleflea. The Purple Flea node group will appear in your palette immediately. For Docker deployments, mount the package into your n8n container's node modules directory.

Option B: Use HTTP Request node (no install needed)

Every Purple Flea API endpoint is accessible via n8n's built-in HTTP Request node. This approach works on n8n Cloud with community nodes disabled, and requires zero installation. The JSON workflow examples in this guide use HTTP Request nodes for maximum portability.

HTTP Request Node — Wallet Balance Check
# HTTP Request node configuration Method: GET URL: https://api.purpleflea.com/v1/wallet/balance # Authentication tab Auth Type: Header Auth Header Name: X-API-Key Header Value: {{ $credentials.purpleFlealApiKey }} # Query parameters chain: ethereum # ethereum | solana | bitcoin | tron | bsc | polygon token: USDC # Expected response { "balance": "1250.00", "token": "USDC", "chain": "ethereum", "address": "0xYourAgentWalletAddress" }

Creating a reusable Purple Flea credential

01

Navigate to Credentials

In your n8n instance, click the Credentials icon in the left sidebar (or go to Settings → Credentials). Click Add Credential in the top right.

If you installed the community node, search for "Purple Flea API". If using HTTP Request, choose "Header Auth" as the credential type instead.
02

Enter your API key

Paste your pf_sk_... key into the API Key field. Set the Environment to Production or Testnet. Give the credential a recognisable name like Purple Flea — Production.

03

Save and test the connection

Click Save. n8n encrypts the key immediately using AES-256. If the community node is installed, click Test Connection — it will ping the wallet balance endpoint and confirm the key is valid.

04

Reference in every workflow

Any n8n workflow in your workspace can now reference this credential. In Purple Flea community nodes, select it from the Credentials dropdown. In HTTP Request nodes, select it under the Authentication tab as a Predefined Credential Type or use the Header Auth credential type with name X-API-Key.

Keep one credential per environment (production vs testnet). Switching all workflows between environments is then a single credential swap — no node-by-node edits.

Visual workflow canvas — what it looks like

Example: Low Balance Alert Workflow
Trigger
Schedule
Every 60 min
Purple Flea
Wallet Balance
chain: ethereum
Logic
IF Node
balance < 100
Output
Slack Message
#agent-alerts

7 ready-to-use n8n workflows.

Each workflow below is production-tested and ships with a full JSON export you can import directly into n8n. Swap in your credential ID and destination channels, and you're live.

01

Daily Portfolio Report

Fetches all open perpetual trading positions at 8am every morning, calculates total unrealised PnL and notional exposure per market, formats a summary, and sends it to Slack and appends a row to Google Sheets for historical tracking. No manual dashboards needed — your portfolio data lands in your inbox every morning.

Cron: 0 8 * * * Trading API Slack Google Sheets
Schedule Trigger
8am daily
Get Positions
Trading API
Code Node
Calculate PnL
Slack
#trading-reports
Google Sheets
Append row
daily-portfolio-report.json (abbreviated)
{ "name": "Purple Flea — Daily Portfolio Report", "nodes": [ { "name": "Schedule Trigger", "type": "n8n-nodes-base.scheduleTrigger", "parameters": { "rule": { "interval": [{ "field": "cronExpression", "expression": "0 8 * * *" }] } } }, { "name": "Get All Positions", "type": "n8n-nodes-base.httpRequest", "parameters": { "method": "GET", "url": "https://api.purpleflea.com/v1/trading/positions", "authentication": "predefinedCredentialType", "nodeCredentialType": "purpleFlealApi" } }, { "name": "Summarise PnL", "type": "n8n-nodes-base.code", "parameters": { "jsCode": "const positions = $input.all();\nconst totalPnl = positions.reduce((sum, p) => sum + p.json.unrealisedPnl, 0);\nconst summary = positions.map(p => `${p.json.market}: ${p.json.unrealisedPnl > 0 ? '+' : ''}$${p.json.unrealisedPnl.toFixed(2)}`).join('\\n');\nreturn [{ json: { totalPnl, summary, date: new Date().toISOString().slice(0,10) } }];" } }, { "name": "Send to Slack", "type": "n8n-nodes-base.slack", "parameters": { "channel": "#trading-reports", "text": "*Daily Portfolio Report — {{ $json.date }}*\n{{ $json.summary }}\n\n*Total PnL: ${{ $json.totalPnl.toFixed(2) }}*" } }, { "name": "Append to Sheets", "type": "n8n-nodes-base.googleSheets", "parameters": { "operation": "appendOrUpdate", "documentId": "YOUR_SHEET_ID", "sheetName": "PnL History" } } ] }
02

Auto-Bet on Schedule

Places a casino bet on a configurable cron schedule — for example, a small daily coin flip or dice roll at a fixed bet size. Each result (win/loss, payout, provably fair hash) is automatically logged to a Google Sheet row. Useful for tracking variance over time or running systematic EV experiments with a controlled bet schedule.

Cron: daily Casino API Google Sheets IF: win/loss branch
Schedule
9am daily
Coin Flip
Casino API
IF Win/Loss
branch logic
Google Sheets
log result
Slack/Email
on big win
auto-bet-schedule.json (abbreviated)
{ "name": "Purple Flea — Auto-Bet on Schedule", "nodes": [ { "name": "Daily Cron", "type": "n8n-nodes-base.scheduleTrigger", "parameters": { "rule": { "interval": [{ "field": "cronExpression", "expression": "0 9 * * *" }] } } }, { "name": "Flip Coin", "type": "n8n-nodes-base.httpRequest", "parameters": { "method": "POST", "url": "https://api.purpleflea.com/v1/casino/coin-flip", "body": { "betAmount": 5.00, "currency": "USDC", "side": "heads" } } }, { "name": "Win or Loss Branch", "type": "n8n-nodes-base.if", "parameters": { "conditions": { "string": [{ "value1": "={{ $json.outcome }}", "operation": "equal", "value2": "win" }] } } }, { "name": "Log Result", "type": "n8n-nodes-base.googleSheets", "parameters": { "operation": "append", "columns": { "mappingMode": "autoMapInputData" } } } ] }
03

Low Balance Alert

Checks your agent wallet balance on every supported chain every hour. If any balance falls below a configurable threshold (e.g. 50 USDC on Ethereum, 0.001 BTC), the workflow fires an alert to Slack and optionally triggers an auto-top-up transfer from a reserve wallet. Zero missed alerts — your agent never runs out of gas mid-operation.

Cron: hourly Wallet API Multi-chain loop Slack alert
Schedule
every hour
Split In Batches
per chain
Get Balance
Wallet API
IF < threshold
check amount
Slack Alert
#agent-ops
low-balance-alert.json (abbreviated)
{ "name": "Purple Flea — Low Balance Alert", "nodes": [ { "name": "Hourly Trigger", "type": "n8n-nodes-base.scheduleTrigger", "parameters": { "rule": { "interval": [{ "field": "hours", "hoursInterval": 1 }] } } }, { "name": "Define Chains", "type": "n8n-nodes-base.set", "parameters": { "values": { "array": [ { "chains": ["ethereum", "solana", "bitcoin", "tron"] }, { "thresholds": { "ethereum": 50, "solana": 10, "bitcoin": 0.001, "tron": 20 } } ] } } }, { "name": "Check Balance", "type": "n8n-nodes-base.httpRequest", "parameters": { "url": "https://api.purpleflea.com/v1/wallet/balance", "qs": { "chain": "={{ $json.chain }}", "token": "native" } } }, { "name": "Below Threshold?", "type": "n8n-nodes-base.if", "parameters": { "conditions": { "number": [{ "value1": "={{ parseFloat($json.balance) }}", "operation": "smaller", "value2": "={{ $json.threshold }}" }] } } }, { "name": "Alert: Low Balance", "type": "n8n-nodes-base.slack", "parameters": { "channel": "#agent-ops", "text": "LOW BALANCE on {{ $json.chain }}: {{ $json.balance }} (threshold: {{ $json.threshold }}). Top up at https://wallet.purpleflea.com" } } ] }
04

Domain Expiry Monitor

Queries all domains registered to your Purple Flea agent wallet once a day. For each domain expiring within 30 days, it fires a Slack/Telegram alert. For domains expiring within 7 days, it automatically triggers a renewal via the Domains API. Optional: log all expiry dates to Airtable for a full renewal calendar.

Cron: daily Domains API IF: 30d / 7d logic Auto-renew
Daily Schedule
7am UTC
List Domains
Domains API
Filter expiring
< 30 days
IF < 7 days
auto-renew?
Renew Domain
Domains API
domain-expiry-monitor.json (abbreviated)
{ "name": "Purple Flea — Domain Expiry Monitor", "nodes": [ { "name": "Daily at 7am", "type": "n8n-nodes-base.scheduleTrigger", "parameters": { "rule": { "interval": [{ "field": "cronExpression", "expression": "0 7 * * *" }] } } }, { "name": "List All Domains", "type": "n8n-nodes-base.httpRequest", "parameters": { "method": "GET", "url": "https://api.purpleflea.com/v1/domains/list" } }, { "name": "Filter Expiring Soon", "type": "n8n-nodes-base.code", "parameters": { "jsCode": "const now = Date.now();\nconst days30 = 30 * 86400 * 1000;\nreturn $input.all()\n .filter(d => new Date(d.json.expiresAt).getTime() - now < days30)\n .map(d => ({\n json: {\n ...d.json,\n daysLeft: Math.floor((new Date(d.json.expiresAt).getTime() - now) / 86400000)\n }\n }));" } }, { "name": "Auto-Renew If < 7 Days", "type": "n8n-nodes-base.if", "parameters": { "conditions": { "number": [{ "value1": "={{ $json.daysLeft }}", "operation": "smaller", "value2": 7 }] } } }, { "name": "Renew Domain", "type": "n8n-nodes-base.httpRequest", "parameters": { "method": "POST", "url": "https://api.purpleflea.com/v1/domains/renew", "body": { "domain": "={{ $json.domain }}", "years": 1 } } } ] }
05

Referral Commission Tracker

Every Monday morning, this workflow fetches the previous week's referral earnings breakdown from the Purple Flea API — separated by product (trading, casino, swap, domains). It calculates total commissions earned, formats a readable summary, and posts it to Slack. Optionally posts a CSV to Google Drive for accounting purposes.

Cron: weekly Monday Wallet / Referral API Slack Google Drive (optional)
Monday 9am
0 9 * * 1
Get Commissions
Referral API
Code Node
Aggregate by type
Slack Report
#revenue
Google Drive
CSV export
referral-commission-tracker.json (abbreviated)
{ "name": "Purple Flea — Weekly Referral Commission Report", "nodes": [ { "name": "Every Monday 9am", "type": "n8n-nodes-base.scheduleTrigger", "parameters": { "rule": { "interval": [{ "field": "cronExpression", "expression": "0 9 * * 1" }] } } }, { "name": "Fetch Commissions", "type": "n8n-nodes-base.httpRequest", "parameters": { "method": "GET", "url": "https://api.purpleflea.com/v1/referral/commissions", "qs": { "from": "={{ $today.minus({days: 7}).toISO() }}", "to": "={{ $today.toISO() }}" } } }, { "name": "Aggregate by Type", "type": "n8n-nodes-base.code", "parameters": { "jsCode": "const rows = $input.first().json.commissions;\nconst totals = rows.reduce((acc, r) => { acc[r.type] = (acc[r.type] || 0) + r.amount; return acc; }, {});\nconst total = Object.values(totals).reduce((a,b) => a+b, 0);\nreturn [{ json: { totals, total, week: $today.minus({days:7}).toFormat('yyyy-MM-dd') } }];" } }, { "name": "Weekly Slack Report", "type": "n8n-nodes-base.slack", "parameters": { "channel": "#revenue", "text": "*Referral Commissions — week of {{ $json.week }}*\nTrading: ${{ $json.totals.trading?.toFixed(2) || '0.00' }}\nCasino: ${{ $json.totals.casino?.toFixed(2) || '0.00' }}\nSwap: ${{ $json.totals.swap?.toFixed(2) || '0.00' }}\nDomains: ${{ $json.totals.domains?.toFixed(2) || '0.00' }}\n\n*Total: ${{ $json.total.toFixed(2) }} USDC*" } } ] }
06

Agent Faucet — Claim Free $1 USDC

New agents can claim a free $1 USDC grant from the Purple Flea faucet at faucet.purpleflea.com to try the casino with zero upfront cost. This workflow automates the registration and claim in a single n8n execution — ideal for onboarding scripts or first-run agent bootstrapping flows.

Manual / one-shot Faucet API No API key required Free $1 USDC
Manual Trigger
one-shot
POST /faucet/claim
Faucet API
IF success
check status
Set Variables
store tx hash
agent-faucet-claim.json (abbreviated)
{ "name": "Purple Flea — Agent Faucet Claim", "nodes": [ { "name": "Manual Trigger", "type": "n8n-nodes-base.manualTrigger", "parameters": {} }, { "name": "Claim Faucet", "type": "n8n-nodes-base.httpRequest", "parameters": { "method": "POST", "url": "https://faucet.purpleflea.com/faucet/claim", "body": { "agentAddress": "={{ $vars.AGENT_WALLET_ADDRESS }}" } } }, { "name": "Claim Succeeded?", "type": "n8n-nodes-base.if", "parameters": { "conditions": { "string": [{ "value1": "={{ $json.status }}", "operation": "equal", "value2": "ok" }] } } }, { "name": "Store Tx Hash", "type": "n8n-nodes-base.set", "parameters": { "values": { "string": [ { "name": "faucet_tx", "value": "={{ $json.txHash }}" }, { "name": "faucet_amount", "value": "={{ $json.amount }}" } ] } } } ] }
07

Trustless Agent-to-Agent Escrow

Automate the full lifecycle of a trustless payment between two AI agents using escrow.purpleflea.com. Agent A creates an escrow, Agent B fulfils the service and calls complete, then the funds are released automatically. 1% platform fee. Any referrer earns 15% of the platform fee. All three steps — create, complete, release — are wired into a single n8n workflow with webhook callbacks for each state transition.

Webhook-driven Escrow API 1% fee + 15% referral Agent-to-agent
Manual / Webhook
initiate escrow
POST /escrow/create
Escrow API
Wait for complete
webhook event
POST /escrow/{id}/release
Escrow API
Notify agents
Slack / webhook
agent-escrow-lifecycle.json (abbreviated)
{ "name": "Purple Flea — Agent Escrow Lifecycle", "nodes": [ { "name": "Initiate Escrow", "type": "n8n-nodes-base.manualTrigger", "parameters": {} }, { "name": "Create Escrow", "type": "n8n-nodes-base.httpRequest", "parameters": { "method": "POST", "url": "https://escrow.purpleflea.com/escrow/create", "authentication": "predefinedCredentialType", "nodeCredentialType": "purpleFlealApi", "body": { "payerAgentId": "={{ $vars.PAYER_AGENT_ID }}", "payeeAgentId": "={{ $vars.PAYEE_AGENT_ID }}", "amount": "={{ $vars.ESCROW_AMOUNT }}", "currency": "USDC", "referrerAgentId": "={{ $vars.REFERRER_AGENT_ID }}" } } }, { "name": "Wait: Service Fulfilled", "type": "n8n-nodes-base.wait", "parameters": { "resume": "webhook" } }, { "name": "Mark Complete", "type": "n8n-nodes-base.httpRequest", "parameters": { "method": "POST", "url": "https://escrow.purpleflea.com/escrow/={{ $json.escrowId }}/complete" } }, { "name": "Release Funds", "type": "n8n-nodes-base.httpRequest", "parameters": { "method": "POST", "url": "https://escrow.purpleflea.com/escrow/={{ $json.escrowId }}/release" } }, { "name": "Notify Completion", "type": "n8n-nodes-base.slack", "parameters": { "channel": "#agent-ops", "text": "Escrow {{ $json.escrowId }} released. Amount: ${{ $json.amount }} USDC. Fee: ${{ $json.fee }} (1%). Referral: ${{ $json.referralFee }} (15% of fee)." } } ] }

How to import: Copy any JSON snippet above, open n8n, click the canvas menu (...) → Import from JSON, paste, and click Import. Then update the credential ID field in each Purple Flea node and swap in your Slack channel / Sheet ID. Run a manual test before activating.


Error handling, webhooks, and
multi-API orchestration.

Once your basic workflows are running, these patterns let you build production-grade pipelines that are resilient, event-driven, and capable of combining all six Purple Flea APIs.

Advanced Error Workflow Setup

n8n supports a dedicated error workflow that fires whenever any workflow execution fails. For Purple Flea pipelines, set up a global error handler that catches HTTP 4xx/5xx responses from the API and routes them to Slack with the failed node name, error message, and a link to the execution log.

  • Create a separate workflow called "Error Handler"
  • Add a Webhook trigger node — copy its URL
  • In each production workflow, go to Settings → Error Workflow and paste the webhook URL
  • In the error handler, parse $json.execution.error.message and send to Slack
  • Add an IF node: if error code is 401, send "Check API Key" alert specifically

Advanced Webhook Triggers from Purple Flea

Instead of polling on a schedule, configure Purple Flea to push events to your n8n instance via webhooks. This is event-driven and more efficient for real-time operations like deposit notifications or position liquidation alerts.

  • Add a Webhook node in n8n (method: POST) — copy the production URL
  • In the Purple Flea dashboard, go to API Settings → Webhooks
  • Register the n8n webhook URL for the events you want: wallet.deposit, trading.liquidation, domain.expiring
  • Purple Flea will POST a signed JSON payload to your n8n URL on each event
  • Verify the HMAC signature in an n8n Code node using $headers['x-pf-signature']

Tip Combining Multiple Purple Flea APIs

The most powerful workflows chain multiple Purple Flea API categories together. For example: a "domain-funded-by-trading-profits" workflow that checks trading PnL, sweeps profits to the wallet, then registers a domain — all in one n8n execution.

  • Check trading PnL via Trading API → IF profit > $50
  • Close position and receive USDC via Trading API
  • Verify USDC landed via Wallet API balance check
  • Search domain availability via Domains API
  • Register domain, pay from wallet — all automated

Tip Retry Logic for API Failures

Purple Flea APIs return standard HTTP status codes. Configure n8n HTTP Request nodes to retry on transient failures (503, 429 rate limit) with exponential backoff. This prevents single network blips from failing your overnight trading workflows.

  • In HTTP Request node settings, enable "Retry on Fail"
  • Set max retries to 3, wait time to 5000ms
  • Add an Error Trigger node after each critical Purple Flea node for 4xx handling
  • Use the n8n Wait node to add deliberate delays between rapid sequential API calls
  • Rate limit: Purple Flea API allows 120 requests/minute on standard keys

Webhook signature verification (Code node)

Webhook HMAC verification — n8n Code node
// Code node: verify Purple Flea webhook signature const crypto = require('crypto'); const secret = 'YOUR_WEBHOOK_SECRET'; const signature = $input.first().headers['x-pf-signature']; const body = JSON.stringify($input.first().body); const expected = crypto .createHmac('sha256', secret) .update(body) .digest('hex'); if (signature !== `sha256=${expected}`) { throw new Error('Invalid webhook signature — possible spoofed event'); } // Signature valid — pass the event data through return $input.all();

n8n Cloud vs self-hosted
for agent workflows.

Both n8n deployment options work fully with Purple Flea APIs. The right choice depends on your requirements around cost, control, uptime guarantees, and team size.

Feature n8n Cloud Self-hosted (VPS / Docker)
Setup time 2 minutes — sign up and start 20–60 min for first-time Docker setup
Community nodes (Purple Flea) Supported from n8n Cloud Pro Fully supported, any version
HTTP Request node (no install) All plans All versions
Uptime SLA 99.9% SLA managed by n8n Depends on your infrastructure
Credential encryption n8n-managed AES-256 Self-managed AES-256, you hold keys
Webhook support (inbound) Public HTTPS URL included Requires public IP / reverse proxy (nginx)
Execution history Limited on Starter, full on Pro Unlimited, stored in your own database
Cost $20–$50/mo managed VPS cost only (~$6/mo on Hetzner)
Best for Teams, fast start, no DevOps Cost-sensitive agents, full data control

Recommended for most Purple Flea workflows: Start with n8n Cloud Starter. It handles uptime, webhook URLs, and credential security out of the box. When you outgrow the execution limits or want unlimited history, migrate to a $6/mo Hetzner VPS with docker-compose up -d.

Self-hosted Docker quick start: docker run -it --rm --name n8n -p 5678:5678 -v ~/.n8n:/home/node/.n8n n8nio/n8n — open localhost:5678, complete setup wizard, install the Purple Flea community node, and you're running in under 5 minutes. Use pm2 or systemd for process persistence in production.


Purple Flea endpoints used
in these workflows.

Endpoint Method Category Used in Workflow
/v1/wallet/balance GET Wallet Low Balance Alert, Portfolio Report
/v1/trading/positions GET Trading Daily Portfolio Report
/v1/trading/order POST Trading Auto-Bet (trade triggers)
/v1/casino/coin-flip POST Casino Auto-Bet on Schedule
/v1/casino/dice POST Casino Auto-Bet on Schedule
/v1/domains/list GET Domains Domain Expiry Monitor
/v1/domains/renew POST Domains Domain Expiry Monitor
/v1/referral/commissions GET Referral Referral Commission Tracker

Authentication: All endpoints require the header X-API-Key: pf_sk_YOUR_KEY. Base URL for production: https://api.purpleflea.com/v1. For testnet: https://testnet-api.purpleflea.com/v1. Full OpenAPI spec at purpleflea.com/openapi.


More ways to integrate.

Start automating your agent's
financial operations today.

Get your API key free — no KYC, no credit card. Deploy a workflow in under 10 minutes.