Implementation:AI4Finance Foundation FinGPT Finogrid API Services
Appearance
| 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
- Repository: AI4Finance_Foundation_FinGPT
- Key Files:
- agent_ledger_api/main.py (Lines 1-65)
- ingress_api/main.py (Lines 1-52)
- ops_console/main.py (Lines 1-61)
- chain_watcher.py (Lines 1-216)
- intent_sweeper.py (Lines 1-153)
- middleware/payment_required.py (Lines 1-179)
- sdk/typescript/src/client.ts (Lines 1-272)
- Routers: agent_accounts.py, kya.py, micropay.py, payment_intents.py, topup.py, wallets.py, batches.py, onboarding.py, webhooks.py, agents_explorer.py, approvals.py, corridors.py, exceptions.py, ledger_explorer.py, mandates_console.py, search.py
- Schemas: agent_ledger_api/schemas.py, ingress_api/schemas.py
- Config: agent_ledger_api/config.py, ingress_api/config.py, ops_console/config.py
- Dependencies: agent_ledger_api/dependencies.py, ingress_api/dependencies.py
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