Skip to main content
The REST API is the default integration path. Public, no auth, per-IP rate limit (currently 240 requests a minute per IP, see the RateLimit-Limit header). The dashboard and embed widget read through it. Base URL: https://api.pegana.xyz

Endpoints at a glance

The full schema lives in the API Reference.

Stability contract

The v1 read surface is a stable, versioned contract you can wire a risk engine against. Going forward we make only additive changes within v1 — new fields (such as risk_score) and new endpoints — never a breaking rename or removal; any future breaking change would ship under a new prefix (v2) with v1 left working.
One-time reshape (2026-07-24). Before the first external integration, v1 had a single coordinated cleanup to the shapes documented here — lists gained the { ok, generated_at, count, data } envelope, the peg feed became a data array, and a few fields were renamed (as_of→updated_at, model_note/note→advisory_note, positions_affected→positions). See the changelog for the migration. The additive-only promise above holds from that point on.
Open-source release (2026-10-20): authenticated surfaces removed. When Pegana became open source and free, everything that required an account went away with the accounts: GET /v1/alerts, /v1/me/* and /v1/auth/* were removed from v1 and now return 404 not_found. This was a removal without a v2 prefix or a Sunset period, which is an exception to the promise above. The public transition ledger that replaces GET /v1/alerts is GET /v1/audit. See the changelog for the migration. No other v1 endpoint or field changed. See the 2026-10-22 open-core entry in the changelog: the methodology, verifier and SDKs stay MIT; current service code is FSL-1.1-MIT, and the website is proprietary.
Poll /v1/assets/{symbol}/state as often as your logic needs (limit: 240 requests a minute per IP, see the RateLimit-Limit header); it is the same object the dashboard and embed widget read, so it never disagrees with what a human sees on the site.
Pegana is purely observational — it classifies and proves, and never touches your contracts or parameters. Reading Pegana adds no actuation and no new attack surface to your protocol; you keep full control of any response.

Response format

Two wire conventions hold across every endpoint. They are part of the stability contract — values never change form in a breaking way.
  • Monetary & ratio values are exact decimal strings. discount, intrinsic_usd, market_usd, market_cap, loop_exposure_usd, sol_per_lst, worst_abs_24h, jitter_bps_24h and friends are JSON strings (e.g. "3.58235002", "-0.007405"), not floats — parse them with a decimal/BigNumber library so you never lose precision. Trailing zeros are trimmed, so the value is exact but compact.
  • USD aggregates are cent-rounded; signal fields keep full precision. Large USD totals (market_cap, loop_exposure_usd, liquidatable_usd, collateral_usd, collateral_lev_usd, debt_usd) are rounded to two decimals — sub-cent noise on a hundreds-of-millions figure is meaningless. discount carries 6 decimal places (the precision it is stored at), with one exception: on /v1/assets/{symbol}/history?bucket=1m each point is the average of the samples in that minute and is not re-rounded, so it can carry more digits (for example "0.0009515"). Only the USD price legs (intrinsic_usd, market_usd, …) keep full precision, up to 18 decimal places, so they carry the full peg signal.
  • discount_bps is the one numeric ratio. On /v1/peg/feed, discount_bps is discount × 10000 in basis points, a JSON number rounded to 4 decimal places (e.g. -74.05). It is a convenience for display; use the discount string for anything exact.
  • Timestamps are RFC3339 UTC, millisecond precision, Z suffix — e.g. 2026-07-24T15:33:14.545Z. Every *_at / ts / generated_at field uses this single form; parse with any RFC3339/Date parser. Resource freshness is always updated_at; the response’s own build time is generated_at.
  • Lists are enveloped; single resources are bare. These collection endpoints (/v1/assets, /v1/calibration, /v1/assets/{s}/history, /v1/peg/feed) wrap their rows in a uniform envelope so you always branch on the same shape and new top-level fields never break you:
    Read the rows from data. Single-resource endpoints (/v1/assets/{s}, /v1/assets/{s}/state, /v1/assets/{s}/loop-exposure, …) return the resource object itself (the Stripe/GitHub convention). One exception predates the envelope and stays as is within v1: the receipt ledger GET /v1/audit returns a bare JSON array of rows (see Pagination). Errors always carry a stable error code (see Errors).
Do not compare decimals or timestamps as exact byte strings — compare the parsed numeric value or instant. Two representations that differ only in trailing zeros or sub-millisecond precision are the same value.

Read one asset’s state

This is the single most-used endpoint. It returns the current peg state with the two underlying values. Use it for dashboards, pre-flight checks, automation gates.

Risk score

risk_score (present on /v1/assets, /v1/assets/{symbol} and /v1/peg/feed, not on /state) is a derived 0–100 integer for integrators who want a single sortable / thresholdable value — if risk_score >= 75 { gate_market() } — alongside (never replacing) the authoritative state. It is anchored to the committed state, so it can never disagree with the classification: Within each band the score interpolates by the effective, direction-sensitive discount magnitude (a benign premium on an LST / yield token scores ~0). It is null whenever the state is UNKNOWN/absent, there is no fresh discount, or the asset uses collateral-ratio thresholds (hyUSD) — Pegana never fabricates a number it does not have. The score is a pure, deterministic function of the other published fields, so you can recompute it yourself; it is a projection of the verifiable classification, not a separate input and not part of any receipt hash.

List all assets

Returns the list envelope { ok, generated_at, count, data } where data is an array of AssetCard objects with optional series_24h (hourly avg discount). Filter by class or peg query params. class is a case-sensitive exact match — valid values are lst, stable_fiat, stable_dn, stable_cdp, stable_yield, and stable_fx. An unknown value (e.g. stablecoin) returns an empty data array with HTTP 200.

Asset history

  • bucket=raw — discount snapshots as recorded by the engine. Limited to the last 7 days and a window of at most 7 days; anything older or wider returns 400 invalid_range (use bucket=1m for longer ranges)
  • bucket=1m — 1-minute aggregate (use for charts; smaller payload)
  • from, to — ISO 8601 timestamps; default last 24h
  • limit — clamped 1–5000, default 500. When the window holds more rows, the response carries truncated: true, next_from and next_to; pass from=<next_from>&to=<next_to> for the next, older page (see Pagination & limits)

Systemic impact (Loop Intelligence)

A depeg rarely breaks in isolation — it breaks the leverage stacked on top of it. These endpoints answer “how much leveraged collateral rides on this asset across Solana lending, and how much of it would be liquidated if the asset depegs?” — a cross-protocol view no single lending dashboard shows.
Everything here is an advisory model estimate: not a verifiable receipt. It is namespaced away from the peg fields and carries its own advisory_note. It is anonymous by construction: only k-anonymised distributions are computed (a band with fewer than 5 positions, or one dominated by a single position, is suppressed), and no wallet, owner or authority is ever read. Coverage today spans Kamino + Jupiter Lend — read the numbers as an honest floor, not a ceiling.

Exposure and cascade

GET /v1/assets/{symbol}/loop-exposure
Example response, fetched live on 2026-10-20 (the numbers change continuously; treat them as illustrative):
cascade carries the whole depeg ladder in one call — liquidatable_usd is the leveraged collateral crossing a liquidation threshold at each preset shock (in bps). positions is a k-floored range, never a raw count. The array is empty (or the object omitted) when the asset carries no tracked leverage. The cascade is built only from health-factor bands written in the last 3 hours (the enumerators run hourly). cascade_updated_at is the timestamp of the oldest band used, separate from updated_at (the freshest exposure row). When no band is that fresh, the cascade is empty and simulate-depeg returns coverage: "unknown", rather than serving an old cascade under a current timestamp.

Single shock

GET /v1/assets/{symbol}/simulate-depeg
shock_bps must be one of {100, 250, 500, 1000, 2000} (a fixed grid — continuous sweeps are refused so the anonymised distribution can’t be differenced). Returns the same estimate as one cascade rung, plus a by_protocol breakdown. coverage is partial whenever risky bands were privacy-suppressed (the honest default). When no health-factor band is fresh, coverage is unknown, liquidatable_usd and positions are null, and by_protocol is empty. null means the cascade is not known; it does not mean nothing would be liquidated. A real zero is the string "0" under coverage: "partial".

Partner feed

GET /v1/peg/feed The batch feed carries the full peg signal for every active asset as a data array (each signal carries its own mint), including an optional systemic block — the same exposure + cascade, packaged for a token page. The global methodology version is stamped once on the envelope, not on every signal:
Index data[] by each signal’s mint. systemic is omitted (not null) when the token carries no tracked leverage, and it never mixes into the verifiable peg fields (state, discount, receipt_url). Each signal also carries discount_bps (a JSON number rounded to 4 dp, see Response format); state is always present: with no fresh snapshot it reads UNKNOWN and stale is true (the same asset shows state_reason: stale_source on /v1/assets). The feed supports conditional GETs (ETag / If-None-Match → 304), so high-volume pollers stay cheap.

Why a state reads UNKNOWN

When an asset’s state is UNKNOWN, state_reason says why (on /v1/assets, /v1/assets/{symbol}/state and the WebSocket feed): market_reference_divergence, depth_below_floor and premium_hold_timeout come from guards that are off by default. market_unavailable can appear without any guard when the market feed has gone quiet, and the engine can also emit it when its dark-market guard (off by default) is switched on. Treat any state_reason you do not recognise as “state unknown, reason new”.

Audit receipts

Every state transition gets a public receipt. GET /v1/audit lists them (newest first), GET /v1/audit/{alert_id} returns one receipt with its methodology version and frozen inputs, GET /v1/audit/{alert_id}/replay-bundle downloads the inputs for offline replay, and GET /v1/audit.csv exports a window as CSV. GET /v1/audit/{alert_id} answers 200 with the receipt, 202 while the receipt is still being persisted (retry after retry_after_seconds), 410 if persistence failed permanently, and 404 for an unknown id. On-chain anchors. Transitions into DEPEG, CRITICAL or BLACK_SWAN are additionally anchored on Solana with an SPL Memo commit when the operator has on-chain commits enabled (ADR-0004). DRIFT transitions and recoveries are never anchored, and some historical severe receipts carry no anchor because on-chain commits were disabled when they fired. Read onchain_tx_sig on the ledger row, or call GET /v1/audit/{alert_id}/onchain, which returns the signature or a 404 whose error says why there is none (see Errors). Receipts produced under methodology 0.4.0 or later, anchored or not, can be re-derived offline with pegana-replay. Older receipts predate the first published verifier; check their hash in the browser at https://www.pegana.xyz/audit/{alert_id}.

Pagination

We do not paginate /v1/assets (a few dozen rows). /v1/assets/{symbol}/history is windowed with from / to and limit. /v1/audit is paged with a keyset cursor (before + before_id, max 100 rows per page): pass the last row’s detected_at and id to get the next, older page. since / until bound the window but are not a cursor. Full walkthrough in Pagination & limits.

Errors

We return standard HTTP status codes: Error bodies are {"error": "...", "message": "..."} (plus an optional asset) — short, machine-readable. Branch on error, never on message. Errors from the /v1/audit routes may carry hint or route-specific fields instead of message. The full code list is in Errors.

CORS

https://pegana.xyz, https://www.pegana.xyz, and http://localhost:3000 are allowed by default. Add more origins via the CORS_EXTRA_ORIGINS env var on self-hosted instances.

Rate limit

Per-IP sliding-window: currently 240 requests a minute per IP (see the live RateLimit-Limit header; check it rather than hard-coding). The window is 60 seconds. /v1/audit.csv is stricter at 10 req/min. GET /healthz is exempt; GET /readyz has its own 30 req/min per-IP budget (responses are cached for 2 s, so faster polling gains nothing). Every response carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (mirrored as X-RateLimit-*), and a 429 adds Retry-After. See rate limits. Need more? Contact rafael@pegana.xyz.

Authentication

None. The API is public: no key, no sign-in, no token. See authentication.

Next

WebSocket stream

Live push of every peg reading, instead of polling.

API Reference

Full OpenAPI spec with try-it-now.