JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 64979
  • Score
    100M100P100Q141411F
  • License MIT

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

Package Exports

  • query-registry
  • query-registry/package.json

Readme

query-registry

Build status Coverage jsDocs.io Language Dependencies npm bundle size npm License

This package exports several functions to query the npm registry (or one of its mirrors) through one of its endpoints

Features

  • Provides functions to:
    • Get registry metadata
    • Get packuments (package documents)
    • Get package manifests
    • Get download counts
    • Search packages
  • Typed responses
  • Supports mirrors of the npm registry
  • Supports caching network requests
  • Well documented and tested

API & Package Contents

Explore the API on jsDocs.io.

View package contents on unpkg.

View repository on GitHub.

Install

Using npm:

npm i query-registry

Using yarn:

yarn add query-registry

Usage

Get the metadata for the npm registry:

import { getRegistryMetadata } from 'query-registry';

(async () => {
    const metadata = await getRegistryMetadata();

    // Output: 'registry'
    console.log(metadata.db_name);
})();

Get the latest manifest for package query-registry from the npm registry:

import { getPackageManifest } from 'query-registry';

(async () => {
    const manifest = await getPackageManifest({ name: 'query-registry' });

    // Output: 'query-registry'
    console.log(manifest.name);
})();

Get the weekly downloads for package query-registry from the npm registry:

import { getPackageDownloads } from 'query-registry';

(async () => {
    const downloads = await getPackageDownloads({ name: 'query-registry' });

    // Output: 'query-registry'
    console.log(downloads.package);

    // Output: 'number'
    console.log(typeof downloads.downloads);
})();

Get the search results for text query query-registry from the npm registry:

import { searchPackages } from 'query-registry';

(async () => {
    const results = await searchPackages({
        query: { text: 'query-registry' },
    });

    // Output: 'query-registry'
    console.log(results.objects[0].package.name);
})();

Debug

Debug messages are available when the DEBUG environment variable is set to query-registry:

DEBUG="query-registry"

For more information, see the debug package.

License

MIT License

Copyright (c) 2021 Edoardo Scibona

See LICENSE file.