Sending usage
Node.js SDK
Auth, batching and retries, in about seven lines.
3 min read
Install
npm install @pixeldata/nodeusage.ts
import { PixelData } from "@pixeldata/node";
const pixel = new PixelData({ key: process.env.PIXEL_KEY! });
await pixel.track({
event_id: crypto.randomUUID(),
event_type: "api_call",
timestamp: new Date().toISOString(),
account: "acct_orbitapi",
quantity: 1,
unit: "requests",
properties: { endpoint: "/v1/verify" }
});Calls are buffered and flushed on a timer or at 500 events, whichever comes first. Failed batches retry with backoff and are persisted across restarts.