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

@codasignal/routo

v0.2.0

Published

TypeScript SDK for the Routo link management API

Readme

@codasignal/routo

TypeScript SDK for the Routo link management API.

Install

npm install @codasignal/routo
# or
bun add @codasignal/routo

Requires Node ≥20, or any modern browser/Cloudflare Workers/Bun/Deno runtime that ships fetch and AbortSignal.any.

Quickstart

import { Routo } from "@codasignal/routo";

const routo = new Routo(process.env.ROUTO_API_KEY!);

const link = await routo.links.create({
  url: "https://example.com/products/42",
  projectId: "proj_abc",
  path: "summer-sale",
  socialMedia: { title: "Summer Sale!", description: "50% off" },
});

console.log(link.id, link.url);

In Node, you can call new Routo() with no arguments and the SDK reads ROUTO_API_KEY from process.env.

Resources

| Resource | Methods | | ------------------ | ---------------------------------------------------------------------------------------------------- | | links | create, createDynalinks, list (Page), update, delete | | links.variants | create, list, update, delete | | analytics | get, aggregate, aggregateUnique, breakdown, variantPerformance | | console | get | | customDomains | create, list (Page), get, update, delete, verify | | projectApps | create, list (Page), listByProject, update, delete | | projects | list, get | | organizations | list, current |

Pagination

list() returns a Page<T> that is both an AsyncIterable<T> and a manual paginator:

// Iterate everything
for await (const link of routo.links.list({ projectId: "p1" })) {
  process(link);
}

// Manual paging
let page = routo.links.list({ projectId: "p1", limit: 50 });
let current = await page.next();
while (current) {
  process(current.data);
  current = current.hasMore ? await current.next() : null;
}

Errors

import { RoutoValidationError, RoutoRateLimitError } from "@codasignal/routo";

try {
  await routo.links.create({ url: "", projectId: "", path: "" });
} catch (err) {
  if (err instanceof RoutoValidationError) {
    for (const fe of err.fieldErrors) console.error(`${fe.path}: ${fe.message}`);
  } else if (err instanceof RoutoRateLimitError) {
    console.error(`rate limited, retry in ${err.retryAfterMs}ms`);
  } else {
    throw err;
  }
}

| Class | Status | Notes | | ------------------------ | ---------- | -------------------------------- | | RoutoValidationError | 400 | exposes fieldErrors[] | | RoutoAuthError | 401, 403 | code is unauthorized/forbidden | | RoutoNotFoundError | 404 | | | RoutoRateLimitError | 429 | exposes retryAfterMs | | RoutoServerError | 5xx | retryable | | RoutoAbortError | n/a | from caller-provided signal | | RoutoTimeoutError | n/a | from timeoutMs | | RoutoNetworkError | n/a | wraps the underlying error in cause |

Retries and Idempotency

Network failures, 408, 429, and 5xx responses are retried automatically up to maxRetries (default 2). For POST / PATCH requests, the SDK generates an Idempotency-Key on first attempt and reuses it across retries. You can pass your own:

await routo.links.create(params, { idempotencyKey: "create-link-42" });

AbortSignal & Timeouts

const ctrl = new AbortController();
setTimeout(() => ctrl.abort(), 5_000);
await routo.links.list({ projectId: "p1" }, { signal: ctrl.signal });

// per-call timeout
await routo.analytics.get(range, { timeoutMs: 5_000 });

Edge runtime notes

The SDK is pure-fetch and ships a single ESM+CJS build. It runs unmodified in:

  • Cloudflare Workers (use wrangler dev)
  • Vercel Edge Functions
  • Bun / Deno
  • React Native (Hermes ≥0.74)

No Node-specific imports.

Examples

See examples/ in the repository:

  • node-quickstart.ts
  • cf-worker.ts
  • next-route-handler.ts
  • pagination.ts
  • abort-and-timeout.ts
  • retry-and-idempotency.ts

License

MIT