npm

npm Registry API

The npm Registry API provides programmatic access to the npm package registry, the largest software registry in the world hosting over two million JavaScript packages. Developers can query package metadata, download tarballs, search for packages, and retrieve version-specific information. The API follows CouchDB-based conventions and serves package manifests in JSON format, enabling tools and services to integrate with the npm ecosystem for dependency resolution, package discovery, and automated workflows.

OpenAPI Specification

npm-registry-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: npm Hooks Downloads Registry API
  description: The npm Hooks API allows developers to subscribe to notifications about changes in the npm registry. Hooks send HTTP POST payloads to a configured URI whenever a package is changed, enabling developers to build integrations that respond to registry events in real time. Users can add hooks to follow specific packages, track all activity of given npm users, or monitor all packages within an organization or user scope. The API provides endpoints for creating, listing, updating, and deleting hook subscriptions. Note that npm hooks services have been deprecated as of July 2024.
  version: 1.0.0
  contact:
    name: npm Support
    url: https://www.npmjs.com/support
  termsOfService: https://docs.npmjs.com/policies/terms
servers:
- url: https://registry.npmjs.org
  description: npm Public Registry
security:
- bearerAuth: []
tags:
- name: Registry
  description: Registry metadata and status information.
paths:
  /:
    get:
      operationId: getRegistryMetadata
      summary: Get registry metadata
      description: Returns metadata about the npm registry, including document counts, storage sizes, and instance information. This endpoint follows the CouchDB database information convention.
      tags:
      - Registry
      responses:
        '200':
          description: Registry metadata retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RegistryMetadata'
components:
  schemas:
    RegistryMetadata:
      type: object
      description: Metadata about the npm registry instance, following CouchDB database information conventions.
      properties:
        db_name:
          type: string
          description: The name of the database, typically "registry".
        doc_count:
          type: integer
          description: The total number of documents in the registry.
        doc_del_count:
          type: integer
          description: The total number of deleted documents.
        update_seq:
          type: integer
          description: The current update sequence number.
        purge_seq:
          type: integer
          description: The current purge sequence number.
        compact_running:
          type: boolean
          description: Whether a database compaction is currently running.
        disk_size:
          type: integer
          description: Total disk size in bytes.
        data_size:
          type: integer
          description: Actual data size in bytes.
        instance_start_time:
          type: string
          description: Timestamp of when this registry instance started.
        disk_format_version:
          type: integer
          description: The version of the on-disk storage format.
        committed_update_seq:
          type: integer
          description: The last committed update sequence number.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: npm access token provided as a Bearer token.
externalDocs:
  description: npm Hooks Documentation
  url: https://blog.npmjs.org/post/145260155635/introducing-hooks-get-notifications-of-npm