npms-client
NodeJS Client for the npms.io
API
Installation
npm i npms-client
You may need to install axios as it is a peer dependency of npms-client
.
API
All query parameters are optional unless otherwise specified. All API endpoints return a Promise
.
search
Perform a search query
terms
(required) - an array of strings that represent the terms to search acrossscope
- a string that filters by a specific scope (@jaebradley
, for example)author
- a string that filters by a specific authormaintainer
- a string that filters by a specific maintainerexclude
- an object that represents certain exclusion rulespackageTypes
- an array ofPACKAGE_TYPES
. Defaults to[PACKAGE_TYPES.DEPRECATED, PACKAGE_TYPES.INSECURE, PACKAGE_TYPES.UNSTABLE]
.keywords
- an array of strings that filter based on matching values inkeywords
field inpackage.json
include
- an object that represents certain inclusion rulespackageTypes
- an array ofPACKAGE_TYPES
. Defaults to an empty array.keywords
- an array of strings that filter based on matching values inkeywords
field inpackage.json
boostExactMatches
- aboolean
that will boost exact matches. Istrue
by default.packageScoreMultiplier
- a number that represents the impact that package scores have on the final search scorepackageScoreWeights
- an object that represents the impact that certain package attributes have on the package scorequality
- a number that represents the impact that quality has on package scorepopularity
- a number that represents the impact that popularity has on package scoremaintenance
- a number that represents the impact that maintenance has on package score
from
- a number that represents the offset to start searching from. Is0
, by defaultsize
- a number that represents the total number of results to return. Is25
, by default.
; // Search for packages that match jae or jaebradley that are not deprecated, insecure, or unstableawait ; // Search for packages that match jae that only exclude deprecated packagesawait ; // Other search examplesconst termsSearch = await ;const scopeSearch = await ;const authorSearch = await ;const maintainerSearch = await ;const excludeDeprecatedPackages = await ;const excludeKeywords = await ;const includeDeprecatedPackages = await ;const includeKeywords = await ;const sizeSearch = await ;const offsetSearch = await ;
getSuggestions
Get suggestions for an array of search terms
terms
(required) - an array of strings that represent the terms to search acrosssize
- a number that represents the total number of results to return. Is25
by default.
; await ;
getPackageInformation
Get information about a specific package
packageName
(required) - a string that represents the package name
; await ;
getPackagesInformation
Get information about a set of packages
packageNames
(required) - an array of strings that represent all the package names to get information for
; await ;
PACKAGE_TYPES
An enum that is exported by npms-client
.
There are three values - PACKAGE_TYPES.DEPRECATED
, PACKAGE_TYPES.UNSTABLE
, PACKAGE_TYPES.INSECURE
.
These values are primarily used to exclude or include certain packages when executing search queries.