async function

getPackageDownloads

(__namedParameters,[object Object]): Promise<PackageDownloads>
getPackageDownloads returns the number of downloads for a package in a given time period.

Examples

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 monthly downloads for package query-registry from the npm registry:
import { getPackageDownloads } from 'query-registry';

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

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

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