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 🙏

© 2024 – Pkg Stats / Ryan Hefner

query-registry

v3.0.0

Published

Query the npm registry for packuments, manifests, packages and download counts

Downloads

71,541

Readme

query-registry

Build status Coverage jsDocs.io Language npm License

query-registry is an API wrapper for the npm registry API.

Features

  • Provides functions to:
    • Get registry metadata.
    • Get registry public keys.
    • Get packuments (package documents) with full package metadata.
    • Get abbreviated packuments with installation data only.
    • Get package manifests for each version of a package.
    • Get download counts for the registry and for packages.
    • Search packages by name and other specific criteria.
  • Works in the browser.
  • Validates registry responses with zod.
  • Automatically caches registry responses for a short time.
  • Supports third-party npm-compatible registries.

Useful resources

Install

Using npm:

npm add query-registry

Using yarn:

yarn add query-registry

Using pnpm:

pnpm add query-registry

Using bun:

bun add query-registry

Usage examples

Registry

Get the metadata about the npm registry itself, if available:

import { getRegistryMetadata } from "query-registry";

const metadata = await getRegistryMetadata();

Get the public signing keys for the npm registry:

import { getRegistrySigningKeys } from "query-registry";

const { keys } = await getRegistrySigningKeys();

Packuments (Package documents)

Get the abbreviated packument containing only the necessary data to install the react package:

import { getAbbreviatedPackument } from "query-registry";

const abbrPackument = await getAbbreviatedPackument("react");

Get the full packument containing all the data available about the react package:

import { getPackument } from "query-registry";

const packument = await getPackument("react");

Package manifests

Get the manifest containing the original package.json data plus additional registry metadata for the latest version of the react package:

import { getPackageManifest } from "query-registry";

const manifest = await getPackageManifest("react");

Get the manifest for [email protected] (semver version):

import { getPackageManifest } from "query-registry";

const manifest = await getPackageManifest("react", "18.2.0");

Get the manifest for react@next (distribution tag):

import { getPackageManifest } from "query-registry";

const manifest = await getPackageManifest("react", "next");

Search packages

Search packages related to react (e.g., react, react-dom, ...):

import { searchPackages } from "query-registry";

const results = await searchPackages({ text: "react" });

Download counts

Get the total number of downloads for package react for the last month:

import { getPackageDownloads } from "query-registry";

const { downloads } = await getPackageDownloads("react", "last-month");

There are also these other download counts functions available: getBulkDailyPackageDownloads, getBulkPackageDownloads, getDailyPackageDownloads, getDailyRegistryDownloads and getPackageVersionsDownloads.

Cache

Clear the internal cache.

import { cache } from "query-registry";

cache.clear();

See the quick-lru package for the cache API.

License

MIT

Copyright (c) 2024 Edoardo Scibona

See LICENSE file.