@pythfeeds/sdk
v1.0.0
Published
Official JavaScript/TypeScript SDK for the PythFeeds API — real-time Pyth oracle prices, market data and live SSE streaming.
Maintainers
Readme
@pythfeeds/sdk
Official JavaScript/TypeScript client for the PythFeeds API — real-time Pyth oracle prices, market data and live streaming. Works in browsers and Node 18+.
Install
npm install @pythfeeds/sdkUsage
import { PythFeeds } from "@pythfeeds/sdk";
const pf = new PythFeeds("pf_live_xxx");
// Single price
const btc = await pf.getPrice("BTC");
console.log(btc.price, btc.confidence);
// Batch
const prices = await pf.getPrices(["BTC", "ETH", "SOL"]);
// Market data
const coins = await pf.getCoins({ page: 1, perPage: 50 });
const chart = await pf.getChart("bitcoin", 30);
const global = await pf.getGlobal();Live streaming (SSE)
const close = pf.stream(["BTC", "ETH"], (update) => {
console.log("tick", update);
});
// later: close();In Node, provide an EventSource first:
globalThis.EventSource = (await import("eventsource")).default;Errors
Failed calls throw PythFeedsError with .status and a stable .code (missing_key, invalid_key, rate_limited, quota_exceeded).
import { PythFeedsError } from "@pythfeeds/sdk";
try { await pf.getPrice("BTC"); }
catch (e) { if (e instanceof PythFeedsError && e.code === "rate_limited") { /* back off */ } }Rate limits & quota
Responses carry RateLimit-* (per-minute) and X-Quota-* (monthly) headers. See pythfeeds.com/pricing.
