Everything an AI agent can do with the npm API.

A reference guide for building AI agents: every method, how to authenticate, and the permissions each one needs.

Endpoints29
API versionUnversioned
Last updated23 June 2026
Orientation

How the npm Registry API works.

The npm API is how an app or AI agent works with the npm registry: reading a package's metadata, searching for packages, publishing new versions, and moving distribution tags like latest or beta. Access is granted through an access token in an Authorization header, and a granular token can be limited to read-only or read-and-write on specific packages, scopes, and organizations, while public reads need no token at all. The registry is largely unversioned, and it can push a change event to a webhook when a watched package or scope is updated.

29Endpoints
10Capability groups
15Read
14Write
2Permissions
Authentication
Calls authenticate with an access token sent as 'Authorization: Bearer '. As of November 2025 the supported token type is the granular access token, created on the npm website, which sets read-only or read-and-write access and can be limited to specific packages, scopes, and organizations. Classic tokens, which had coarse account-wide reach, can no longer be created and were revoked. Public reads, such as package metadata, search, and download counts, need no token at all.
Permissions
A granular access token carries one access level, read-only or read-and-write, applied to the packages, scopes, and organizations it is scoped to. Read access reads metadata and private package contents; read-and-write also publishes versions, moves dist-tags, deprecates, and changes access. Organization access on a token manages members and teams but cannot publish that organization's packages. A token with write access enforces two-factor authentication by default, with an optional bypass for automation.
Versioning
The registry is largely unversioned and path-based; most package operations are served from a single, continuously updated surface with no version header to pin. The search and account areas live under their own path prefixes, such as /-/v1/search and /-/npm/v1, and download statistics live on a separate host. Notable behavior changes ship through npm's dated changelog rather than a versioned API.
Data model
Each package is a JSON document, the packument, holding its dist-tags and every version's manifest, read from /{package} and a single version from /{package}/{version}. Publishing PUTs an updated document with the tarball attached, and the same document mechanism deprecates a version. Distribution tags, such as latest and beta, map a label to a version under /-/package/{package}/dist-tags. Accounts, tokens, orgs, and teams live under the /-/ prefix, and download counts come from a separate host.
Connect & authenticate

Connection & authentication methods.

How an app or AI agent connects to npm determines what it can reach. Most calls go to the registry, with separate hosts for download statistics and webhooks, and a Bearer token decides what each route can read or write.

Ways to connect

Registry API

The registry API answers at https://registry.npmjs.org. Most calls are path-based reads and writes against package documents, with no version header to pin. It is what the npm command-line tool itself calls.

Best forConnecting an app or AI agent to npm.
Governed byThe access token and the read or write it carries on each package or scope.
Docs ↗

Download counts API

The download statistics API answers at https://api.npmjs.org/downloads. It serves public total and per-day counts per package and needs no token.

Best forReading public download statistics for packages.
Governed byPublic access, no token required.
Docs ↗

Webhooks

Webhooks fire when a watched package or scope changes and post the event to a receiver URL. Each delivery carries an x-npm-signature header, computed from the hook's shared secret, so the receiver can confirm it came from npm.

Best forReacting to package or scope changes without polling.
Governed byThe token used to manage hooks, and the shared secret on each hook.
Docs ↗

Trusted publishing (OIDC)

Trusted publishing lets a CI job publish without a long-lived token, exchanging a short-lived OpenID Connect credential for publish access. It supports GitHub Actions and GitLab CI/CD.

Best forPublishing from CI without storing a token.
Governed byA short-lived, job-specific credential rather than a stored token.
Docs ↗
Authentication

Granular access token

A granular access token sets read-only or read-and-write access and can be limited to chosen packages, scopes, and organizations, with an expiry of up to 90 days and optional IP allow-lists. As of November 2025 it is the only supported token type, and a token with write access enforces two-factor authentication by default. It is the least-privilege choice for connecting to npm.

TokenGranular access token
Best forLeast-privilege access to specific packages
Docs ↗

Trusted publishing (OIDC)

Trusted publishing exchanges a short-lived OpenID Connect credential from GitHub Actions or GitLab CI for publish access, so no long-lived token is stored. npm promotes it as the safer way to publish from automation.

TokenShort-lived OIDC credential
Best forPublishing from CI pipelines
Docs ↗

Classic token (legacy)

Classic tokens came in read-only, publish, and automation types, but with coarse account-wide reach rather than per-package limits. New classic tokens can no longer be created, and npm revoked existing ones in November 2025.

TokenClassic access token
Best forLegacy integrations, now retired
Docs ↗
Capability map

What an AI agent can do on npm.

The npm Registry API is split into areas an agent can act on, such as package metadata, search, publishing, distribution tags, and organization membership. Each area has its own methods and its own permissions, and writes change what every npm user installs.

Package metadata

3 endpoints

Read a package's full metadata document, read a single version, and read the registry's own status.

These are reads, but the full document for a popular package can be very large.
View endpoints

Search

1 endpoint

Search the registry for packages by text, with weighting for quality, popularity, and maintenance.

Reads only; returns public package data.
View endpoints

Publishing

3 endpoints

Publish a new package version, deprecate a version, and unpublish a version.

Writes here change what every npm user installs.
View endpoints

Distribution tags

3 endpoints

List the tags on a package, point a tag such as latest or beta at a version, and remove a tag.

Moving the latest tag changes the default install for everyone.
View endpoints

Download counts

2 endpoints

Read total and per-day download counts for one or many packages over a period.

Reads only; public download statistics.
View endpoints

Account & tokens

4 endpoints

Read the authenticated profile and list, create, or revoke access tokens.

Creating or revoking tokens changes who can act as the account.
View endpoints

Package access

3 endpoints

Read who can reach a package, read its visibility, and grant or revoke team access to it.

Writes here change who can publish or install a package.
View endpoints

Orgs & teams

4 endpoints

List and change organization members and teams, and the packages a team can reach.

Writes here change who belongs to an organization.
View endpoints

Security advisories

1 endpoint

Look up known security advisories for a set of packages and version ranges.

Reads only; returns advisory data.
View endpoints

Webhooks

5 endpoints

List, create, update, and remove webhooks that fire when a package or scope changes.

Writes here change which events are delivered and where.
View endpoints
Endpoint reference

Every npm Registry API method.

Filter by method, access, or permission, or search any path. Select a row for version detail, rate limits, the related webhook event, and the source.

MethodEndpointWhat it doesAccessPermissionVersion

Package metadata

Read a package's full metadata document, read a single version, and read the registry's own status.3

Public packages return without a token. A smaller install-oriented document is returned when the Accept header is application/vnd.npm.install-v1+json, since the full document can exceed 10MB for a package with many versions. A granular access token needs at least read access to a private package.

Acts onpackage
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventpackage-change
Rate limitStandard limits apply

Public versions return without a token. A granular access token needs at least read access to a private package.

Acts onpackage version
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

No token required.

Acts onregistry
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply
Search the registry for packages by text, with weighting for quality, popularity, and maintenance.1

Takes text, size, and from for paging, plus quality, popularity, and maintenance weights between 0 and 1 that tune the ranking. No token required for public results.

Acts onsearch result
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Publishing

Publish a new package version, deprecate a version, and unpublish a version.3

The body is a packument with name, dist-tags, versions, access, and the tarball in _attachments. Needs a token with read and write to the package or scope; trusted publishing through GitHub Actions or GitLab CI can supply a short-lived credential instead of a long-lived token.

Acts onpackage version
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventpackage-change
Rate limitStandard limits apply

Sent as an update to the package document with a deprecated field, not a separate path. Leaves the version installable, unlike unpublishing. Needs read and write to the package.

Acts onpackage version
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventpackage-change
Rate limitStandard limits apply

npm recommends deprecating rather than unpublishing, since removing a public version can break anything that depends on it. Unpublishing a public package is restricted by npm's unpublish policy, generally to within 72 hours of publishing. Needs read and write to the package.

Acts onpackage version
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventpackage-change
Rate limitStandard limits apply

Distribution tags

List the tags on a package, point a tag such as latest or beta at a version, and remove a tag.3

Distribution tags are human-readable labels, such as latest, beta, or next, that map to a version. Listing needs read access to a private package.

Acts ondist-tag
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Moving the latest tag changes the version npm installs by default for everyone. Needs read and write to the package.

Acts ondist-tag
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventpackage-change
Rate limitStandard limits apply

The latest tag cannot be removed. Needs read and write to the package.

Acts ondist-tag
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventpackage-change
Rate limitStandard limits apply

Download counts

Read total and per-day download counts for one or many packages over a period.2

Served from api.npmjs.org, not the registry host. Periods are last-day, last-week, last-month, last-year, or a YYYY-MM-DD:YYYY-MM-DD range. Up to 128 comma-separated packages can be requested at once, except scoped packages. No token required.

Acts ondownload stat
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Served from api.npmjs.org. Standard queries reach back at most 18 months, with data from 10 January 2015 onward. No token required.

Acts ondownload stat
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Account & tokens

Read the authenticated profile and list, create, or revoke access tokens.4

Returns the profile object for the token's owner, or 401 when unauthenticated. Any valid token works.

Acts onuser
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Returns token metadata, never the secret values. Needs an authenticated token.

Acts ontoken
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

This endpoint creates legacy classic tokens, whose creation npm disabled across the website, CLI, and API in November 2025. Granular access tokens, the supported type, are created only on the npm website.

Acts ontoken
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Identified by the token's hash, not its secret value. Needs an authenticated token.

Acts ontoken
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Package access

Read who can reach a package, read its visibility, and grant or revoke team access to it.3

Needs read access to the package or its scope.

Acts onaccess grant
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Changes who can install or publish the package. Needs read and write to the package or scope.

Acts onaccess grant
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs organization-management access on the token, granted per organization.

Acts onaccess grant
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Orgs & teams

List and change organization members and teams, and the packages a team can reach.4

Needs organization access on the token.

Acts onorg membership
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

A token granted organization access can manage organization settings, teams, and members, but cannot publish that organization's packages. Needs organization access.

Acts onorg membership
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs organization access on the token.

Acts onorg membership
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs organization access on the token.

Acts onteam
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Security advisories

Look up known security advisories for a set of packages and version ranges.1

Takes a body of package names mapped to version arrays and returns the advisories that match. This is the data behind npm audit.

Acts onadvisory
Permission (capability)None required
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Webhooks

List, create, update, and remove webhooks that fire when a package or scope changes.5

Served from the hooks host. Needs an authenticated token.

Acts onwebhook
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

A hook watches a specific package, a user scope, an organization scope, or all packages a maintainer owns. Deliveries carry an x-npm-signature header so the receiver can confirm they came from npm. Needs an authenticated token.

Acts onwebhook
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventpackage-change
Rate limitStandard limits apply

Needs an authenticated token.

Acts onwebhook
Permission (capability)read
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs an authenticated token.

Acts onwebhook
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply

Needs an authenticated token.

Acts onwebhook
Permission (capability)publish
VersionAvailable since the API’s base version
Webhook eventNone
Rate limitStandard limits apply
No endpoints match those filters.
Webhooks

Webhook events.

npm can notify an app or AI agent when a package or scope changes, instead of the app repeatedly asking. npm posts the event payload to a registered webhook URL, signed so the receiver can confirm it came from npm.

EventWhat it signalsTriggered by
package:changeFires when a watched package changes, such as a new version being published, a dist-tag moving, or a version being deprecated or unpublished. A hook can watch a single package, a user scope, an organization scope, or all packages a maintainer owns./{package}
/{package}
/{package}/-rev/{rev}
/-/package/{package}/dist-tags/{tag}
/-/package/{package}/dist-tags/{tag}
/v1/hooks/hook
No events match that search.
Rate limits & pagination

Rate limits, pagination & request size.

npm limits how fast an app or AI agent can call the registry. Anonymous callers are held to a lower rate than authenticated ones, and going over returns a 429 response that says to slow down and retry.

Request rate

npm rate-limits all registry APIs and returns HTTP 429 when a caller exceeds the limit. Anonymous requests are held to a lower rate than authenticated ones, so sending a token raises the ceiling. npm does not publish exact per-minute numbers; its acceptable-use guidance treats up to about five million registry requests per month as reasonable, and npm contacts organizations that consistently go beyond that. A client should handle 429 by backing off and retrying.

Pagination

Search paginates through the size and from query parameters on /-/v1/search, where size sets how many results to return and from is the offset into the result set. Package metadata is returned as one document per package rather than a paged list, so reading a popular package means downloading its full version history in a single response unless the abbreviated install format is requested.

Request size

Requests and responses are JSON, except publishing, which sends the package tarball as a base64 attachment inside the package document. A full metadata document can exceed 10MB uncompressed for a package with many versions, which is why the abbreviated install format exists. Download-count bulk queries accept up to 128 comma-separated packages per request.

Errors

Status codes & error handling.

The status codes an agent should handle, and what to do about each.

StatusCodeMeaningWhat to do
401UnauthorizedAuthentication is missing or the token is invalid or expired.Send a valid token in the Authorization Bearer header.
403ForbiddenThe token is valid but lacks the permission for the action, such as publishing to a package or scope it cannot write.Grant the token read-and-write access to the package or scope, then retry.
404Not FoundThe package or version does not exist, or a private package is hidden from a token that cannot see it.Confirm the package name and version, and that the token has access to a private package.
429Too Many RequestsThe request rate limit was exceeded. Anonymous callers are limited more tightly than authenticated ones.Slow down and retry after a delay; authenticating raises the allowed rate.
Versioning & freshness

Version history.

The npm registry is largely unversioned and path-based, with most methods served from a single, continuously updated surface. The search and account areas carry their own path prefixes, and notable changes ship through npm's dated changelog rather than a version header.

Version history

What changed, and when

Latest versionUnversioned
UnversionedCurrent version
Path-based, continuously updated registry

The npm registry has no dated API version to pin. Most package operations are served from a single, continuously updated surface, with the search and account areas under their own path prefixes. Notable changes are announced through npm's dated changelog rather than a version header, so an integration tracks behavior over time rather than pinning a version.

What changed
  • Package metadata, publishing, dist-tags, and search served from path-based routes with no version header
  • Search under /-/v1/search and account, token, org, and team operations under the /-/ prefix
  • Download statistics served from a separate host, api.npmjs.org
2025-11-05Requires migration
Classic token creation disabled, granular token changes

npm disabled creation of classic tokens across the website, command-line tool, and API, and revoked existing classic tokens on 19 November 2025. New tokens with write access now enforce two-factor authentication by default, and existing granular tokens with write access were capped at a 90-day maximum lifetime. It was announced on Wednesday 5 November 2025.

What changed
  • New classic tokens can no longer be created on the website, CLI, or API
  • Existing classic tokens revoked on 19 November 2025
  • New tokens with write permissions enforce 2FA by default, with an optional CI bypass
  • Existing granular tokens with write permissions capped at a 90-day maximum lifetime
2025-09-29Feature update
Token and authentication tightening announced

npm announced a rollout that shortened granular token lifetimes, began retiring classic tokens, limited two-factor setup options, and promoted trusted publishing. Granular tokens moved to a default 7-day expiry, down from 30, and a 90-day maximum, down from unlimited. It was announced on Monday 29 September 2025.

What changed
  • Granular token default expiry reduced to 7 days and maximum to 90 days
  • Five-week rollout to revoke classic tokens, completing in mid-November
  • New time-based one-time-password two-factor setups to be disabled in favor of other methods
  • Trusted publishing through GitHub Actions and GitLab CI promoted as the token-free path

There is no version header to pin; an integration tracks behavior changes through the npm changelog.

npm changelog ↗
Questions

npm Registry API, answered.

What kind of token does an agent need to call the npm registry?+
An access token sent as 'Authorization: Bearer '. As of November 2025, the supported type is the granular access token, created on the npm website, which can be limited to specific packages, scopes, and organizations and set to read-only or read-and-write. Public reads such as package metadata, search, and download counts need no token. Classic tokens can no longer be created and were revoked.
What's the difference between the full and abbreviated package metadata?+
Both come from the same path, /{package}. By default it returns the full document with every version's complete manifest, author, and history, which can exceed 10MB uncompressed for a package with many versions. Sending the Accept header application/vnd.npm.install-v1+json returns an abbreviated document with only the fields needed to install, which is far smaller and what npm itself uses.
Should an agent unpublish or deprecate a version?+
Deprecate in almost all cases. Deprecating updates the package document with a warning message but leaves the version installable, so nothing that depends on it breaks. Unpublishing removes the version and its tarball, and for public packages npm's policy generally allows it only within 72 hours of publishing, because removing a depended-on version breaks other people's installs.
How do dist-tags work, and why does moving latest matter?+
Distribution tags are labels, such as latest, beta, or next, that each point at one version. Listing them reads /-/package/{package}/dist-tags, and a PUT to that path with a tag points it at a version. The latest tag is special: it is the version npm installs by default when no version is given, so moving it changes what every new install gets.
What are the rate limits?+
npm rate-limits all registry APIs and returns HTTP 429 when a caller goes over. Authenticated callers get a higher rate than anonymous ones, so sending a token helps. npm does not publish exact per-minute figures; its acceptable-use guidance treats up to about five million registry requests per month as reasonable and reaches out to organizations that consistently exceed that. Clients should back off and retry on a 429.
Can an agent get notified when a package changes instead of polling?+
Yes, through webhooks. A hook can watch a specific package, a user scope, an organization scope, or all packages a maintainer owns, and npm posts a payload to a receiver URL when the watched target changes, such as a new version or a moved dist-tag. Each delivery carries an x-npm-signature header, computed from the hook's shared secret, so the receiver can confirm the payload came from npm.
Is there a way to publish from CI without storing a long-lived token?+
Yes, through trusted publishing. A CI job on GitHub Actions or GitLab CI exchanges a short-lived OpenID Connect credential for publish access, so no long-lived token sits in the pipeline. npm promotes this as the safer alternative to a stored automation token.
Related

More developer API guides for agents

What is Bollard AI?

Control what every AI agent can do on npm.

Bollard AI sits between a team's AI agents and the npm registry. Grant each agent exactly the access it needs, read or write, package by package, and every call is checked and logged.

  • Set read, write, or full access per agent, never a shared npm token.
  • Denied by default, so an agent reaches only what has been explicitly allowed.
  • Every call recorded in plain English: who, what, where, and the decision.
npm
Release Agent
Read package metadata ResourceOffReadFull use
Publish a package version ActionOffReadFull use
Unpublish a version ActionOffReadFull use
Manage org members ResourceOffReadFull use
Per-agent access, set in Bollard AI, not in npm