query-registry
Version:
Query the npm registry for packuments, manifests, packages and download counts
49 lines • 1.76 kB
TypeScript
import { DownloadPeriod } from '../types/download-period';
import { DailyRegistryDownloads } from '../types/downloads';
/**
* `getDailyRegistryDownloads` returns the number of downloads for all registry packages
* for each day in a given time period.
*
* @param period - time period in which downloads happened (default: `last-week`)
* @param registryDownloadsAPI - URL of the registry's downloads API (default: npm registry)
* @param cached - accept cached responses (default: `true`)
*
* @example
* Get the day by day weekly downloads for the npm registry:
*
* ```typescript
* import { getDailyRegistryDownloads } from 'query-registry';
*
* (async () => {
* const downloads = await getDailyRegistryDownloads();
*
* // Output: 'number'
* console.log(typeof downloads.downloads[0].downloads);
* })();
* ```
*
* @example
* Get the day by day monthly downloads for the npm registry:
*
* ```typescript
* import { getDailyRegistryDownloads } from 'query-registry';
*
* (async () => {
* const downloads = await getDailyRegistryDownloads({ period: 'last-month' });
*
* // Output: 'number'
* console.log(typeof downloads.downloads[0].downloads);
* })();
* ```
*
* @see {@link DailyRegistryDownloads}
* @see {@link DownloadPeriod}
* @see {@link npmRegistryDownloadsAPI}
* @see {@link https://github.com/npm/registry/blob/master/docs/download-counts.md#ranges}
*/
export declare function getDailyRegistryDownloads({ period: rawDownloadPeriod, registryDownloadsAPI, cached, }?: {
period?: DownloadPeriod;
registryDownloadsAPI?: string;
cached?: boolean;
}): Promise<DailyRegistryDownloads>;
//# sourceMappingURL=get-daily-registry-downloads.d.ts.map