{"id":13682,"library":"npm-api","title":"NPM API Client","description":"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.","status":"abandoned","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/doowb/npm-api","tags":["javascript","api","base","downloads","maintainer","maintainers","npm","npm-api","package"],"install":[{"cmd":"npm install npm-api","lang":"bash","label":"npm"},{"cmd":"yarn add npm-api","lang":"bash","label":"yarn"},{"cmd":"pnpm add npm-api","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The primary client constructor. This package is CommonJS-only and does not natively support ESM imports. The `NpmApi` class is the default export.","wrong":"import NpmApi from 'npm-api';","symbol":"NpmApi","correct":"const NpmApi = require('npm-api');"},{"note":"The `Repo` model can be instantiated directly for advanced use cases, but it is typically obtained via an `NpmApi` instance (e.g., `new NpmApi().repo('name')`). Direct import requires specifying the sub-path as it's not a root export. The README's example `new Repo()` is misleading without showing the full import path.","wrong":"const { Repo } = require('npm-api');","symbol":"Repo","correct":"const Repo = require('npm-api/lib/models/repo');"},{"note":"The `Maintainer` model can be instantiated directly, but it is typically obtained via an `NpmApi` instance (e.g., `new NpmApi().maintainer('name')`). Direct import requires specifying the sub-path as it's not a root export. The README's example `new Maintainer()` is misleading without showing the full import path.","wrong":"const { Maintainer } = require('npm-api');","symbol":"Maintainer","correct":"const Maintainer = require('npm-api/lib/models/maintainer');"}],"quickstart":{"code":"const NpmApi = require('npm-api');\n\nasync function getNpmInfo() {\n  const npm = new NpmApi();\n\n  // Get info for a specific repository via the NpmApi instance\n  console.log('--- Repository Info ---');\n  const repo = npm.repo('express');\n  try {\n    const pkg = await repo.package();\n    console.log(`Package: ${pkg.name}@${pkg.version}`);\n    console.log(`Description: ${pkg.description}`);\n    console.log(`Maintainers: ${pkg.maintainers.map(m => m.name).join(', ')}`);\n  } catch (err) {\n    console.error(`Error fetching express package: ${err.message}`);\n  }\n\n  // Get info for a specific maintainer via the NpmApi instance\n  console.log('\\n--- Maintainer Info ---');\n  const maintainer = npm.maintainer('ljharb');\n  try {\n    const repos = await maintainer.repos();\n    console.log(`Maintainer ljharb manages ${repos.length} repositories.`);\n    console.log('Some of their repos:');\n    repos.slice(0, 3).forEach(r => console.log(`- ${r}`));\n  } catch (err) {\n    console.error(`Error fetching maintainer repos: ${err.message}`);\n  }\n}\n\ngetNpmInfo();","lang":"javascript","description":"Demonstrates fetching package details for 'express' and listing repositories for 'ljharb' using the `NpmApi` client."},"warnings":[{"fix":"Consider using alternative, actively maintained NPM registry clients or making direct HTTP requests to the official NPM registry API endpoints.","message":"The `npm-api` package has not been updated in approximately five years, indicating it is no longer actively maintained. Users should be aware of potential compatibility issues with newer Node.js versions or changes in the NPM registry API that may not be addressed.","severity":"breaking","affected_versions":">=1.0.1"},{"fix":"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')`.","message":"The README examples for `new Maintainer()` and `new Repo()` are misleading. These classes are not directly exported from the main `npm-api` package. Attempting `const { Maintainer } = require('npm-api');` will result in `undefined`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"This package is strictly CommonJS (CJS) and does not support ES Modules (ESM) syntax. Attempting `import NpmApi from 'npm-api';` in an ESM context will throw a `TypeError`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"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.","message":"The NPM registry API, particularly the CouchDB views that this library heavily relies on, may change or become less reliable over time. Given the package's abandoned status, it might not adapt to future API changes, potentially leading to unexpected errors or incomplete data.","severity":"gotcha","affected_versions":">=1.0.1"}],"env_vars":null,"search_vec":"'1.0.1':13 'abandon':105 'activ':117 'allow':32 'api':2,9,25,123,131 'approxim':98 'associ':50 'base':124 'caution':111 'client':3,48 'conveni':89 'couchdb':29 'current':10 'data':44 'detail':73 'develop':33 'direct':62 'download':125 'featur':121 'fetch':35 'five':99 'get':71 'http':63 'indic':101 'inform':40 'interact':19 'interfac':17 'javascript':122 'librari':6,56 'like':104 'list':80 'maintain':39,53,78,126,127 'metadata':37 'method':69 'model':54 'modern':120 'new':114 'node.js':5 'npm':1,8,23,128,130 'npm-api':7,129 'npmapi':47 'offer':68 'otherwis':60 'packag':36,72,92,132 'particular':112 'primarili':26 'programmat':16 'project':115 'provid':14 'public':22 'queri':42 'receiv':95 'registri':24,43,67 'repo':51 'repositori':82 'request':64 'requir':116 'retriev':38 'serv':86 'simplifi':57 'specif':74 'stabl':11 'support':118 'updat':96 'use':45,109 'version':12,75 'view':30 'would':59 'wrapper':90 'year':100","created_at":"2026-04-20T01:55:45.739361+00:00","updated_at":"2026-04-20T01:55:45.739361+00:00","problems":[{"fix":"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');`.","cause":"Attempting to instantiate `Maintainer` or `Repo` directly (e.g., `new Maintainer('name')`) without correctly importing the class.","error":"TypeError: Maintainer is not a constructor"},{"fix":"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');`.","cause":"Trying to use `require()` to import `npm-api` within an ES Module (ESM) context, or vice-versa with `import` in CJS.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported. Instead change the require of index.js in ... to a dynamic import() call."},{"fix":"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.","cause":"The `repo` or `package` method was called with a package name that does not exist in the NPM registry.","error":"Error: Not Found - no such package available"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/doowb/npm-api","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/npm-api","openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}