This Node.js library, `npm-api` (current stable version 1.0.1), provides a programmatic interface for interacting with the public NPM registry API, primarily through its CouchDB views. It allows developers to fetch package metadata, retrieve maintainer information, and query registry data using its `NpmApi` client and associated `Repo` and `Maintainer` models. The library simplifies what would otherwise be direct HTTP requests to the registry, offering methods to get package details, specific versions, and a maintainer's list of repositories. While it once served as a convenient wrapper, the package has not received updates in approximately five years, indicating it is likely abandoned and should be used with caution, particularly for new projects requiring active support or modern features.
npm install npm-apiVerified import paths — ran on the pinned version, not inferred.
Demonstrates fetching package details for 'express' and listing repositories for 'ljharb' using the `NpmApi` client.
Consider using alternative, actively maintained NPM registry clients or making direct HTTP requests to the official NPM registry API endpoints.
To directly import and instantiate `Maintainer` or `Repo`, you must use specific sub-paths: `require('npm-api/lib/models/maintainer')` or `require('npm-api/lib/models/repo')`. Alternatively, obtain instances via the `NpmApi` client: `new NpmApi().maintainer('name')` or `new NpmApi().repo('name')`.Always use `require()` syntax for importing `npm-api` and its sub-modules: `const NpmApi = require('npm-api');`. If used in an ESM project, consider dynamic import (`await import('npm-api')`) or a CJS wrapper.Regularly test critical integrations with this library. Be prepared to implement custom logic to interact with the current NPM registry API endpoints if this library's methods fail or return incorrect data.
Import the class from its specific sub-path: `const Maintainer = require('npm-api/lib/models/maintainer');` or use the `NpmApi` client method: `const npm = new NpmApi(); const maintainer = npm.maintainer('name');`.Ensure your project or file uses CommonJS (`.js` files without `"type": "module"` in `package.json` or explicit `.cjs` extension) or use dynamic `import()`: `const NpmApi = await import('npm-api');`.Verify the package name is correct and published on npm. Ensure there are no typos. This error can also occur if the registry URL is inaccessible or has changed, though less likely for public packages.
No dependency data recorded yet.