# Package Docs Finder — PyPI, npm & Crates to Markdown (`thermn/package-docs-finder`) Actor

Extract clean, LLM-ready Markdown documentation by package name (PyPI, npm, crates.io) or direct URL. Supports version selection, topic filtering, and llms.txt for AI agents, MCP, and RAG.

- **URL**: https://apify.com/thermn/package-docs-finder.md
- **Developed by:** [Roman](https://apify.com/thermn) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 pages extracted

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/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 Docs Finder — PyPI, npm & Crates to Clean Markdown

Extract clean, **LLM-ready Markdown documentation** by library name (`PyPI`, `npm`, `crates.io`) or direct documentation URL — built for **AI coding agents (MCP)**, **RAG pipelines**, and **developers**.

Instead of feeding noisy 200 KB HTML pages full of sidebars, navbars, and scripts into an LLM context window, **Package Docs Finder** resolves the official documentation site, detects `llms-full.txt` / `llms.txt` when available, or extracts clean Markdown with preserved code block languages (`python`, `typescript`, `rust`, `bash`, etc.).

***

### Key Features

- **Zero-URL Package Resolution:** Pass just a package name (`httpx`, `zod`, `@tanstack/react-query`, `tokio`, `serde`) and ecosystem (`pypi`, `npm`, `crates`), or pass any documentation URL directly.
- **Version Selection:** Fetch documentation for a specific version (e.g. `3.1.2`), or leave `version` empty to automatically resolve the **latest current version**.
- **`llms.txt` Fast Path:** Automatically detects official `/llms-full.txt` and `/llms.txt` endpoints before crawling HTML sitemaps.
- **Engine-Aware DOM Cleaning:** Built-in profiles for **MkDocs Material**, **Docusaurus**, **Sphinx / Read the Docs**, **Mintlify**, **GitBook**, **`docs.rs` (rustdoc)**, and **GitHub READMEs** — strips menus, footers, copy buttons, and heading anchors while preserving headings, tables, breadcrumbs, and fenced code languages.
- **Dual Output for Agents & Humans:**
  - **Dataset (JSON):** Structured per-page records ideal for MCP tools, AI agents, and RAG ingestion.
  - **`DOCUMENTATION.md` (Key-Value Store):** A single combined Markdown file ready for one-click download into Claude Projects, Cursor, ChatGPT, NotebookLM, or Obsidian.
- **Fair Pay-Per-Event Billing:** Charges `page-extracted` **only** for valid extracted pages (`>= 50` characters). Typos, missing packages, or 404/stub pages are never charged.

***

### Input Parameters

| Field | Type | Default | Description |
|---|---|---|---|
| `query` *(required)* | `string` | `"httpx"` | Package name (e.g. `httpx`, `zod`, `tokio`) or direct documentation URL. |
| `ecosystem` | `string` | `"pypi"` | Package registry when `query` is a package name: `"pypi"`, `"npm"`, or `"crates"`. |
| `version` | `string` | `""` | Optional library version (e.g. `"3.1.2"`). Empty = latest version. |
| `topic` | `string` | `""` | Optional keyword filter (e.g. `"async"`, `"auth"`). Empty = full docs up to `maxPages`. |
| `maxPages` | `integer` | `30` | Maximum number of pages to extract in one run (`1`–`200`). |

#### Example 1: Targeted Lookup for AI Agents / MCP

```json
{
  "query": "httpx",
  "ecosystem": "pypi",
  "topic": "async",
  "maxPages": 5
}
```

#### Example 2: Full Library Export for RAG / NotebookLM

```json
{
  "query": "fastapi",
  "ecosystem": "pypi",
  "maxPages": 30
}
```

#### Example 3: Specific Package Version

```json
{
  "query": "openpyxl",
  "ecosystem": "pypi",
  "version": "3.1.2",
  "maxPages": 10
}
```

***

### Output Format

#### 1. Dataset Items (JSON)

Each extracted page is stored as a clean JSON record in the default Dataset:

```json
{
  "query": "httpx",
  "ecosystem": "pypi",
  "version": "0.29.0",
  "url": "https://www.python-httpx.org/async/",
  "title": "Async Support",
  "engine": "mkdocs",
  "breadcrumbs": [],
  "markdown": "# Async Support\n\nHTTPX offers a standard synchronous API by default...",
  "char_count": 6383
}
```

If a package is not found, a descriptive error item is written without triggering any `page-extracted` event charge:

```json
{
  "query": "nonexistent-pkg",
  "ecosystem": "pypi",
  "version": null,
  "error": "Package 'nonexistent-pkg' was not found in pypi."
}
```

#### 2. Combined Markdown File (`DOCUMENTATION.md`)

All extracted pages from a run are also merged into `DOCUMENTATION.md` in the default Key-Value Store (accessible directly from the **Output** tab in Apify Console).

***

### Using with AI Agents (Apify MCP)

You can expose **Package Docs Finder** directly to Claude Desktop, Cursor, Windsurf, or custom agents via the [Apify MCP Server](https://docs.apify.com/platform/integrations/mcp) — allowing your coding agent to fetch up-to-date documentation for newly released library versions on demand.

***

### Local Development

```bash
## Run locally with Apify CLI
apify run --purge

## Simulate Pay-Per-Event charging locally (writes to storage/datasets/charging-log/)
ACTOR_TEST_PAY_PER_EVENT=true python -m my_actor
```

# Actor input Schema

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

Library name (e.g. httpx, zod, tokio) or direct documentation URL.

## `ecosystem` (type: `string`):

Package registry to search when query is not a URL.

## `version` (type: `string`):

Specific library version (e.g. 3.1.2, 4.2). Leave empty to fetch docs for the latest/current version.

## `topic` (type: `string`):

Filter sections by keyword (for AI agents). Leave empty to fetch full documentation.

## `maxPages` (type: `integer`):

Maximum number of pages to extract in one run.

## Actor input object example

```json
{
  "query": "httpx",
  "ecosystem": "pypi",
  "version": "",
  "topic": "",
  "maxPages": 30
}
```

# Actor output Schema

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

No description

## `markdownFile` (type: `string`):

No description

# 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": "httpx"
};

// Run the Actor and wait for it to finish
const run = await client.actor("thermn/package-docs-finder").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": "httpx" }

# Run the Actor and wait for it to finish
run = client.actor("thermn/package-docs-finder").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": "httpx"
}' |
apify call thermn/package-docs-finder --silent --output-dataset

```

## MCP server setup

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

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/v0YYZ1kawca7CeNOg/builds/NeUOmynndRSdGedok/openapi.json
