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

@restlessai/sdk

v0.7.1

Published

Capture API traffic and send it to Restless. Works with Express, Fastify, Koa, Hono, Next.js, and the bare Node http server. Runs on Node, Bun, and Deno.

Readme

Run in your codebase to get started:

npx restless init

This scans your project, figures out your framework, generates an OpenAPI spec, and automatically wires the SDK into your server.

@restlessai/sdk

Capture your API traffic and send it to Restless.

Supports Express, Fastify, Koa, Hono, Next.js, and bare Node http. Runs on Node 18+, Bun, and Deno.

Manual installation

If you'd rather wire it up by hand:

npm install @restlessai/sdk
const restless = require('@restlessai/sdk')(process.env.RESTLESS_KEY);

app.use(restless.setup((req) => ({
  apiKey: restless.mask(req.headers.authorization),
  owner: {
    // `id` is permanent and immutable. Pick a stable internal identifier
    // (workspace id, tenant uuid, user pk). Never an API key, email, or
    // anything else that can change for the same customer.
    id: /* this customer's stable, immutable internal id */,
    enrich: async (id) => {
      // Lazy-resolved: runs once per owner id, then cached.
      // Fill in with your own lookup (DB, JWT, API, etc.).
      //
      //   const workspace = await db.workspaces.findById(id);

      return {
        /*
          label: workspace.name,
          email: workspace.adminEmails,  // string or string[]
        */
      };
    },
  },
})));

Here's how to set it up for your framework:

| framework | registration | | --------- | ------------------------------------------------------------------------ | | Express | app.use(restless.setup(cb)) + app.use(restless.errorHandler) last | | Fastify | await fastify.register(restless.setup(cb)) | | Koa | app.use(restless.setup(cb)) | | Hono | app.use(restless.setup(cb)) | | Next.js | withRestless(nextConfig) + restless.config.ts — no per-route changes | | http | http.createServer(restless.setup(cb)(myHandler)) |

Full per-framework examples are in install.md.

What you get

  • One line of setup. The factory returns a client; setup(cb) gives you framework-ready middleware back.

  • Lazy owner enrichment. Expensive DB lookups for owner metadata (display name, contact emails, plan tier) run only on the first request from each owner id, then cache until the server asks for a refresh. 100 requests from the same workspace don't hit your database 100 times.

  • Safe by default. Headers like Authorization / Cookie and body fields like password / token / ssn are redacted before anything leaves your server. The redaction list extends itself from your OpenAPI spec: the npx restless init flow scans your auth mechanisms and flags custom fields automatically.

  • Bounded under load. Logs upload in the background, at most 4 uploads at a time with a 10 s timeout, so a slow or busy Restless can't pile up sockets or memory in your process. Uploads Restless turns away (503/429) are retried; anything it may already have stored is never resent. Details in docs/INTERNALS.md.

  • Error-triage built in. Every response gets an x-log-url header pointing at the captured log, an x-debug header with the npx api debug <id> command, and an x-api-feedback header with the npx api feedback <id> command for filing feedback about that exact request. 4xx / 5xx responses also get a debug block in the JSON body so you can jump straight to it. If a customer attaches a "next steps" message to an error in the dashboard's Agent Recovery view, the SDK injects it into the response as debug.recovery — looked up sync from an in-process cache, never blocking the response on a network call.

  • Crashes are logged, and grouped by where they crashed. A handler that throws still produces a log, and the exception's throw site (file + function, never line numbers) is what groups it - so the same bug stays one group in the dashboard no matter what the error message interpolates. The exception is always re-thrown untouched: your framework's error handling behaves exactly as it did without the SDK. Express needs one extra line for this, because Express only routes errors to middleware registered after your routes:

    app.use(restless.setup(cb));
    app.use("/api", routes);
    app.use(restless.errorHandler); // ← after your routes

    Every other framework wires itself up. Without it, an Express crash still logs, it just groups by the text of your error response instead of by throw site.

  • Blocking. Return { block: true } from the setup callback to reject a request with a 403 before your handler runs. Blocked requests skip enrich entirely, so a banned tenant costs you no database lookups.

  • Sampling. Send less for noisy endpoints without losing your counts. Each endpoint is "on" (the default), "off", "errors" (only status >= 400), or a rate such as 0.1: that fraction of successful requests is logged in full and the rest without bodies, so counts, latency and per-customer usage stay exact. Errors are always logged in full, except on an "off" route.

    restless(process.env.RESTLESS_KEY, {
      sampling: {
        default: "on",
        routes: { "GET /health": "off", "GET /status": "errors", "GET /pets": 0.1, "* /pets/{id}": 0.5 },
      },
    });

    Keys are a method (or * for any) and the route pattern your framework matched; {id} and :id are the same. The same sampling block can live in .restless/settings.json, and the code option wins per route. A request on an "off" route, or a success on an "errors" route, sends nothing and gets no x-request-id / x-restless-id, x-debug or x-api-feedback header. An invalid value never throws: it falls back to "on" and says so under DEBUG=restless.

Environment variables

| variable | purpose | | ------------------- | -------------------------------------------------------------------------------------------------------------------------------- | | RESTLESS_KEY | Your project API key. Used if you don't pass one explicitly. Auto-loaded from .env (walking up from cwd) if not already set. | | RESTLESS_BASE_URL | Override the metrics server URL (self-hosted / staging). restless(key, { baseUrl }) takes precedence over it. | | DEBUG=restless | Print upload diagnostics to stderr. |

Docs

  • install.md: comprehensive installation reference. Framework examples, option tables, every gotcha. Structured so both humans and AI coding assistants can follow it.
  • docs/INTERNALS.md: how batching, blocking, redaction, and request ID generation actually work.
  • spec/: the cross-language SDK contract. This package is the reference implementation for every Restless SDK; spec/ holds the normative spec, generated conformance vectors, and a harness that runs them against an implementation in any language.

License

MIT