Optional configuration for registry URL, downloads API URL, and auth token
Runs a full security audit against the npm registry.
The payload mirrors the top-level structure of package-lock.json:
a name, version, and a dependencies map of resolved packages with their
versions, integrity hashes, and nested sub-dependencies.
Returns detailed advisory objects for every vulnerability found, along with recommended actions (update, install, or manual review).
POST /-/npm/v1/security/audits
Lock-file-shaped dependency tree to audit
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Full audit report with advisories, actions, and vulnerability counts
const result = await npm.audit({
name: 'my-app',
version: '1.0.0',
requires: { lodash: '^4.17.11' },
dependencies: {
lodash: { version: '4.17.11', integrity: 'sha512-...' },
},
});
console.log(result.metadata.vulnerabilities);
// { info: 0, low: 0, moderate: 1, high: 0, critical: 0 }
Object.values(result.advisories).forEach(a => {
console.log(`[${a.severity}] ${a.title} — ${a.module_name}@${a.vulnerable_versions}`);
console.log(` Fix: upgrade to ${a.patched_versions}`);
});
Runs a quick security audit against the npm registry.
Same payload as audit but returns only vulnerability counts by severity — no advisory details or recommended actions. Faster and lighter than the full audit.
POST /-/npm/v1/security/audits/quick
Lock-file-shaped dependency tree to audit
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Vulnerability counts by severity and dependency totals
const result = await npm.auditQuick({
name: 'my-app',
version: '1.0.0',
requires: { lodash: '^4.17.11' },
dependencies: {
lodash: { version: '4.17.11', integrity: 'sha512-...' },
},
});
const { high, critical } = result.metadata.vulnerabilities;
if (high + critical > 0) {
console.error(`Found ${high} high and ${critical} critical vulnerabilities`);
}
Fetches the total download count for multiple packages in a single request.
GET /downloads/point/{period}/{name1},{name2},... (via api.npmjs.org)
Array of package names to fetch downloads for (max 128)
Named period or date range (default: 'last-month')
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
A map of package name to download point data
Fetches the per-day download breakdown for a package over a given period.
GET /downloads/range/{period}/{package} (via api.npmjs.org)
Convenience method — equivalent to npm.package(name).downloadRange(period).
Named period or date range
The package name
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Download range data with a per-day array
Fetches the total download count for a package over a given period.
GET /downloads/point/{period}/{package} (via api.npmjs.org)
Convenience method — equivalent to npm.package(name).downloads(period).
Named period or date range
The package name
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Download point data including total count and date range
Returns a MaintainerResource for a given npm username, providing access to all packages they maintain.
GET /-/v1/search?text=maintainer:{username}
The npm username (e.g. 'sindresorhus', 'pilmee')
A maintainer resource with a packages() method
Subscribes to a client event.
Returns an OrgResource for a given npm organization, providing authenticated access to org packages, teams, and members.
These endpoints require a registry auth token with org access.
The npm org name, with or without the leading @
An org resource with packages(), teams(), members(), and teamMembers() methods
Returns a PackageResource for a given package name, providing access to package metadata, versions, dist-tags, and download statistics.
The returned resource can be awaited directly to fetch the full packument, or chained to access nested resources.
The package name (e.g. 'react', '@types/node')
A chainable package resource
Searches for packages on the npm registry.
GET /-/v1/search
Search parameters (required: text)
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Search results including packages, scores, and total count
Returns top packages for a keyword.
GET /-/v1/search?text=keywords:{keyword}&size={n}
Keyword to filter by
Number of packages to return (default: 20, max: 250)
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Search results including packages, scores, and total count
Returns top packages ranked by maintenance.
GET /-/v1/search?text=keywords:javascript&size={n}&maintenance=1&quality=0&popularity=0
Number of packages to return (default: 20, max: 250)
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Search results including packages, scores, and total count
Returns top packages ranked by popularity.
GET /-/v1/search?text=keywords:javascript&size={n}&popularity=1&quality=0&maintenance=0
Number of packages to return (default: 20, max: 250)
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Search results including packages, scores, and total count
Returns top packages ranked by quality.
GET /-/v1/search?text=keywords:javascript&size={n}&quality=1&popularity=0&maintenance=0
Number of packages to return (default: 20, max: 250)
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Search results including packages, scores, and total count
Returns top packages for a scope.
GET /-/v1/search?text=scope:{scope}&size={n}
Scope to filter by, with or without the leading @
Number of packages to return (default: 20, max: 250)
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Search results including packages, scores, and total count
Returns the top packages according to npm search's default ranking.
GET /-/v1/search?text=keywords:javascript&size={n}
The default npm ranking combines quality, popularity, and maintenance.
npm requires a non-empty text query, so this helper uses a broad
JavaScript keyword search.
Number of packages to return (default: 20, max: 250)
Optionalsignal: AbortSignalOptional AbortSignal to cancel the request
Search results including packages, scores, and total count
Returns a UserResource for a given npm username, providing authenticated access to the registry user profile and user package list.
These endpoints require a registry auth token.
The npm username (e.g. 'pilmee')
A user resource with get() and packages() methods
Main entry point for the npm Registry API client.
Example