# Broken Link Checker (`webintel/broken-link-checker`) Actor

Crawl same-site HTML pages and check anchors, images, scripts and stylesheets for broken URLs, redirects and blocked external checks.

- **URL**: https://apify.com/webintel/broken-link-checker.md
- **Developed by:** [Deepak Ganesh](https://apify.com/webintel) (community)
- **Categories:** SEO tools, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 links

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

## Broken Link Checker

![Broken Link Checker](https://api.apify.com/v2/key-value-stores/21SBwDwdNtlnapIdO/records/broken-link-checker.png?v=78eafded)

Broken Link Checker crawls same-site HTML pages and checks every unique target URL it finds. It reports broken links, redirects, blocked external checks, and the pages where each URL was discovered.

The Actor uses fast HTTP requests (no browser), follows internal links only, and treats `example.com` and `www.example.com` as the same site. It skips `mailto:`, `tel:`, `javascript:`, `data:` and fragment-only URLs.

### Use cases

- Audit a website before migration or launch.
- Find broken navigation, missing images and bad stylesheet/script URLs.
- Monitor redirect chains after changing CMS, domains or URL structure.
- Export a clean dataset of checked links with source pages and anchor text.

### Input

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `startUrls` | string list | required | Sites or pages to crawl. Plain domains are converted to HTTPS. |
| `maxPagesPerSite` | integer | `50` | Maximum same-site pages crawled per input site. |
| `checkExternalLinks` | boolean | `true` | Check outbound URLs. External 429, 999 and Cloudflare 403 responses are marked `blocked`, not broken. |
| `checkImages` | boolean | `true` | Check image `src` URLs. |
| `checkScripts` | boolean | `false` | Check script `src` URLs. |
| `checkStylesheets` | boolean | `false` | Check stylesheet `link[href]` URLs. |
| `onlyReportBroken` | boolean | `false` | If true, the dataset includes only broken, redirected or blocked results. Billing remains per checked link. |
| `maxConcurrency` | integer | `10` | Maximum parallel page/link work, with extra per-host politeness. |
| `requestTimeoutSecs` | integer | `30` | Page-load timeout. Link checks use a 15-second timeout. |

Example input:

```json
{
  "startUrls": ["https://books.toscrape.com"],
  "maxPagesPerSite": 5,
  "checkExternalLinks": true,
  "checkImages": true,
  "onlyReportBroken": false,
  "maxConcurrency": 5
}
```

### Output

The default dataset contains one item per reported unique target link. `foundOn` is capped at 20 source pages per target.

```json
{
  "url": "https://books.toscrape.com/index.html",
  "finalUrl": "https://books.toscrape.com/index.html",
  "status": "ok",
  "statusCode": 200,
  "ok": true,
  "isBroken": false,
  "errorMessage": null,
  "redirectChain": [],
  "isExternal": false,
  "linkType": "a",
  "foundOn": [
    {
      "pageUrl": "https://books.toscrape.com/",
      "anchorText": "Books to Scrape"
    }
  ],
  "checkedAt": "2026-10-06T16:58:52.943Z"
}
```

A per-site summary is saved to key-value store record `SUMMARY`:

```json
{
  "totals": {
    "sites": 1,
    "pagesCrawled": 5,
    "linksFound": 153,
    "linksChecked": 153,
    "brokenCount": 0,
    "redirectCount": 0
  }
}
```

### Pricing

This Actor uses pay-per-event pricing.

| Event | Price | Charged when |
| --- | ---: | --- |
| Actor Start | $0.00005 | The Actor starts. |
| Link (`link-checked`) | $0.0005 | Each unique target URL is checked. |

If `onlyReportBroken` is enabled, the Actor still charges for every checked link, even though it pushes only broken, redirected or blocked records to the dataset. Pages that fail to load are recorded in the summary and are not charged as links.

### FAQ

#### Are redirects broken?

No. Redirects are reported with `status: "redirect"`, `redirectChain`, and `finalUrl`, but `isBroken` is false unless the final response is HTTP 400+ or a network error occurs.

#### Why is a 403 not always broken?

External Cloudflare 403 responses and external 429/999 bot/rate-limit responses are marked `blocked` to avoid false positives. Ordinary HTTP 403 responses are reported as broken.

#### Does it respect robots.txt?

The Actor is polite (HTTP-only, modest concurrency, per-host limits) but does not currently parse robots.txt. Lower `maxConcurrency` for sensitive sites.

#### What does same-site mean?

Only the exact hostname and its `www` variant are crawled as pages. Subdomains such as `blog.example.com` are external.

### Changelog

#### 0.1

- Initial release: same-site crawl, unique URL checks, HEAD-to-GET fallback, redirect chains, blocked external classification, per-site summary and pay-per-link pricing.

# Actor input Schema

## `startUrls` (type: `array`):

Sites or pages to crawl. Plain domains are accepted and converted to HTTPS.

## `maxPagesPerSite` (type: `integer`):

Maximum number of same-site HTML pages to crawl per input site.

## `checkExternalLinks` (type: `boolean`):

Check outbound URLs. External 429, 999 and Cloudflare 403 responses are marked blocked, not broken.

## `checkImages` (type: `boolean`):

Check image src URLs.

## `checkScripts` (type: `boolean`):

Check script src URLs.

## `checkStylesheets` (type: `boolean`):

Check stylesheet link href URLs.

## `onlyReportBroken` (type: `boolean`):

When true, the dataset contains only broken, redirected or blocked checks. Billing remains per checked link.

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

Maximum number of pages and links processed in parallel. Per-host link checks are additionally limited.

## `requestTimeoutSecs` (type: `integer`):

How long to wait for crawled pages to load.

## Actor input object example

```json
{
  "startUrls": [
    "https://books.toscrape.com"
  ],
  "maxPagesPerSite": 10,
  "checkExternalLinks": true,
  "checkImages": true,
  "checkScripts": false,
  "checkStylesheets": false,
  "onlyReportBroken": false,
  "maxConcurrency": 10,
  "requestTimeoutSecs": 30
}
```

# Actor output Schema

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

Reported checked link targets. By default includes every checked URL; with onlyReportBroken=true includes only broken, redirected or blocked checks.

## `broken` (type: `string`):

Dataset view optimized for broken, blocked and redirected URLs.

## `summary` (type: `string`):

Per-site summary with pages crawled, links checked, broken count and redirect count.

# 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 = {
    "startUrls": [
        "https://books.toscrape.com"
    ],
    "maxPagesPerSite": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("webintel/broken-link-checker").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 = {
    "startUrls": ["https://books.toscrape.com"],
    "maxPagesPerSite": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("webintel/broken-link-checker").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 '{
  "startUrls": [
    "https://books.toscrape.com"
  ],
  "maxPagesPerSite": 10
}' |
apify call webintel/broken-link-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,webintel/broken-link-checker"
        }
    }
}
```

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/tViChPDRVnKe4h6iH/builds/rzV8TgGM9kgx14Ynb/openapi.json
