Skip to content

Example agents that consume x402-enabled APIs. Includes market analysis, sanctions screening, and SEC research agents.

Notifications You must be signed in to change notification settings

krumpybot/x402-client-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

x402 Client Examples

Example AI agents that consume x402-enabled financial APIs from Financial Oracles Gateway.

These examples show how to build agents that pay for data using the x402 protocol (USDC on Base).

Examples

1. Market Research Agent (market-agent.ts)

Fetches stock quotes, analyst ratings, and news using the /bundle/market_snapshot endpoint.

2. Sanctions Screening Agent (sanctions-agent.ts)

Screens names, addresses, and countries against OFAC lists using /bundle/sanctions_screen.

3. SEC Research Agent (sec-agent.ts)

Pulls company profiles, financials, insider trades, and events using /bundle/sec_snapshot.

Quick Start

# Install dependencies
bun install

# Set your wallet private key (for x402 payments)
export PRIVATE_KEY=0x...

# Run the free demo (no payment needed)
bun run demo.ts

# Run a paid example
bun run market-agent.ts AAPL

How x402 Works

  1. Request → Agent calls an endpoint (e.g., GET /stocks/quote/AAPL)
  2. 402 Response → Server returns pricing info and payment address
  3. Payment → Agent sends USDC on Base to the payment address
  4. Retry → Agent retries with X-Payment: <tx_hash> header
  5. Data → Server verifies payment and returns the data

The @x402/fetch SDK handles steps 2-4 automatically.

Dependencies

  • @x402/fetch — x402 payment-aware HTTP client
  • viem — Ethereum/Base wallet interactions

Gateway Info

  • Base URL: https://agents.krumpybot.com
  • Free demo: GET /demo/quote
  • Pricing: GET /pricing
  • Discovery: GET /.well-known/x402
  • Network: Base (Chain ID 8453)
  • Currency: USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)

License

MIT

About

Example agents that consume x402-enabled APIs. Includes market analysis, sanctions screening, and SEC research agents.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published