# npm Package API - Metadata, Dependencies & Downloads (`stas_k/npm-package-api`) Actor

npm pages split the facts across two endpoints and never show a license next to the dependency tree, so you never get one honest answer about a package. This actor returns one row per package: version, license, dependencies, engines, unpacked size, maintainers and the registry's weekly downloads.

- **URL**: https://apify.com/stas_k/npm-package-api.md
- **Developed by:** [Stas K](https://apify.com/stas_k) (community)
- **Categories:** Developer tools, E-commerce, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.90 / 1,000 packages

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## npm Package API: metadata, dependencies and real weekly downloads

A package page on npmjs.com shows a version, a wall of README and a download chart that lives
somewhere else, and no single call gives you both the licence and the dependency tree. Pulling
that into a spreadsheet by hand is how audits never get finished. This actor reads the two
public registry endpoints and returns one row per package: version, licence, dependencies,
engines, unpacked size, maintainers, repository and the downloads the registry counted in its
own last full week.

No key, no login and no browser: both endpoints answer a plain JSON request.

### What one row means

One row is one package. The row is paid only when the registry really answered for that name.

| Field | Meaning |
| --- | --- |
| `packageName` | The name as the registry has it, scope included (`@types/node`) |
| `version` | The version `latest` points to right now |
| `description`, `keywords` | What the package says about itself |
| `license` | The licence string the current version declares |
| `homepage`, `repositoryUrl` | Where the package lives |
| `maintainersCount`, `maintainers` | How many maintainers, and up to five names |
| `dependenciesCount`, `dependencies` | The full count and up to `maxDependencies` names |
| `devDependenciesCount` | How many development dependencies the version declares |
| `enginesNode`, `deprecated` | The Node range it asks for, and the deprecation notice if any |
| `unpackedSizeBytes` | The unpacked size the registry publishes |
| `downloadsWeek`, `downloadsWindow` | Downloads in the registry's last full week, with its start and end dates |
| `url` | The package page |

Status rows are the free half of the dataset: `status`, `reason` and nothing a buyer could
mistake for package data. They are written in batches, so sort by `actorIndex` to restore the
input order.

### Input

- `packages`: a name (`react`), a scoped name (`@types/node`) or a link
  (`https://www.npmjs.com/package/react`).
- `maxDependencies`: how many dependency names to list (default 50, max 200); the count is
  always complete.
- `maxPackages`: how many list lines this run reads (default and max 200).

### Price

One delivered package is one paid event. A name the registry does not publish, a line that
cannot be read and anything past `maxPackages` are free and carry a reason. The lowest
spending limit you can set per run is $0.05, so a run that reads many packages never pays that
limit per package.

### What this actor does not do

- It does not read the whole version history: one row is the current version, not a changelog.
- It does not audit for vulnerabilities. It reports the facts the registry publishes; judging
  a package is your call, not a claim of this actor.
- It does not download, install or run any package, and it never touches your machine.
- It does not guess numbers. If the downloads endpoint stays silent, the row is delivered with
  `downloadsWeek: null` and an empty window, never with a made-up count.

### Notes

- Downloads come from the registry's own counter for the last complete week, so two runs a day
  apart usually report the same window; the window dates are on the row so a report never
  compares two different weeks.
- A name that is not published is a free `NOT_FOUND` row; a rate limit or a network failure is
  a different status again, because an unreadable registry says nothing about the package.
- The source is public and keyless, so the actor works without an account of yours.

# Actor input Schema

## `packages` (type: `array`):

Package names to read: a bare name such as react, a scoped name such as @types/node, or a link such as https://www.npmjs.com/package/react. The last line of the default list is not published, so it comes back free.

## `maxDependencies` (type: `integer`):

How many dependency names to list in the row. Default 50, maximum 200. The count of all dependencies is always reported in dependenciesCount.

## `maxPackages` (type: `integer`):

How many lines of the list this run reads. Default and maximum 200; a line past the cap comes back as a free NOT_CHECKED_CAP row that names the cap.

## Actor input object example

```json
{
  "packages": [
    "react",
    "@types/node",
    "express",
    "this-package-does-not-exist-xyz-9999"
  ],
  "maxDependencies": 50,
  "maxPackages": 200
}
```

# Actor output Schema

## `dataset` (type: `string`):

One row per package. Paid rows carry packageName, version, description, license, homepage, repositoryUrl, keywords, maintainersCount, maintainers, dependenciesCount, dependencies, devDependenciesCount, enginesNode, deprecated, unpackedSizeBytes, downloadsWeek, downloadsWindow and url; every other row is a free status row with a reason and no package data. Status rows are written in batches of up to 100, so sort by actorIndex to get the input order back.

## `summary` (type: `string`):

Counters of the run: requested, attempted, delivered, chargedEvents, deliveredUncharged, deliveredUnverified, chargeUncertain, packagesNotFound, packagesInvalid, cutByLimit, byStatus, counterMismatch, stopReason, datasetNote, firstFailure and priceNote. The bare RUN_SUMMARY lives in the default store of the run; a copy under RUN_SUMMARY-<runId> is kept in the named store npm-package-summary so two runs do not overwrite each other.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "packages": [
        "react",
        "@types/node",
        "express",
        "this-package-does-not-exist-xyz-9999"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("stas_k/npm-package-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "packages": [
        "react",
        "@types/node",
        "express",
        "this-package-does-not-exist-xyz-9999",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("stas_k/npm-package-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "packages": [
    "react",
    "@types/node",
    "express",
    "this-package-does-not-exist-xyz-9999"
  ]
}' |
apify call stas_k/npm-package-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,stas_k/npm-package-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/wQakgN71PDWmyeFqU/builds/pdqbrjMIiMJl6f6TB/openapi.json
