# PyPI Package Intelligence — Downloads, Risk & Health (AI) (`noniner/pypi-package-intelligence`) Actor

Analyze any PyPI (Python) package: download trend, dependencies, maintenance recency, maintainers, license and an AI risk read (unmaintained, yanked, heavy deps). For dependency due diligence and supply-chain risk.

- **URL**: https://apify.com/noniner/pypi-package-intelligence.md
- **Developed by:** [Fredrik Hansson](https://apify.com/noniner) (community)
- **Categories:** Developer tools, AI, Automation
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$100.00 / 1,000 package analyzeds

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

## PyPI Package Intelligence — Downloads, Risk & Health (AI)

**Before you add a Python dependency, know what you're pulling in.** Give this Actor a list of PyPI package names and it turns each one into a clear intelligence record: how often it's downloaded, how many dependencies it drags in, when it was last released, who maintains it, its license — and an **AI risk read** that tells you plainly whether a package is active, stale, or effectively abandoned.

You bring the package names. It hands back a dependency due-diligence sheet.

***

### The flow

```
1. Paste PyPI package names        2. The Actor gathers facts            3. Get an AI risk read
   (requests, flask, numpy,   →       PyPI JSON API + pypistats     →      downloads · deps · age ·
    distribute, ...)                   (public, no API key)                 license · maintenance · flags
```

1. **Paste PyPI (Python) package names** into the `packages` field — one per line.
2. **The Actor pulls public data** for each: the [PyPI JSON API](https://pypi.org/) for metadata, versions, classifiers, dependencies and license, and [pypistats.org](https://pypistats.org/) for download counts. No API key, no scraping of login-walled pages.
3. **The AI layer reads the facts** and returns a maintenance signal, a popularity tier, concrete risk flags and a two-sentence summary — grounded only in the data, never invented.

***

### What you get per package

For every package, the Actor returns:

1. **Identity & release** — `latestVersion`, `summary`, `versionCount`, `lastRelease` (ISO timestamp) and `lastReleaseAgeDays` (how long since the newest release).
2. **Reach** — `weeklyDownloads` and `monthlyDownloads` from pypistats, so you can tell a ubiquitous library from a weekend experiment.
3. **Footprint** — `dependenciesCount` (how many packages it requires), `pythonVersions` it declares support for, and `license`.
4. **Maintenance signals** — `maintainersCount`, `developmentStatus` (e.g. `5 - Production/Stable`, `7 - Inactive`), `yanked`, and the `repository` URL.

Then the **AI layer** (OpenAI `gpt-4o-mini`, a fast and low-cost model) adds:

- **`maintenanceSignal`** — `active`, `maintained`, `stale`, or `abandoned`, from release recency and status.
- **`popularityTier`** — `niche`, `growing`, `popular`, or `ubiquitous`, from download volume.
- **`riskFlags`** — short, data-backed phrases: `"unmaintained (last release >18mo)"`, `"marked Inactive"`, `"yanked release"`, `"single maintainer"`, `"no license declared"`, `"heavy dependency tree"`.
- **`aiSummary`** — two factual sentences on the package and its risk posture.
- **`suggestedAlternatives`** — only well-known, widely-trusted substitutes for the same job, else `[]`.

***

### Three ways people use it

- **Python dependency due diligence** — before a new library lands in `requirements.txt` or `pyproject.toml`, run a **PyPI package analysis** to see downloads, license, dependency count and whether it's still maintained. Catch a `7 - Inactive`, a yanked release or a single-maintainer bus factor *before* it's in your build.
- **Supply-chain risk** — audit an existing dependency list for **Python dependency risk**: surface **unmaintained packages**, stale projects and heavy dependency trees across your whole stack in one run. A standing input for your **supply chain** security reviews.
- **Library selection** — comparing candidates for the same job? Line them up and let download tier, maintenance signal and `suggestedAlternatives` make the call obvious.

Keywords: PyPI package analysis, Python dependency risk, supply chain, unmaintained packages.

***

### Input

| Field | Type | Notes |
|---|---|---|
| `packages` | array | **Required.** PyPI package names, one per line (e.g. `requests`, `flask`). Version pins and `pypi.org/project/...` URLs are tolerated and normalised. |
| `maxResults` | integer | Cap how many packages to analyze. Default `200`. |
| `maxConcurrency` | integer | Packages processed in parallel. Default `6`. |
| `model` | string | OpenAI model override. Default `gpt-4o-mini`. |

#### Minimal input example

```json
{
  "packages": ["requests", "flask", "distribute"]
}
```

***

### Output example

```json
{
  "package": "requests",
  "latestVersion": "2.32.3",
  "summary": "Python HTTP for Humans.",
  "license": "Apache-2.0",
  "pythonVersions": ["3.8", "3.9", "3.10", "3.11", "3.12"],
  "weeklyDownloads": 123456789,
  "monthlyDownloads": 512345678,
  "lastRelease": "2024-05-29T15:37:49.000000Z",
  "lastReleaseAgeDays": 164,
  "versionCount": 152,
  "maintainersCount": 1,
  "dependenciesCount": 5,
  "yanked": false,
  "developmentStatus": "5 - Production/Stable",
  "repository": "https://github.com/psf/requests",
  "maintenanceSignal": "maintained",
  "popularityTier": "ubiquitous",
  "riskFlags": [],
  "suggestedAlternatives": ["httpx", "urllib3"],
  "aiSummary": "requests is a ubiquitous, permissively licensed HTTP client with hundreds of millions of monthly downloads and a stable release line. It carries a light dependency tree and shows no significant supply-chain risk."
}
```

A package that is not found on PyPI comes back with the same shape plus an `error` field (and is not charged).

***

### Pay-per-event pricing

This Actor uses **pay-per-event** billing with a single event:

| Event | Price | Charged when |
|---|---|---|
| `package-analyzed` | $0.10 | Once per package successfully analyzed (facts gathered + AI risk read produced). |

The Actor logs its OpenAI token usage and the estimated AI cost per package at the end of every run, so the event price always stays safely above the model cost.

***

### Data source

Everything comes from **public, key-less sources**: the PyPI JSON API (`https://pypi.org/pypi/<pkg>/json`) for metadata, versions, classifiers, dependencies and license, and pypistats.org (`https://pypistats.org/api/packages/<pkg>/recent`) for download counts. Rate limiting or a missing stats record is handled gracefully — the record still ships, just without download numbers.

***

### Setup

The AI layer calls the OpenAI API. Set the environment variable / secret **`OPENAI_API_KEY`** on the Actor. The fact-gathering step (downloads, dependencies, license, maintenance) needs no key.

***

### Use it from an AI agent (Apify MCP server)

This Actor is available through the [Apify MCP server](https://mcp.apify.com), so AI agents (Claude, ChatGPT, or anything that speaks MCP) can call it as a tool — hand it a list of `packages` and read back the intelligence records — with no custom integration code.

***

### Run it locally

```bash
npm install
## put your input in storage/key_value_stores/default/INPUT.json
export OPENAI_API_KEY=sk-...
apify run -p
```

***

### Related actors

- [npm Package Intelligence](https://apify.com/noniner/npm-package-intelligence) — The Node.js twin of this Actor: downloads, dependencies, maintenance and AI risk for any npm package.
- [GitHub Repo Analyzer](https://apify.com/noniner/github-repo-analyzer) — Health, activity and maintenance signals for any GitHub repository.
- [CVE Vulnerability Lookup](https://apify.com/noniner/cve-vulnerability-lookup) — Look up known vulnerabilities and severity for packages and software.
- [B2B Tech Stack Detector](https://apify.com/noniner/b2b-tech-stack-detector) — Detect the technologies a company's website is built on.

***

**Part of the [No Niner](https://noniner.io) toolkit** — no-code web scraping, enrichment & AI data tools, all pay-per-use. Browse the full set at **[noniner.io](https://noniner.io)**.

# Actor input Schema

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

PyPI (Python) package names to analyze. One per line (e.g. requests, flask, numpy).

## `maxResults` (type: `integer`):

Max packages to analyze. One pay-per-event charge per package analyzed.

## `maxConcurrency` (type: `integer`):

How many packages to process in parallel.

## `model` (type: `string`):

Override the model (default gpt-4o-mini).

## Actor input object example

```json
{
  "packages": [
    "requests",
    "flask"
  ],
  "maxResults": 200,
  "maxConcurrency": 6
}
```

# Actor output Schema

## `packages` (type: `string`):

All analyzed package records in the default dataset.

# 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": [
        "requests",
        "flask"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("noniner/pypi-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": [
        "requests",
        "flask",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("noniner/pypi-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": [
    "requests",
    "flask"
  ]
}' |
apify call noniner/pypi-package-intelligence --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,noniner/pypi-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/kDLJ4D373f4lNvBQW/builds/rlakaXzjKsAZ3b5tD/openapi.json
