Skip to main content

Documentation Index

Fetch the complete documentation index at: https://developer.alterscope.org/llms.txt

Use this file to discover all available pages before exploring further.

npm install @alterscope/sdk
import { AlterscopeClient, freshnessStatusOf } from "@alterscope/sdk";

const client = new AlterscopeClient({
  apiKey: process.env.ALTERSCOPE_API_KEY!,
  baseUrl: "https://dev.alterscope.org",
});

const oracle = await client.oracles.classify({ marketId: "morpho-usdc-lending" });
console.log("freshness", freshnessStatusOf(oracle));
import WebSocket from "ws";

const ws = new WebSocket("wss://dev.alterscope.org/v2/events", {
  headers: { Authorization: `Bearer ${process.env.ALTERSCOPE_API_KEY}` },
});

ws.on("open", () => ws.send(JSON.stringify({ action: "subscribe", types: ["oracle.stale"] })));
ws.on("message", (raw) => console.log(raw.toString()));
import crypto from "node:crypto";

export function verify(secret: string, body: Buffer, header: string): boolean {
  const parts = Object.fromEntries(header.split(",").map((part) => part.split("=", 2)));
  const expected = crypto.createHmac("sha256", secret).update(`${parts.t}.`).update(body).digest("hex");
  return crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected));
}
AlterscopeClient retries 429 and 5xx responses. Catch AuthenticationError, ForbiddenError, RateLimitError, and ServerError for explicit handling. Next: Pricing, Changelog, API Reference, Recipes.