This is an npm package to interact with the npm api and npm registry. You can search for npm packages, get details, statistics or downlaod counts of any npm package.
If you have trouble with this package, feel free to ask me in my Discord.
Simply execute the following command in your commandline:
npm install npm-stats-info
First, import the package like this:s
const npmStats = require("npm-stats-info");
To get details about a certain package, you can use the following function:
let package = await npmStats.packageInfo("example-package");
console.log(package)
To get download statistics for a certain package, you can use the following function:
// Get download statistics for "example-package"
let downloads = await npmStats.packageDownloads("example-package");
console.log(downloads)
// Get download statistics for "example-package" from 2023-12-01 until 2022-12-01 (Default is now to one year ago)
// !!! When using a custom time span, "yesterday", "thisMonth" and "lastMonth" might be undefined!
let downloads = await npmStats.packageDownloads("splatoon3api", "2023-12-01", "2022-12-01")
console.log(downloads)
To get download statistics for all packages together on npm, you can use the following function:
let downloads = await npmStats.allDownloads();
console.log(downloads)
To find packages by a string, you can use the following function.
Special search qualifiers can be provided in the full-text query:
author:bcoe
: Show/filter results in which bcoe is the authormaintainer:bcoe
: Show/filter results in which bcoe is qualifier as a maintainerkeywords:batman
: Show/filter results that have batman in the keywords- separating multiple keywords with
,
acts like a logical OR+
acts like a logical AND,-
can be used to exclude keywords
- separating multiple keywords with
not:unstable
: Exclude packages whose version is < 1.0.0not:insecure
: Exclude packages that are insecure or have vulnerable dependencies (based on the nsp registry)is:unstable
: Show/filter packages whose version is < 1.0.0is:insecure
: Show/filter packages that are insecure or have vulnerable dependencies (based on the nsp registry)boost-exact:false
: Do not boost exact matches, defaults to true
// Search for "electron",
// Maximum of 20 results,
// Page 5 (4 * 20 results get skipped)
let result = await npmStats.searchPackage("electron", 20, 4 * 20);
console.log(result)// Output the result
// Search for packages by "kartoffelchips", that has the keywords "splatoon" and "splatoon3"
let myPackages = await npmStats.searchPackage("author:kartoffelchips keywords:splatoon+splatoon3");
console.log(myPackages)// Output the result
GNU General Public License v3.0
You can find the Changelog in CHANGELOG.md.