# Package Intelligence for npm and PyPI (`agentictools/package-intelligence`) Actor

Track npm and PyPI packages: download stats, versions, dependencies, license, and repository. For dependency monitoring and developer marketing.

- **URL**: https://apify.com/agentictools/package-intelligence.md
- **Developed by:** [Ken Agland](https://apify.com/agentictools) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.50 / 1,000 package returneds

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/platform/actors/running/actors-in-store#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

## Package Intelligence for npm and PyPI

Track npm and PyPI packages: download stats, versions, dependencies, license, and repository. For dependency monitoring and developer marketing.

### What it does

Looks up metadata and download stats for npm or PyPI packages, either from an explicit list of names or from an npm search, and returns one clean record per package: current version, license, homepage, repository, dependency count, last publish date, and downloads for the last day, week, and month.

### Example input

Look up a fixed list of npm packages:

```json
{ "packages": ["react", "express"], "registry": "npm" }
```

Search npm for packages matching a term:

```json
{ "search": "http client", "registry": "npm", "maxItems": 20 }
```

Look up PyPI packages by name:

```json
{ "packages": ["requests", "numpy"], "registry": "pypi" }
```

### Input

| Field | Type | Description |
|---|---|---|
| `packages` | array of strings | Package names to look up. Takes priority over `search`. |
| `search` | string | Full-text search term for npm. Used only when `packages` is empty. PyPI has no public search API, so this is ignored when `registry` is pypi. |
| `registry` | string | `npm` or `pypi`. Default `npm`. |
| `maxItems` | integer | How many packages to return in search mode. Default 25, max 250. |

### Output

Each dataset item is one package:

```json
{
  "name": "express",
  "registry": "npm",
  "description": "Fast, unopinionated, minimalist web framework",
  "version": "5.2.1",
  "license": "MIT",
  "homepage": "https://expressjs.com/",
  "repository": "https://github.com/expressjs/express",
  "downloadsLastDay": 13245678,
  "downloadsLastWeek": 92345678,
  "downloadsLastMonth": 453785456,
  "dependencyCount": 28,
  "lastPublished": "2025-12-01T20:49:43.268Z",
  "url": "https://www.npmjs.com/package/express"
}
```

#### Run summary (OUTPUT)

The run's default key-value store record `OUTPUT` holds an aggregate for the whole run:

```json
{
  "registry": "npm",
  "mode": "packages",
  "requested": 2,
  "packagesReturned": 2,
  "mostDownloaded": "express",
  "generatedFrom": "https://registry.npmjs.org"
}
```

### How it works

For npm, the Actor reads package metadata from the public npm registry (`registry.npmjs.org`), pulls download counts from the npm downloads API, and, in search mode, resolves names first through the npm search API. For PyPI, it reads metadata from `pypi.org` and download counts from `pypistats.org`. License is read from the package metadata, falling back to a `License ::` classifier for PyPI packages that only declare license via classifiers. A missing or rate-limited download source leaves the download fields null instead of failing the whole package. Requests use a descriptive User-Agent and retry on rate limits and server errors with backoff; unknown package names are skipped with a warning rather than stopping the run.

### Use cases

- Dependency monitoring: track version bumps, license changes, and dependency count over time.
- Developer marketing: size up adoption of a package or a competitor's package by download volume.
- Due diligence: check license and repository before adding a dependency.
- Discovery: search npm for packages in a given space and compare their traction.

# Actor input Schema

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

npm or PyPI package names to look up (for example "react", "express", "requests"). If set, this takes priority over the search term.

## `search` (type: `string`):

Full-text search term for the npm registry, used only when "Package names" is empty. PyPI has no public search API, so this is ignored when registry is pypi.

## `registry` (type: `string`):

Which package registry to query.

## `maxItems` (type: `integer`):

How many packages to return when using a search term. Ignored when "Package names" is set.

## Actor input object example

```json
{
  "packages": [
    "react",
    "express"
  ],
  "search": "http client",
  "registry": "npm",
  "maxItems": 25
}
```

# 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",
        "express"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("agentictools/package-intelligence").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",
        "express",
    ] }

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

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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",
    "express"
  ]
}' |
apify call agentictools/package-intelligence --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=agentictools/package-intelligence",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

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