# 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
- **Features:** Limited permissions
- **Stats:** 3 total users, 2 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/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

## 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(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",
    "express"
  ]
}' |
apify call agentictools/package-intelligence --silent --output-dataset

```

## MCP server setup

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

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/yG0biuWxQrneMVBa9/builds/zGJTe7NfT7UCIRHIv/openapi.json
