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

metrics-api-client

v0.0.3

Published

Typed client for a hosted metrics-api-server (default https://metrics-api.tamino.dev)

Readme

metrics-api-client

Typed fetch wrapper for a hosted metrics-api-server — by default the reference deployment at https://metrics-api.tamino.dev, or any self-hosted fork (see the root README's Self-hosting section).

npm install metrics-api-client

Usage

import { MetricsApiClient } from 'metrics-api-client';

const api = new MetricsApiClient(); // default: https://metrics-api.tamino.dev
// const api = new MetricsApiClient({ baseUrl: 'https://your-fork.vercel.app' });

const user = await api.github('octocat');
// { profile, repos, contributions, warnings? }

Other methods:

const npmStats = await api.npmStats('octocat', { months: 6 }); // 1–17, default 12

github(user, options?)

Returns a GithubUser: { profile, repos, contributions, warnings? }. options:

{
  years?: 'all' | 'last' | number[]; // default 'all' — mirrors the server's `y` query param
  token?: string;                    // your own GitHub PAT — sent as `Authorization: Bearer`
  lifetime?: boolean;                // with `token`, also request contributions.lifetimeTotal
}
  • Without token, you get the base scraped profile/repos/contributions, plus any public GraphQL enrichment the server adds via its own GITHUB_TOKEN (profile.accountCreatedAt, profile.location, per-repo defaultBranchCommits/createdAt/pushedAt) — best-effort, may be absent if the server has no token or is rate-limited (see warnings).
  • With token, your PAT is sent as Authorization: Bearer <token> and the response additionally includes contributions.byType (commits, pullRequests, reviews, issues) and contributions.privateLastYear, computed from your token's access — the request is never cached server-side. Add lifetime: true to also get contributions.lifetimeTotal.
const enriched = await api.github('octocat', { years: [2024, 2025], token: myPat, lifetime: true });

Options

new MetricsApiClient({
  baseUrl?: string;      // default: https://metrics-api.tamino.dev
  fetch?: typeof fetch;  // default: globalThis.fetch — override for retries, logging, custom runtimes, tests
});

Errors

Failed requests throw MetricsApiError, which carries a machine-readable kind and the HTTP status alongside the message:

import { MetricsApiClient, MetricsApiError } from 'metrics-api-client';

const api = new MetricsApiClient();
try {
  await api.github('this-user-does-not-exist-hopefully');
} catch (error) {
  if (error instanceof MetricsApiError) {
    console.log(error.kind, error.status, error.message);
    // 'not-found' 404 'user not found: this-user-does-not-exist-hopefully'
  }
}

kind is one of:

| Kind | HTTP status | Meaning | | --- | --- | --- | | bad-request | 400 | invalid username | | not-found | 404 | GitHub/npm has no such user | | upstream | other non-2xx (incl. 401 for a rejected token) | server-side scrape/aggregation failure, or GitHub rejected the caller's token | | network | — (status 0) | the request itself failed (offline, DNS, CORS, etc.) |

Types

GithubUser and NpmStats are re-exported from metrics-api-server so consumers don't need a direct dependency on that package just for types. GithubUser includes the nested profile, repos[], and contributions (with optional byType) shapes described above.