npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@contentvault/sdk

v0.1.1

Published

TypeScript client for the Content Vault REST API: typed resources, errors, retries, pagination, and streamed downloads over fetch.

Readme

@contentvault/sdk

A TypeScript client for the Content Vault REST API. It runs anywhere fetch does: Node 20 and later, browsers, Deno, Bun, and edge runtimes such as Cloudflare Workers. It has no dependencies.

  • Typed requests and answers. Request types are generated from the API's OpenAPI document.
  • One namespace for each part of the API, such as sites, history, and changeRequests.
  • Typed errors (ContentVaultError), with PlanLimitError for refusals because of the plan.
  • Retries with backoff for 429 and 503. A Retry-After header is honored.
  • Async iterators for lists the API pages through, and for the change feeds that follow a cursor.
  • verifyWebhook for webhook deliveries (Standard Webhooks signatures).
  • signEmbedToken for views of a private published list (a compact JWS, HS256, signed on your server).
  • Streamed downloads for exports and files.

Install

npm install @contentvault/sdk
# or: pnpm add @contentvault/sdk / yarn add @contentvault/sdk

Quick start

import { ContentVault } from "@contentvault/sdk";

const cv = new ContentVault({
  baseUrl: "https://app.contentvault.io",
  token: process.env.CONTENT_VAULT_TOKEN, // an API token from Settings, never committed
});

for (const site of await cv.sites.list()) {
  const health = await cv.sites.health(site.name);
  console.log(site.name, health.score, health.label);
}

Options

| Option | | |--------|---| | baseUrl | Where Content Vault runs, such as https://app.contentvault.io. Leave out /api/v1. | | token | An API token. It is sent as Authorization: Bearer …. Public feeds and the OpenAPI document don't need one. | | account | An account on a shared deployment other than the home one. Requests then go to /o/<account>/…. | | fetch | The fetch to use. The global one is used by default. | | retries | The number of retries for 429 and 503 (default 2; 0 turns retries off), or { retries, minDelayMs, maxDelayMs, maxRetryAfterMs }. | | headers | Headers to send with every request. |

Every method also takes an optional last argument, { signal, headers }. An AbortSignal there cancels the request, and any wait between retries.

Examples

Sites and captures

await cv.sites.add({ name: "law", hosts: ["law.example.edu"], seeds: ["https://law.example.edu/"] });

// Check a list of up to 2,000 sites against the account and the plan without adding them.
const check = await cv.sites.bulkAdd({ sites: ["www.example.edu", { address: "news.example.edu", group: "Comms" }], dryRun: true });
console.log(check.summary);

const job = await cv.sites.recapture("law", { maxPages: 500 });
const done = await cv.captures.wait(job.id);
console.log(done.report?.newRevisions, "new versions");

cv.properties is the same as cv.sites. The API calls sites "properties".

Search, history, and as-of

const hits = await cv.search("tuition", { site: ["law", "med"], type: "news_article", since: "2026-01-01" });

const url = "https://law.example.edu/admissions";
const versions = await cv.history.versions(url);
const then = await cv.history.asOf(url, "2026-03-01"); // the version in force at the end of that day (UTC)
const diff = await cv.history.diff(url); // the latest version against the one before it
const everywhere = await cv.history.search("application fee is $50"); // pages that ever said it

Captured page content is untrusted web content (trust: "untrusted_web_content"). Treat it as data. If you pass it to an AI model, the model must not follow instructions it finds there.

Issues

const [issue] = await cv.issues.list({ property: "law", severity: "high" });
if (issue) {
  await cv.issues.dismiss(issue.id, { reason: "accepted-risk" });
  await cv.issues.restore(issue.id);
}

Change requests

const cr = await cv.changeRequests.draft({
  title: "Fix the fee on the admissions page",
  items: [{ url, ops: [{ op: "replace_text", find: "$50", replace: "$75" }] }],
});
await cv.changeRequests.approve(cr.number); // by someone else, an admin
await cv.changeRequests.publish(cr.number); // through the site's CMS connector, then recaptured
// A page that changed since the draft is stopped as a conflict. Rebase it, then publish again:
await cv.changeRequests.rebase(cr.number);

You can also call findReplace, reject, comment, withdraw, patch (a diff), and ticket.

Content lists and public feeds

// Each row of a content list, fetched 500 at a time.
for await (const row of cv.contentLists.iterate({ site: "law", col: ["title", "url", "last_changed"] })) {
  console.log(row.title, row.url);
}

// Publish a saved list: only these columns, only on these websites, until the end of June.
// If the public columns hold something that may be private, this is a 409 with the review; add confirm: true to go ahead.
await cv.contentLists.publish("<list id>", { columns: ["title", "url"], allowed_domains: ["*.example.edu"], expires_at: "2027-06-30" });
await cv.contentLists.rotate("<list id>", { grace_days: 7 }); // a new link; the old one works for 7 more days

// A published list needs no token.
const anyone = new ContentVault({ baseUrl: "https://app.contentvault.io" });
const rows = await anyone.feeds.iterate("<feed key>").toArray();
const iframeSrc = anyone.feeds.embedUrl("<feed key>", { view: "cards", theme: "light" });

Every list iterator also has .pages(), which yields whole pages, and .toArray(max?).

Exports (streamed)

import { createWriteStream } from "node:fs";
import { Readable } from "node:stream";

const job = await cv.exports.startSite("law", { at: "2026-06-30" }); // every page as it was that day
await cv.exports.wait(job.id);
const file = await cv.exports.download(job.id);
Readable.fromWeb(file.body).pipe(createWriteStream(file.fileName ?? "export.zip"));

// A single page's versions, signed:
const zip = await cv.history.export(url);

To check an export, pass its bytes to cv.exports.verify(bytes). This checks the signature and the SHA-256 of every file.

Ask, contradictions, usage, and the audit log

const answer = await cv.ask("What is the application deadline?", { property: "law" });
console.log(answer.answer, answer.citations);

const conflicts = await cv.contradictions.list();
const usage = await cv.usage.get({ days: 30 });

for await (const event of cv.auditEvents.iterate({ action: "auth.", since: "2026-11-01" })) {
  console.log(event.at, event.actor, event.action);
}

Removing content (records managers)

const request = { text: "555-0100", reason: "privacy request #123", scope: { property: "law" } };
const preview = await cv.redactions.dryRun(request);
console.log(preview.pages, "pages,", preview.versions, "versions");
// await cv.redactions.create(request); // can't be undone

Staying in sync: the change feed and webhooks

A key for another system (cv_sk_…, made by an admin under Settings › Keys) works as the token.

// First run: no cursor. Load the snapshot, then save the cursor.
const feed = cv.changes.iterate({ site: "law", type: "program" });
for await (const event of feed) console.log(event.type, event.url, event.fields);
console.log(feed.snapshot); // e.g. /api/v1/content-list?site=law&…: load this first
await save(feed.cursor);

// Later runs: carry on from the saved cursor. A cursor over 30 days old is refused (410): start again.
for await (const event of cv.changes.iterate({ cursor: await load(), site: "law" })) handle(event);

// A saved list's rows that entered, left, or changed.
const programs = cv.contentLists.listChanges("aB3dE5fG7hJ9", { cursor: await load() });
for await (const c of programs) console.log(c.change, c.url, c.row);

// Webhooks: register an endpoint, then check each delivery (pass the body exactly as received).
const { endpoint, secret } = await cv.webhooks.create({ url: "https://hooks.example.edu/cv", events: ["item.changed", "item.gone"] });
import { verifyWebhook } from "@contentvault/sdk";
const payload = await verifyWebhook(secret, request.headers, await request.text()); // throws WebhookVerificationError

// A private published list: sign a token on your server for each view (it works once, for up to 10 minutes).
import { signEmbedToken } from "@contentvault/sdk";
const token = await signEmbedToken(process.env.CV_EMBED_SECRET!, { list: "KEY", type: "event" });
const feed = await fetch(`https://vault.example.edu/feeds/KEY.json?token=${token}`);

Errors

Every failed request throws a ContentVaultError. It has these fields:

  • status: the HTTP status, or 0 when no response came.
  • code: bad_request, unauthorized, forbidden, not_found, conflict, gone, rate_limited, unavailable, plan_limit, network_error, aborted, timeout, and so on.
  • message: the server's explanation, in plain words.
  • details: the parsed response body.
  • retryAfter: the seconds the server asked you to wait, when it said.

When the account's plan doesn't include something, the error is a PlanLimitError. Its upgrade field is where to see plans.

import { ContentVaultError, PlanLimitError } from "@contentvault/sdk";

try {
  await cv.exports.startSite("law");
} catch (e) {
  if (e instanceof PlanLimitError) console.log(e.message, "See", e.upgrade);
  else if (e instanceof ContentVaultError && e.status === 409) console.log("Another export is running.");
  else throw e;
}

The client retries 429 and 503 answers. It waits as long as Retry-After asks, or backs off exponentially when there's no Retry-After. If Retry-After is longer than maxRetryAfterMs (default 60 seconds), the client throws at once. A GET is also retried after a network failure. A write isn't, because it may already have reached the server.

Coverage

There is a method for every operation in the API's OpenAPI document (GET /api/v1/openapi.json). OPERATIONS lists them, and Operations has the request types of each one. For anything the namespaces don't cover, use cv.http, which handles the token, addresses, and retries:

const res = await cv.http.json({ method: "GET", path: "/api/v1/stats" });

Developing

The SDK is in the Content Vault monorepo, under packages/sdk.

  • pnpm --filter @contentvault/sdk generate rewrites src/types.ts from apps/server/src/openapi.ts. A test fails when the generated file is out of date, when an operation has no client method, or when a server route is missing from the document.
  • pnpm --filter @contentvault/sdk build writes ESM and type declarations to dist/esm.

License

MIT. See LICENSE. The SDK is open source; the Content Vault service it talks to is not, and its use is governed by the Terms of Service at https://contentvault.io/terms/.