# npm packages - search, metadata, downloads (public registry) (`retrainmapdata/npm-packages`) Actor

npm registry scraper on the public API: one row per package - name, latest version, description, keywords, license, author, maintainers, repository, homepage, dependency count, last publish date, weekly downloads, npm URL. Search by keyword or give package names (scoped too). $5 per 1,000 rows.

- **URL**: https://apify.com/retrainmapdata/npm-packages.md
- **Developed by:** [RetrainMap Data](https://apify.com/retrainmapdata) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 records

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## npm packages - search, metadata, downloads (public registry)

**Returns:** one row per npm package: name, latest version, description, keywords, license, author, publisher, maintainers, repository, homepage, dependency counts (runtime / dev / peer) and list, engines, publish dates, weekly downloads, npm URL.
**Input:** `{ "query": "keywords:cli not:deprecated", "max_records": 100 }` or `{ "package_names": ["express", "@types/node", "lodash"] }`.
**Price:** $5.00 per 1,000 rows ($0.005 per package row) plus $0.10 per run. Pay per event; no subscription.

One row per package from the public npm registry (https://registry.npmjs.org, no key):
search by keyword with the registry's own search endpoint and qualifiers
(`author:`, `maintainer:`, `keywords:`, `scope:`, `not:deprecated`, `is:unstable`), or give
exact package names, scoped ones included. Each row merges the search record, the latest
version's manifest (dependencies, repository, homepage, license, engines, size) and the
last-week download count from api.npmjs.org - normalised, one flat row per package.

**The prefilled input (`keywords:cli not:deprecated`, 100 rows, downloads on) succeeds
within 5 minutes and returns rows** - Apify auto-tests it daily.

### Data source and status

| | |
|---|---|
| Publisher | npm, Inc. (GitHub) - the public npm registry |
| API | https://registry.npmjs.org/-/v1/search (search), https://registry.npmjs.org/{name} and /{name}/latest (metadata), https://api.npmjs.org/downloads/point/last-week/{names} (downloads) - public, no key (documentation: https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md and .../download-counts.md) |
| What this Actor reads | Search pages of up to 250 (`from` paging), one small `/latest` manifest per search hit, the full document for packages given by name, downloads 128 unscoped names per request; at most one request per 500 ms by default |
| Refresh cadence | Live on every run; `fetched_at` on each row is the fetch time. Download counts are npm's last-week point count (the period is in `weekly_downloads_period`) |
| Terms | npm's Open Source Terms (https://docs.npmjs.com/policies/open-source-terms) and the registry's public-API documentation apply; the registry asks bulk consumers to identify themselves - this Actor sends a product-token User-Agent and a `From:` contact. Package metadata is published by its authors under their own licenses (`license` column) |
| Known caveats | Search order and `search_score` are the registry's own; a query can page through a few thousand results at most (the registry returns empty pages beyond that). `weekly_downloads` is null when the downloads API has no data (very new or unpublished packages). `last_publish_date` for search hits is the search record's `date`; for named packages it is the latest version's publish time from the full document. Package names that do not exist are listed in the run summary, not guessed |

Honesty note: the rows are the registry's own fields merged and flattened - repository
URLs are normalised to `https://` form, `description` is cut at 3,000 characters, and
nothing is inferred, summarised or classified by this Actor; a run stops with an error
rather than guess when the registry's shape changes.

Identification: the requests carry a product-token User-Agent and the operator's
contact address in the standard `From:` header (RFC 9110 §10.1.2).

### Input

| Field | Type | Meaning |
|---|---|---|
| `query` | string | Registry search text with optional qualifiers (`keywords:cli`, `author:sindresorhus`, `scope:types`, `not:deprecated`) |
| `package_names` | array of strings | Exact names, e.g. `express`, `@types/node` |
| `max_records` | integer | Default 100, at most 5,000 |
| `include_downloads` | boolean | Default true - last-week download counts |
| `request_interval_ms` | integer | Default 500 (floor 200) |
| `contact_email` | string | Sent in the `From:` header |

Example - the 200 most relevant React component packages that are not deprecated:

```json
{ "query": "react component not:deprecated", "max_records": 200 }
```

### Output (dataset row)

`name`, `version`, `description` (<= 3,000 chars), `keywords`, `license`, `author`,
`publisher`, `maintainers`, `repository`, `homepage`, `bugs`, `dependencies_count`,
`dev_dependencies_count`, `peer_dependencies_count`, `dependencies` (names),
`engines_node`, `types` (ships type definitions), `unpacked_size_bytes`, `file_count`,
`deprecated` (message or null), `dist_tags` (named packages only), `versions_count` (named
packages only), `created` (named packages only), `last_publish_date`, `weekly_downloads`,
`weekly_downloads_period`, `search_score`, `url`, `matched_by` (`search` / `name`),
`fetched_at`, `source`.

A run summary (filters, the registry's own match total, names not found, requests,
whether the pay-per-event budget stopped the run) is stored as `RUN_SUMMARY` in the run's
key-value store.

### Pricing (pay per event)

| Event | Price |
|---|---|
| `run-start` - once per run | $0.10 |
| `record` - per row written | $0.005 |

The prefilled pull (<= 100 rows) costs at most $0.60; 1,000 packages cost $5.10. Rows stop
when your run's maximum charge is reached; the run summary says so.

### Operator

Steelyard Ventures LLC (RetrainMap) - info@steelyardclinical.com. Not affiliated with npm,
Inc. or GitHub. The Actor writes only to its own dataset and key-value store; it stores no
credentials and sends nothing else.

# Actor input Schema

## `query` (type: `string`):

Full-text query for the registry search endpoint (registry.npmjs.org/-/v1/search). The registry's own qualifiers work: author:sindresorhus, maintainer:, keywords:cli, scope:types, not:deprecated, is:unstable, boost-exact:false. Empty is fine when package\_names is given.

## `package_names` (type: `array`):

Optional exact package names, scoped ones included (express, @types/node). Each costs one registry request; names that do not exist are listed in the run summary.

## `max_records` (type: `integer`):

Stop after this many package rows. Every search hit costs one extra small request for its dependency list, so 1,000 rows take roughly 10 minutes at the default rate.

## `include_downloads` (type: `boolean`):

Add last-week download counts from api.npmjs.org (128 unscoped packages per request; scoped packages one per request).

## `request_interval_ms` (type: `integer`):

Politeness delay towards registry.npmjs.org / api.npmjs.org. The floor is 200 ms.

## `contact_email` (type: `string`):

Sent in the standard From: request header so the data owner can reach the operator (RFC 9110 s10.1.2).

## Actor input object example

```json
{
  "query": "keywords:cli not:deprecated",
  "max_records": 100,
  "include_downloads": true,
  "request_interval_ms": 500,
  "contact_email": "info@steelyardclinical.com"
}
```

# Actor output Schema

## `results` (type: `string`):

One row per package with the latest version's metadata and last-week downloads.

## `results_csv` (type: `string`):

The same rows as a CSV file.

# 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 = {
    "query": "keywords:cli not:deprecated",
    "max_records": 100,
    "include_downloads": true
};

// Run the Actor and wait for it to finish
const run = await client.actor("retrainmapdata/npm-packages").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 = {
    "query": "keywords:cli not:deprecated",
    "max_records": 100,
    "include_downloads": True,
}

# Run the Actor and wait for it to finish
run = client.actor("retrainmapdata/npm-packages").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 '{
  "query": "keywords:cli not:deprecated",
  "max_records": 100,
  "include_downloads": true
}' |
apify call retrainmapdata/npm-packages --silent --output-dataset

```

## MCP server setup

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

```

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/UZrzK7YklE9WULdhY/builds/39paLPvl8iYdbiPHd/openapi.json
