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

npm-registry-sdk

v1.2.1

Published

A fully type-safe client library for the npm registry API.

Readme

npm-registry-sdk

NPM version NPM downloads CI codecov License: ISC

A modern TypeScript client library for the npm registry API. This library provides a simple and type-safe way to interact with the npm registry.

Features

  • 🎯 Fully type-safe API with TypeScript
  • 🔍 Package search functionality
  • 📦 Package metadata retrieval
  • 🔄 Version-specific information
  • ⬇️ Tarball download support
  • 🧪 100% test coverage
  • 🚀 Zero dependencies

Installation

npm install npm-registry-sdk

Usage

Initialize the Client

import { NpmRegistry } from 'npm-registry-sdk';

// Use default registry URLs
const registry = new NpmRegistry();

// Or with custom options
const customRegistry = new NpmRegistry({
  // Custom registry URL (default: 'https://registry.npmjs.org')
  registry: 'https://custom-registry.example.com',
  // Additional fetch options
  headers: {
    'Authorization': 'Bearer token'
  }
});

Search for Packages

// Basic search
const results = await registry.search('react');

// Search with options
const resultsWithOptions = await registry.search('react', {
  size: 20,
  from: 0
});

// Search with qualifiers
const resultsWithQualifiers = await registry.search('react', {
  size: 20,
  qualifiers: {
    author: 'facebook',
    keywords: 'frontend,ui',
    not: 'deprecated'
  }
});

console.log(results.objects.map(obj => obj.package.name));

Get Package Information

// Get full package info
const packageInfo = await registry.getPackage('react');

// Get specific version
const versionInfo = await registry.getPackageVersion('react', '18.2.0');

// Get latest version
const latestInfo = await registry.getLatestVersion('react');

Get Dist Tags

const tags = await registry.getDistTags('react');
console.log(tags.latest); // e.g., '18.2.0'

Get registry metadata

const metadata = await registry.getMetadata();
console.log(metadata); // e.g., { db_name: '', db_count: '', ... }

Get public signing keys used by the registry

const registryKeys = await registry.getRegistryKeys();
console.log(keys); // e.g., { keys: [{ 'expires': '...', 'keyid': '...' }] }

Download Statistics

// Get download counts for a specific period
const allDownloads = await registry.getRegistryDownloads('last-week');
console.log(allDownloads.downloads); // Total downloads for all packages

// Get download counts for a specific package
const packageDownloads = await registry.getRegistryDownloads('last-month', 'react');
console.log(packageDownloads.downloads); // Downloads for react package

// Available periods: 'last-day', 'last-week', 'last-month', 'last-year'
// You can also specify a custom date range: 'yyyy-mm-dd:yyyy-mm-dd'
const customPeriod = await registry.getRegistryDownloads('2023-01-01:2023-12-31', 'react');

Download Package Tarballs

// Download a specific version of a package as ArrayBuffer
const tarball = await registry.downloadTarball('react', '18.2.0');
// You can then save this to a file or process it as needed

API Reference

Class: NpmRegistry

Creates a new instance of the npm registry client.

constructor(options?: NpmRegistryOptions)

Options:

  • registry?: string - The base URL of the NPM Registry (default: https://registry.npmjs.org)
  • api?: string - The base URL of the NPM Registry API (default: https://api.npmjs.org)
  • Additional options are passed to the underlying fetch calls as RequestInit

API Methods

getPackage

Get full package information including all versions.

getPackage(packageName: string): Promise<PackageInfo>

getPackageVersion

Get metadata for a specific version of a package.

getPackageVersion(packageName: string, version: string): Promise<PackageMetadata>

getLatestVersion

Get metadata for the latest version of a package.

getLatestVersion(packageName: string): Promise<PackageMetadata>

getDistTags

Get the dist-tags (like 'latest', 'beta', etc.) for a package.

getDistTags(packageName: string): Promise<DistTags>

search

Search for packages in the registry.

search(query: string, options?: SearchOptions): Promise<SearchResults>

Options:

  • size?: number - Number of results per page
  • from?: number - Starting position
  • quality?: number - Quality score
  • popularity?: number - Popularity score
  • maintenance?: number - Maintenance score
  • qualifiers?: SearchQueryQualifiers - Additional search qualifiers (author, keywords, etc.)

getRegistryDownloads

Get download statistics for the entire registry or a specific package.

getRegistryDownloads(period: DownloadPeriod, packageName?: string): Promise<RegistryDownloads>

Periods:

  • Predefined: 'last-day', 'last-week', 'last-month', 'last-year'
  • Custom range: 'yyyy-mm-dd:yyyy-mm-dd'

getRegistryMetadata

Get metadata about the registry.

getRegistryMetadata(): Promise<RegistryMetadata>

getRegistryKeys

Get the public signing keys used by the registry.

getRegistryKeys(): Promise<RegistryKeys>

downloadTarball

Download a specific version of a package as an ArrayBuffer.

downloadTarball(packageName: string, version: string): Promise<ArrayBuffer>

TypeScript Support

This library is written in TypeScript and includes comprehensive type definitions for all APIs. You'll get full IntelliSense support and type checking out of the box.

Contributing

Contributions are welcome! Please see our Contributing Guide for more details.

License

ISC