Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AI4Finance Foundation FinGPT Finogrid API Services

From Leeroopedia
Knowledge Sources
Domains API_Server, Fintech_Infrastructure, Payments
Last Updated 2026-10-18 00:00 GMT

Overview

Concrete tools for the Finogrid platform's FastAPI services: Agent Ledger API, Ingress API, and Ops Console API, plus their supporting middleware, chain watcher, intent sweeper, and TypeScript SDK.

Description

The Finogrid API services provide the HTTP layer for the payout platform:

  • Agent Ledger API (port 8100) — stablecoin micro-transaction service for AI agents. Endpoints: agent accounts, KYA, wallets, payment intents, micropay, topup, withdrawal. Includes x402 `PaymentRequiredMiddleware`.
  • Ingress API — v1 payout batch submission API. Routers: batches, onboarding, webhooks.
  • Ops Console API — operations dashboard. Routers: agents explorer, approvals, corridors analytics, exceptions, ledger explorer, mandates console, search.
  • Chain Watcher — Base L2 on-chain event processor. Job A: deposits → credit prefund balance. Job B: settlement sweep → promote off-chain to on-chain.
  • Intent Sweeper — lifecycle management for expired/refunded payment intents.
  • x402 Middleware — HTTP 402 payment wall protocol (Coinbase/Cloudflare standard).
  • TypeScript SDK — `FinogridClient` HTTP client for the Agent Ledger API.

Usage

Run these FastAPI apps to serve the Finogrid platform's HTTP endpoints. Import routers/schemas/config when extending individual services.

Code Reference

Source Location

Signature

# Agent Ledger API
app = FastAPI(title="Finogrid Agent Ledger API", version="1.0.0")
# Routers: /v1/agent-accounts, /v1/agent-accounts/{id}/kya, /v1/agent-accounts/{id}/wallets,
#          /v1/payment-intents, /v1/micropay, /v1/agent-accounts/{id}/topup, /v1/agent-accounts/{id}/withdraw

# Chain Watcher
async def watch_deposits(): ...
async def settlement_sweep(): ...

# Intent Sweeper
async def sweep_expired_intents(): ...

# x402 Middleware
class PaymentRequiredMiddleware(BaseHTTPMiddleware):
    async def dispatch(self, request, call_next): ...
// TypeScript SDK
class FinogridClient {
  constructor(config: FinogridClientConfig) {}
  async agents: { create(req): Promise<AgentAccountCreateResponse>; }
  async kya: { submit(agentId, req): Promise<KYAStatusResponse>; }
  async wallets: { create(agentId, req): Promise<AgentWalletCreateResponse>; }
  async paymentIntents: { create(req): Promise<PaymentIntentCreateResponse>; }
  async micropay: { pay(req): Promise<MicroPayResponse>; }
}

Import

from finogrid.services.agent_ledger_api.main import app as agent_ledger_app
from finogrid.services.ingress_api.main import app as ingress_app
from finogrid.services.ops_console.main import app as ops_console_app
from finogrid.services.agent_ledger_api.chain_watcher import watch_deposits
from finogrid.services.agent_ledger_api.intent_sweeper import sweep_expired_intents
from finogrid.services.agent_ledger_api.middleware.payment_required import PaymentRequiredMiddleware

I/O Contract

Inputs

Name Type Required Description
HTTP requests JSON Yes API endpoint payloads (Pydantic schemas)
on-chain events Transfer events Yes (watcher) USDC Transfer events on Base
expired intents DB records Yes (sweeper) Payment intents past expires_at

Outputs

Name Type Description
HTTP responses JSON API responses (Pydantic schemas)
balance credits DB updates Prefund balance increments (watcher)
402 responses HTTP 402 Payment-required wall (middleware)

Usage Examples

Start the Agent Ledger API

import uvicorn
from finogrid.services.agent_ledger_api.main import app

uvicorn.run(app, host="0.0.0.0", port=8100)

Use the TypeScript SDK

import { FinogridClient } from "@finogrid/sdk";

const client = new FinogridClient({
  baseUrl: "http://localhost:8100",
  apiKey: "fig_agent_xxx",
});

const agent = await client.agents.create({ name: "my-agent" });
await client.kya.submit(agent.agent_account_id, { agent_purpose: "trading" });

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment