query-registry

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

Examples

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 abbreviated packument for package query-registry from the npm registry:
import { getAbbreviatedPackument } from 'query-registry';

(async () => {
    const packument = await getAbbreviatedPackument({ 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);
})();
Enable debug messages by setting the DEBUG environment variable to query-registry (available only in non production environments):
$ DEBUG="query-registry"

Classes

FetchError
FetchError represents an error that happened when fetching a URL.

Interfaces

AbbreviatedPackument
AbbreviatedPackument represents a packument (package document) containing only the metadata necessary to install a package.
BugTracker
BugTracker represents the bug tracking methods.
DailyPackageDownloads
DailyPackageDownloads lists the number of downloads for a package for each day in a given time period.
DailyRegistryDownloads
DailyRegistryDownloads lists the number of downloads for the registry for each day in a given time period.
DateRange
DateRange represents a time period between two days where the start and end dates are inclusive.
DistInfo
DistInfo contains data describing the distributed package.
DistTags
DistTags maps distribution tags to version numbers.
DownloadsPerDay
DownloadsPerDay lists the number of downloads in a given day.
GitRepository
GitRepository represents a git repository hosting the source code of a package.
NpmOperationalInternal
PackageDownloads
PackageDownloads lists the number of downloads for a package in a given time period.
PackageFlags
PackageFlags contains flag attributes categorizing the package.
PackageJSON
PackageJSON contains the package metadata usually found in package.json files.
PackageLinks
PackageLinks contains a collection of links of pages associated to the package.
PackageManifest
PackageManifest represents the manifest describing a specific version of a package.
PackageSearchResult
PackageSearchResult contains abbreviated package metadata returned by searching the registry for packages.
Packument
Packument represents a packument (package document) containing all the data about a package.
Person
Person represents a person associated to a package.
RawAbbreviatedPackument
RawAbbreviatedPackument represents an abbreviated packument (package document), as returned from the registry, containing only the metadata necessary to install a package.
RawPackageManifest
RawPackageManifest represents the manifest, as returned by the registry, describing a specific version of a package.
RawPackument
RawPackument represents a packument (package document), as returned from the registry, containing all the data about a package .
RegistryDownloads
RegistryDownloads lists the number of downloads for the registry in a given time period.
RegistryMetadata
RegistryMetadata contains information about the registry itself.
RegistryMetadataOther
RegistryMetadataSizes
Repository
Repository represents a remote repository hosting the source code of a package.
SearchCriteria
SearchCriteria represents the available search criteria.
SearchResult
SearchResult contains the search result for a single package and its search score.
SearchResults
SearchResults contains the results returned by the registry for a query.
SearchScore
SearchScore contains the final and detailed search score values.
SearchScoreDetail
SearchScoreDetail contains the search score values for the quality, popularity and maintenance categories.
VersionsToTimestamps
VersionsToTimestamps maps version numbers to their publishing timestamps.

Constants

InvalidPackageNameError
InvalidPackageNameError is thrown when the name of a package is not valid according to the npm registry naming rules.
InvalidPackageVersionError
InvalidPackageVersionError is thrown when a package's version does not exist.
cloudflareRegistry
npm registry mirror by Cloudflare
npmRegistry
npm registry
npmRegistryDownloadsAPI
Downloads API for the npm registry
npmRegistryMirrors
Mirrors of the npm registry.
yarnRegistry
npm registry mirror by Yarn