DEV Community

roblambert9
roblambert9

Posted on

I built 11 payment-enabled AI APIs in 48 hours — here's exactly how

Last weekend I had $0 in online income. By Sunday evening I had
11 APIs running on the internet, each one charging other AI
agents $0.005 USDC per call automatically.

No employees. No store. No prior coding experience.

Here's exactly what I built and how.

The Problem I Was Solving

I'm building a Polymarket trading agent. It needed:

  • Real-time crypto sentiment data
  • Macro economic signals
  • Whale wallet movement data
  • Fear & greed composite index

I couldn't find a single clean, cheap API that did all of this
well. So I built it myself. Then I built 10 more.

The Tech Stack

Every agent uses the same stack:

Python + Flask — dead simple API framework
Railway.app — $5/month hosting, deploys from GitHub in minutes
NewsAPI — free tier for headline data
x402 protocol — Coinbase's open payment standard for micropayments
Base chain — Coinbase's L2, gas fees under $0.01

Total cost to build: $0
Monthly infrastructure: $50 for all 11 agents
Net ROI if they reach target traffic: 330x

The x402 Protocol — The Interesting Part

x402 is an open protocol released by Coinbase in 2025.
It lets HTTP endpoints request micropayments before serving data.

Here's how it works:

@app.route("/sentiment")
def sentiment():
    # Check if payment was made
    payment = request.headers.get("X-Payment", "")
    if not payment and PAYMENT_ENABLED:
        return jsonify({
            "error": "Payment required",
            "amount_usdc": 0.005,
            "wallet": YOUR_WALLET,
            "chain": "Base",
            "protocol": "x402"
        }), 402

    # Serve the data
    return jsonify(calculate_sentiment(ticker))
Enter fullscreen mode Exit fullscreen mode

When an AI agent calls the endpoint:

  1. Gets HTTP 402 Payment Required
  2. Pays $0.005 USDC to my wallet on Base chain
  3. Retries with the transaction hash in X-Payment header
  4. Gets the data

Zero humans involved. Zero invoices. Software paying software.

The 11 Agents I Built

  1. Crypto Sentiment Score — 0-100 score for BTC, ETH, SOL + 10 more
  2. Stock Sentiment Score — PLTR, TSLA, NVDA, ORCL + 20 more
  3. Polymarket Odds Aggregator — live prediction market odds by category
  4. Macro Signal Tracker — Fed stance, CPI, oil signals
  5. Whale Wallet Monitor — large BTC/ETH wallet movements
  6. Social Momentum Scorer — Reddit + news velocity
  7. DeFi Yield Tracker — best yields across Aave, Compound, Curve
  8. News Velocity Tracker — breaking news speed detection
  9. Fear & Greed Composite — combines all signals (premium)
  10. Analyst Price Targets — consensus targets for crypto + stocks
  11. Bundle API — all 10 signals in one call ($0.035 vs $0.050)

Deploying on Railway

Each agent deploys from GitHub in under 5 minutes:

# Procfile
web: gunicorn app:app --bind 0.0.0.0:$PORT

# requirements.txt
flask==3.0.3
requests==2.31.0
gunicorn==22.0.0
Enter fullscreen mode Exit fullscreen mode

Push to GitHub → Railway detects → deploys automatically.
Add 3 environment variables:

  • NEWSAPI_KEY
  • WALLET_ADDRESS
  • PAYMENT_ENABLED=true

Done. API is live and charging.

The Free Tier — Critical for Adoption

First version charged immediately. Zero developers tested it.

Version 0.3 added a free tier:

FREE_CALLS_PER_IP = 50

def check_access():
    ip = get_client_ip()
    count = free_tier_usage.get(ip, 0)
    if count < FREE_CALLS_PER_IP:
        free_tier_usage[ip] = count + 1
        return True  # Free
    return check_payment()  # Then paid
Enter fullscreen mode Exit fullscreen mode

50 free calls per IP. Developers test it risk-free.
By call 51 they've already integrated it.
Switching costs are too high. They pay.

Listing on RapidAPI

After deployment, listed all 11 on RapidAPI:

  • 1 million+ developers browse it
  • Free to list
  • Handles billing for subscription plans
  • Handles discovery in Finance category

Each listing took 5 minutes once I learned the flow.

The Business Model

11 agents × 10,000 calls/day × $0.005 = $500/day = $15,000/month
Infrastructure: $50/month
Net ROI: 300x
Enter fullscreen mode Exit fullscreen mode

Plus RapidAPI subscription plans ($9-99/month) for predictable revenue.

Why I'm Building This

My family is moving from Ottawa, Canada to Yucatán, Mexico by 2030.
This agent army is one piece of the financial independence plan.

Building publicly at @mexico2030dream.
Rocky the Pomsky supervises at @LifeOfFluff.


The full code is on GitHub: github.com/roblambert9/crypto-sentiment-api

Questions welcome in the comments.

— Robert

Top comments (0)