What is npm-keyword?
The npm-keyword package allows you to search for npm packages by keyword. It provides a simple API to fetch packages that match a given keyword, making it easier to discover related packages.
What are npm-keyword's main functionalities?
Search for packages by keyword
This feature allows you to search for npm packages that match a specific keyword. The code sample demonstrates how to use the npm-keyword package to find all packages related to the keyword 'gulpplugin'.
const keyword = require('npm-keyword');
(async () => {
const packages = await keyword('gulpplugin');
console.log(packages);
})();
Search for package names by keyword
This feature allows you to search for the names of npm packages that match a specific keyword. The code sample demonstrates how to use the npm-keyword package to find the names of all packages related to the keyword 'gulpplugin'.
const keyword = require('npm-keyword');
(async () => {
const packageNames = await keyword.names('gulpplugin');
console.log(packageNames);
})();
Search for package count by keyword
This feature allows you to get the count of npm packages that match a specific keyword. The code sample demonstrates how to use the npm-keyword package to find the number of packages related to the keyword 'gulpplugin'.
const keyword = require('npm-keyword');
(async () => {
const count = await keyword.count('gulpplugin');
console.log(count);
})();
Other packages similar to npm-keyword
package-json
The package-json package allows you to get metadata of a package from the npm registry. While npm-keyword focuses on searching packages by keyword, package-json provides detailed information about a specific package, such as its version, dependencies, and more.
npm-registry-fetch
The npm-registry-fetch package is a low-level utility for fetching resources from the npm registry. It provides more granular control over the requests made to the registry compared to npm-keyword, which is more specialized in keyword-based searches.
npms
The npms package is a client for the npms.io API, which provides a higher-level search and analysis of npm packages. It offers more advanced search capabilities and package scoring compared to the simpler keyword-based search provided by npm-keyword.
npm-keyword
Get a list of npm packages with keywords
Install
npm install npm-keyword
Usage
import {npmKeyword, npmKeywordNames, npmKeywordCount} from 'npm-keyword';
console.log(await npmKeyword('gulpplugin'));
console.log(await npmKeywordNames('gulpplugin'));
console.log(await npmKeywordCount('gulpplugin'));
Caveat
The list of packages will contain a maximum of 250 packages matching the keywords. This limitation is caused by the npm registry API.
API
npmKeyword(keywords, options?)
Returns a promise for a list of packages having the specified keyword in their package.json keywords
property.
keywords
Type: string | string[]
Example: ['string', 'camelcase']
One or more keywords. Only matches packages that have all the given keywords.
options
Type: object
size
Type: number
Default: 250
Limits the amount of results.
npmKeywordNames(keywords, options?)
Returns a promise for a list of package names.
keywords
Type: string | string[]
Example: ['string', 'camelcase']
One or more keywords. Only matches packages that have all the given keywords.
options
Type: object
size
Type: number
Default: 250
Limits the amount of results.
npmKeywordCount(keywords)
Returns a promise for the count of packages.
keywords
Type: string | string[]
Example: ['string', 'camelcase']
One or more keywords. Only matches packages that have all the given keywords.
Related
- package-json - Get the package.json of a package from the npm registry
- npm-user - Get user info of an npm user
- npm-email - Get the email of an npm user