All articles
solanadataanalyticsapix402mcpai-agents

Top Ledger's API: decoded Solana data by key or by x402

Top Ledger exposes decoded Solana protocol data — DEX, lending, perps, LP, staking, yield — through an MCP server and a keyless x402 pay-per-call API at $0.0004/call. What it returns and how to call it.

Share

Most Solana data products start from the same painful place: raw transactions are an undifferentiated firehose, and turning them into "how much did this lending market earn this week" means decoding every program's instructions and accounts yourself. Top Ledger does that decoding as a business — it's the analytics and data layer behind dashboards used across the ecosystem, with the Solana Foundation, Metaplex, Helium, Drift, and Squads among the names on its wall.

What's new and worth a developer's attention is the Top Ledger API: the same decoded data, available two ways — an authenticated MCP/REST tier, and a keyless x402 pay-per-call endpoint at $0.0004 a call. That second model is the interesting one, so this piece covers what the API returns and both ways to reach it.

What the API actually returns

The value isn't raw bytes — it's decoded, per-protocol data. Top Ledger maintains a discriminator/decoding database across 20+ programs (Kamino, Drift, Jupiter, Raydium, Orca, Meteora, and more), so the endpoints speak in domain terms rather than account layouts. The surface is a small set of category readers plus a wallet view:

text
get_all_dex          — DEX activity (swaps, volume, pools)
get_all_lending      — lending markets (supply, borrow, rates)
get_all_perps        — perpetuals (open interest, positions, funding)
get_all_lp           — liquidity-provider positions
get_all_staking      — staking activity
get_all_yield        — yield / vault data
get_all_governance   — governance activity
get_all_rewards      — rewards / emissions
get_holdings         — wallet holdings (per-address view)

Underneath, Top Ledger also offers the heavier tiers of access — real-time account/ledger/pool/position feeds over WebSocket and Kafka, and full historical raw + decoded data in Parquet from the genesis block. The API above is the queryable, request/response slice of that, and the part you can wire into an app or an agent in minutes.

Two ways to call it

The same data sits behind two access models, and which you pick says a lot about what you're building.

1. API key — MCP and REST, with tiers

The keyed path is the conventional one: get a key, send it as x-api-key (or Authorization: Bearer), and call within your tier. Pricing is request-volume based:

text
Free        $0       50 req/min
Pro         $199     ~1M requests / month
Business    $799     ~20M requests / month

The most agent-friendly keyed surface is the MCP server, served over SSE at api.topledger.xyz/mcp/sse. Point an MCP client at it with your key and the get_all_* readers show up as tools your model can call directly:

json
{
  "mcpServers": {
    "topledger": {
      "url": "https://api.topledger.xyz/mcp/sse",
      "headers": { "x-api-key": "<your-key>" }
    }
  }
}

With no key, the SSE endpoint is explicit about it: 401 — Missing API key. Provide x-api-key header or Authorization: Bearer <key>. That's the keyed door. The other door needs no key at all.

2. x402 — keyless, pay per call

Top Ledger also fronts the data with an x402 gateway. There is no signup, no key, no dashboard — a request without payment comes back 402 Payment Required, the client pays $0.0004 in USDC on Solana, and the call goes through. The gateway lives under /pay/__402/ and you can prove it's up before spending a cent:

bash
$ curl https://api.topledger.xyz/pay/__402/health
ok

Settlement is the standard x402 flow: an x402-aware client wraps your HTTP library, catches the 402, signs the micro-payment with a Solana keypair, and retries — no human in the loop. The shape is identical to any other x402 resource (see the x402 seller and x402 + MCP pieces):

typescript
import { wrapFetchWithPayment } from "x402-fetch"
import { Keypair } from "@solana/web3.js"

const wallet = Keypair.fromSecretKey(/* agent's key */)

// fetch that auto-pays the 402 and retries — no API key anywhere
const payFetch = wrapFetchWithPayment(fetch, wallet)

const res = await payFetch("https://api.topledger.xyz/pay/__402/<endpoint>")
const data = await res.json()
// charged ~$0.0004 USDC for this single call

At $0.0004 a call, 2,500 calls cost a dollar. The exact paid paths are in the /api-docs; the point is the access pattern: an autonomous agent can buy a decoded slice of Solana state with a stablecoin and zero onboarding.

Why the combo matters

These two models cover the two real consumers of on-chain data:

  • A backend or dashboard making predictable, high-volume calls wants a flat monthly tier and a key — the Pro/Business path. You provision once and stop thinking about per-call cost.
  • An autonomous agent making unpredictable, occasional calls doesn't want a signup flow or a key it has to store and rotate. x402 lets it pay-as-it-goes with the same wallet it already uses for everything else — the data API becomes just another endpoint on the open internet it can transact with.

It's the same pattern showing up across the ecosystem: serve the humans with keys and tiers, serve the agents with x402. Top Ledger doing both over one data set is a clean example of where this is going.

The honest read

This is decoded analytics, not a raw indexer — you're buying Top Ledger's decoding and aggregation, which is the whole point but also the trust boundary: their discriminator DB and their definition of "volume" or "open interest" are what you get. For anything you'd settle money on, reconcile against the chain. Pricing is per call, not per row, so a single broad get_all_* read is one charge — cheap — but watch how much you pull per call rather than counting calls alone. And as with any hosted data layer, freshness and uptime are theirs, not yours; the /pay/__402/health check is there for a reason. For the vast majority of agent and dashboard use cases, paying Top Ledger to have already decoded 20+ protocols beats standing up your own Geyser pipeline.

References

Solana's hard problem was never storing data — it's decoding it. Top Ledger sells that decoding, and by putting it behind both an API key and an x402 meter, it's made the same data legible to a backend and purchasable by an agent.

Top Ledger's API: decoded Solana data by key or by x402 | devrels.xyz