Skip to content

matsblocknode1957-oss/pegcheck-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pegcheck-js

Official JavaScript/TypeScript SDK for the PegCheck stablecoin monitoring API.

Monitor 19 stablecoins in real time — prices, peg deviations, depeg alerts, whale activity and on-chain history.

Installation

npm install pegcheck-js

Requires Node.js 18 or later (uses native fetch).

Quick start

import PegCheck from "pegcheck-js";

const client = new PegCheck("your-api-key");

// Get all 19 stablecoin prices
const coins = await client.getAllPrices();
console.log(coins);

// Check a single coin
const usdt = await client.getPrice("usdt");
console.log(usdt.price, usdt.status, usdt.deviation_bps);

// Is USDT depegged right now?
const depegged = await client.isDepegged("usdt");
console.log(depegged); // false

Get your API key at pegcheck.uk/developers.

API

new PegCheck(apiKey: string)

Creates a new client instance.

const client = new PegCheck("pc_live_xxxxxxxxxxxx");

getAllPrices(): Promise<CoinPrice[]>

Returns live prices, status and deviation for all 19 tracked stablecoins.

const coins = await client.getAllPrices();
// [
//   { slug: "usdt", name: "USDT", price: 1.0002, peg: 1.0, deviation_bps: 2, status: "Healthy", ... },
//   { slug: "usdc", name: "USDC", price: 0.9998, peg: 1.0, deviation_bps: -2, status: "Healthy", ... },
//   ...
// ]

getPrice(slug: string): Promise<CoinPrice>

Returns live data for a single coin.

const coin = await client.getPrice("usdc");
console.log(`USDC is ${coin.status} at $${coin.price}`);

Supported slugs: usdt, usdc, usds, ethena, pyusd, fdusd, rlusd, tusd, frax, gho, crvusd, lusd, usdp, usdd, mkusd, eurc, dola, alusd, bold


isDepegged(slug: string): Promise<boolean>

Returns true if the coin's current status is "Depeg".

if (await client.isDepegged("usdt")) {
  console.log("USDT has depegged!");
}

getCautionCoins(): Promise<CoinPrice[]>

Returns all coins currently in "Caution" status (1–2.5% from peg).

const caution = await client.getCautionCoins();
caution.forEach(c => console.log(`${c.slug}: ${c.deviation_bps} bps from peg`));

getDepeggedCoins(): Promise<CoinPrice[]>

Returns all coins currently in "Depeg" status (>2.5% from peg).

const depegged = await client.getDepeggedCoins();
if (depegged.length > 0) {
  console.log("DEPEGS DETECTED:", depegged.map(c => c.slug));
}

getWhaleActivity(): Promise<AlertsStatus>

Returns recent large on-chain transfers (≥$1M) and current alert status across all monitored coins.

const alerts = await client.getWhaleActivity();
console.log(`${alerts.whaleTransfers.length} whale transfers in the last 7 days`);

registerWebhook(url: string, events: WebhookEvent[]): Promise<Webhook>

Registers a webhook to receive real-time POST notifications for depeg, caution, and recovery events.

const webhook = await client.registerWebhook(
  "https://your-app.com/webhooks/pegcheck",
  ["depeg", "caution", "recovery"]
);
console.log(`Webhook registered: ${webhook.id}`);

Webhook payload:

{
  "event": "depeg",
  "coin": "usdt",
  "price": 0.9710,
  "peg": 1.0,
  "deviation_pct": -2.9,
  "triggered_at": "2026-01-15T09:00:00.000Z"
}

getHistory(slug: string, days?: number): Promise<HistoryPoint[]>

Returns price history for a coin. days defaults to 7, max 90.

const history = await client.getHistory("usdc", 30);
history.forEach(p => console.log(p.created_at, p.price, p.deviation_bps));

TypeScript types

import type {
  CoinPrice,
  CoinStatus,
  HistoryPoint,
  WhaleTransfer,
  WhaleAction,
  AlertsStatus,
  Webhook,
  WebhookEvent,
} from "pegcheck-js";

Error handling

All methods throw on API errors with a descriptive message and a status property:

try {
  const coin = await client.getPrice("usdt");
} catch (err) {
  if (err.status === 401) console.error("Invalid API key");
  if (err.status === 429) console.error("Rate limit exceeded");
  if (err.status === 404) console.error("Coin not found");
  console.error(err.message);
}

Links

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages