# API Documentation Extractor (`coral_breakthrough/api-documentation-extractor`) Actor

This Actor turns API documentation into structured, machine-readable API intelligence. Give it a documentation URL. It prefers an OpenAPI or Swagger specification when one exists, otherwise it extracts endpoints from HTML.Use it when you need a normalized JSON model of an API.

- **URL**: https://apify.com/coral\_breakthrough/api-documentation-extractor.md
- **Developed by:** [eunice jacob](https://apify.com/coral_breakthrough) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.25 / actor start

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

### What does API Documentation Extractor — Structured API Intelligence do?

This Actor turns **API documentation** into **structured, machine-readable API intelligence**. Give it a documentation URL. It prefers an OpenAPI or Swagger specification when one exists, otherwise it extracts endpoints from HTML. It does **not** return scraped page text or raw HTML as the product.

Use it when you need a normalized JSON model of an API for developers, AI agents, integration platforms, or API research.

### Why use it?

- Discover OpenAPI/Swagger specs automatically and treat them as the source of truth
- Extract HTTP endpoints, authentication, parameters, request bodies, and responses from HTML when no spec is published
- Capture webhooks, errors, rate limits, SDKs, and documented code examples when they appear in the docs
- Keep a `sourceUrl` on extracted entities so you can audit and debug results
- Run on Apify with scheduling, monitoring, and API/CLI access

This is an extractor, not a generic web scraper.

### What data can it extract?

| Field | Description |
| --- | --- |
| `api` | Name, description, version, base URLs, documentation URL |
| `authentication` | Bearer, API key, OAuth, Basic, HMAC, JWT when documented |
| `endpoints` | Method, path, parameters, request body, responses, source URL |
| `webhooks` | Event name, payload, signature verification when documented |
| `errors` | HTTP status, error code, message |
| `rateLimits` | Documented limits, or `null` if none are stated |
| `sdks` | Client libraries mentioned in the docs |
| `codeExamples` | Copy-only examples from the documentation |
| `crawl` | Pages visited, OpenAPI URL, whether a browser was used |

### How to extract API intelligence

1. Open the Actor in Apify Console.
2. Paste a documentation URL into **Documentation URL** (for example `https://paystack.com/docs/api/`).
3. Optionally lower **Max pages** for a cheaper run.
4. Click **Start**.
5. Download the dataset as JSON, or fetch `OUTPUT` from the default key-value store.

### How much will it cost?

Compute cost scales with pages crawled. HTTP/Cheerio is the default and is inexpensive. A browser is used only when a page looks JavaScript-rendered and the initial HTML has no useful API content. Start with a smaller `maxPages` on large sites such as Stripe or GitHub.

### Input

See the input tab for the full form.

- `startUrl` (required) — documentation URL
- `maxPages` — default `100`
- `includeCodeExamples` — default `true`
- `includeWebhooks` — default `true`
- `includeErrors` — default `true`

### Output

You can download the dataset as JSON, HTML, CSV, or Excel. The Actor writes **one** JSON object describing the API, and the same object to key-value store record `OUTPUT`.

```json
{
  "api": {
    "name": "Payments API",
    "version": "1",
    "baseUrls": ["https://api.payments.test/v1"],
    "documentationUrl": "https://docs.payments.test/api"
  },
  "authentication": [{ "type": "bearer", "headers": ["Authorization"] }],
  "endpoints": [
    {
      "method": "POST",
      "path": "/transaction/initialize",
      "name": "Initialize Transaction",
      "authentication": { "type": "bearer" },
      "requestBody": {
        "email": { "type": "string", "required": true },
        "amount": { "type": "integer", "required": true }
      },
      "responses": { "200": { "description": "Successful response" } },
      "sourceUrl": "https://docs.payments.test/api"
    }
  ],
  "webhooks": [],
  "errors": [],
  "rateLimits": null,
  "sdks": [],
  "codeExamples": [],
  "crawl": { "pagesVisited": 1, "pagesProcessed": 1, "durationMs": 1200, "sourceUrls": [] }
}
```

### Supported documentation types

- OpenAPI 3 and Swagger 2 (`openapi.json`, `swagger.yaml`, `/api-docs`, and links from the docs)
- Static HTML API reference pages
- JavaScript-rendered docs, via a Playwright retry for pages whose initial HTML has no useful content

### Limitations

- The Actor does not invent endpoints, webhooks, or auth schemes. Missing documentation stays missing (`unknown` or empty arrays / `null`).
- It does not generate client code. Examples are copied only when the docs include them.
- Selectors are provider-agnostic. Unusual one-off doc layouts may yield fewer fields.
- Change detection, API comparison, and historical versions are out of scope.

### API usage example

```bash
apify call api-documentation-extractor --input '{
  "startUrl": "https://paystack.com/docs/api/",
  "maxPages": 40,
  "includeWebhooks": true,
  "includeErrors": true
}'
```

Use the Apify API to read dataset items after the run, or the `OUTPUT` record in the default key-value store.

### FAQ

Our Actors extract publicly documented API information. Do not use this Actor to bypass authentication, scrape private user data, or violate a site's terms of service. If your results could contain personal data, GDPR and similar laws may apply.

Open issues on the Issues tab. Programmatic runs are documented on the API tab.

# Actor input Schema

## `startUrl` (type: `string`):

Starting URL of the API documentation to extract. Example: a reference, OpenAPI, or getting-started page.

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

Maximum number of documentation pages to crawl. Unrelated marketing pages are skipped automatically. Keep this at 20 or lower for a fast first run; raise it for large API references.

## `includeCodeExamples` (type: `boolean`):

Extract documented code examples (cURL, JavaScript, Python, and other languages). Examples are copied from the docs, never generated.

## `includeWebhooks` (type: `boolean`):

Extract documented webhook events, payloads, and signature verification details when present.

## `includeErrors` (type: `boolean`):

Extract documented error codes, HTTP statuses, and messages when present.

## Actor input object example

```json
{
  "startUrl": "https://paystack.com/docs/api/",
  "maxPages": 20,
  "includeCodeExamples": true,
  "includeWebhooks": true,
  "includeErrors": true
}
```

# Actor output Schema

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

No description

## `outputFile` (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 = {
    "startUrl": "https://paystack.com/docs/api/",
    "maxPages": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("coral_breakthrough/api-documentation-extractor").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 = {
    "startUrl": "https://paystack.com/docs/api/",
    "maxPages": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("coral_breakthrough/api-documentation-extractor").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 '{
  "startUrl": "https://paystack.com/docs/api/",
  "maxPages": 20
}' |
apify call coral_breakthrough/api-documentation-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,coral_breakthrough/api-documentation-extractor"
        }
    }
}
```

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/mxDwUHznStpxUND2w/builds/qidEcyNJiTN01zTQ0/openapi.json
