# PyPI Package API - Versions, Dependencies & License (`stas_k/pypi-package-api`) Actor

Tired of package metadata spread across pages? One row per PyPI project: latest version, license, requires-python, release count, first and latest release date, dependencies and file sizes. A name PyPI does not have comes back free with a reason, so you pay only for projects that were really read.

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

## Pricing

$1.50 / 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

## PyPI Package API - Versions, Dependencies & License

Send PyPI project names and get one row per project: the version you asked for (or the
latest one), licence, `requires-python`, release count, first and latest release date,
dependencies, supported Python versions and the size of the release files. No API key, no
browser, no proxy.

A name that PyPI does not have is a **verdict**: the row comes back free with the reason, so
a dependency audit does not pay for packages that do not exist.

### Input

| field | what it is |
|---|---|
| `packages` | PyPI project names. Each line is a bare name (`requests`), a pinned version (`requests==2.31.0`) or a project link (`https://pypi.org/project/requests/`, optionally with a version). Names are compared the way PyPI compares them, so `Requests`, `zope.interface` and `zope-interface` are one project and are charged once. |
| `maxPackages` | How many packages to read and sell. Default 100, maximum 500. |
| `includeDependencies` | Put the release dependencies (`requires_dist`, first 50) into the row. On by default. |

### Output, one row per package

`name`, `version`, `summary`, `license`, `requiresPython`, `author`, `homepage`, `repository`,
`pythonVersions`, `dependencies`, `dependenciesCount`, `dependenciesTruncated`,
`releaseCount`, `firstRelease`, `latestRelease`, `filesInRelease`, `releaseSizeBytes`,
`classifiers`, `source`, `billable`, plus `actorIndex` and `actorInput` so the input order can
be rebuilt.

A pinned version returns that version, not the newest one: `numpy==2.0.0` reports 2.0.0 even
though PyPI has later releases, and the file sizes are those of that release.

Free status rows carry `status` and `reason` instead of package fields:

- `INVALID_INPUT` - the line is not a package name (a link on another host, an empty line, a
  name longer than PyPI allows).
- `DUPLICATE` - the same project was already sold in this run.
- `NOT_FOUND` - a valid name, but PyPI has no project behind it.
- `DUPLICATE` - the same project was already sold in this run. Two versions of one project
  are one project: the first line is sold, the second is free.
- `NOT_FOUND` - a valid name, but PyPI has no project behind it, or no release with the
  version you pinned. Nothing is charged for a version PyPI never published, and the reason
  names the latest version that does exist.
- `NOT_CHECKED_TIME`, `NOT_CHECKED_CAP`, `NOT_CHECKED_LIMIT`, `NOT_CHECKED_BILLING`,
  `NOT_CHECKED_ERROR` - the line was not read, and the reason says why: the deadline, your
  spending limit (`CAP`), the `maxPackages` slice (`LIMIT`), an unreadable price, or PyPI
  refusing the read.

### Price

$0.80 per 1,000 packages: `package-delivered` is charged once per project that came back with
metadata. A missing name, a malformed line and a duplicate cost nothing. The lowest spending
limit you can set per run is $0.05.

### Politeness and limits

PyPI's JSON API is keyless and asks callers to identify themselves, so every request carries a
`User-Agent` that names this actor and its page. Names go out one at a time, and there is a
short pause between chunks rather than between every name. The run reads at most 500 packages
per run; the rest comes back as free status rows with the
reason, never as a silent cut.

### What this actor does not do

- It does not search PyPI by keyword, author or classifier: it reads the names you give it.
- It does not download the package files or the source: `releaseSizeBytes` and
  `filesInRelease` describe the release, the files are yours to fetch.
- It does not resolve the dependency tree: `dependencies` is the declaration from the
  metadata, not a resolution, and it is capped at 50 entries with `dependenciesTruncated` set.
- It does not read the README or the long description of a project.

### Source

Data comes from the official PyPI JSON API (`pypi.org/pypi/<name>/json`), keyless. Metadata is
reported as PyPI returns it; empty fields stay `null` rather than being invented. PyPI is
operated by the Python Software Foundation and subject to its own terms of use.

# Actor input Schema

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

PyPI project names. Each line is either a name (requests), a name with a version (requests==2.31.0) or a project link (https://pypi.org/project/requests/). A name PyPI does not have comes back free with a reason.

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

Read at most this many packages. The rest comes back as a free status row with the reason, never as a silent cut.

## `includeDependencies` (type: `boolean`):

Put the release dependencies (requires_dist, first 50) into the row. Off keeps rows small.

## Actor input object example

```json
{
  "packages": [
    "requests",
    "numpy==2.0.0",
    "not-a-real-package-xyz-12345"
  ],
  "maxPackages": 100,
  "includeDependencies": true
}
```

# Actor output Schema

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

One row per line. Paid rows carry name, version, summary, license, requiresPython, homepage, repository, author, pythonVersions, dependencies, dependenciesCount, dependenciesTruncated, classifiers, releaseCount, firstRelease, latestRelease, filesInRelease, releaseSizeBytes, source, actorIndex, actorInput and billable true; every other row is a free status row with status, reason and no package fields. 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, rowsWritten, chargedEvents, deliveredUncharged, deliveredUnverified, chargeUncertain, writeErrors, cappedNotCharged, packagesNotFound, packagesRefused, packagesInvalid, packagesDuplicate, cutByLimit, cutByDeadline, cutByStop, byStatus, counterMismatch, stopReason, datasetNote, firstFailure, billingActive, priceNote, eventName, maxPackages, source and runId. A copy under RUN_SUMMARY-<runId> is kept in the named store pypi-package-summary.

# 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",
        "numpy==2.0.0",
        "not-a-real-package-xyz-12345"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("stas_k/pypi-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": [
        "requests",
        "numpy==2.0.0",
        "not-a-real-package-xyz-12345",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("stas_k/pypi-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": [
    "requests",
    "numpy==2.0.0",
    "not-a-real-package-xyz-12345"
  ]
}' |
apify call stas_k/pypi-package-api --silent --output-dataset

```

## MCP server setup

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