# Broken Link Checker: Site Crawler for 404s & Redirects (`thomson-digital/broken-link-checker`) Actor

Crawl any website and check every internal and external link (plus images, scripts and CSS if you want). Get 404s, 5xx, DNS failures, timeouts and redirect chains, with the exact pages and anchor text that link to each one. Fast, no browser.

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

## Pricing

$0.70 / 1,000 link checkeds

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: Site Crawler for 404s & Redirects

Crawl a website and **check every link on it**. You get every 404, 410, 5xx, DNS failure, timeout and redirect loop, each with **the exact pages that link to it and the anchor text**, so you know what to fix and where.

It checks internal and external links, and can also check **images, scripts, stylesheets, iframes and video/audio** sources. It runs on plain HTTP, so there's no browser or proxy, and runs are fast and cheap.

### Why use it

- **SEO audits:** broken internal links waste crawl budget and leak link equity
- **Site migrations and redesigns:** catch links that now 404 or bounce through redirect chains
- **Content and affiliate sites:** find dead outbound links before readers and Google do
- **Agencies:** run it on client sites on a schedule and export to a sheet
- **Monitoring:** schedule it weekly with `outputMode: "broken"` to get only new problems

### Features

- Crawls same-site pages (www and non-www count as one site, subdomains optional) up to your page and depth limits, with include/exclude URL regex filters
- Checks each **unique** link only once, even if it's linked from 500 pages; `foundOnCount` gives the total
- **HEAD first with GET fallback**, which avoids the false 404/405 errors many servers send to HEAD
- **Redirect chains** with every hop, the final URL and redirect loops
- Bot-blocked responses (401/403/429/LinkedIn's 999) are **not counted as broken** by default, and you can configure this
- Polite per-host concurrency, retries on 429/5xx, 5 MB page cap
- Broken links are listed first in the dataset

### Input

```json
{
  "startUrls": [{"url": "https://example.com/"}],
  "maxPagesToCrawl": 500,
  "maxLinksToCheck": 5000,
  "outputMode": "broken",
  "checkExternalLinks": true,
  "checkAssets": ["img"]
}
```

### Output (one row per unique link)

```json
{
  "url": "https://example.com/old-pricing",
  "isBroken": true,
  "statusCode": 404,
  "linkType": "internal",
  "redirectCount": 1,
  "redirectChain": ["https://example.com/old-pricing", "https://example.com/pricing-2019"],
  "finalUrl": "https://example.com/pricing-2019",
  "foundOnCount": 3,
  "foundOn": [
    {"page": "https://example.com/blog/launch", "anchorText": "see pricing", "rel": null}
  ],
  "error": null
}
```

`error` explains network failures, such as "DNS lookup failed (domain does not resolve)", `ConnectTimeout` or `TooManyRedirects`. The `SUMMARY` record in the key-value store has totals for pages crawled, links checked, broken links and redirects.

### Pricing

**$0.70 per 1,000 unique links checked** (pay-per-event, `link-checked`). Crawling pages is free, there's no start fee, and you don't pay for platform usage. Use `maxLinksToCheck` to cap the cost of any run. For example, a 200-page site with about 3,000 unique links costs about **$2.10**.

### Tips

- Pages that only render their links with JavaScript (some SPAs) expose fewer links to a plain-HTTP crawler. Server-rendered sites, WordPress, Shopify, docs and blogs work best.
- To check a known list of URLs without crawling, use [HTTP Redirect & Status Checker](https://apify.com/thomson-digital/http-redirect-checker).

# Actor input Schema

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

Website(s) to crawl. Pages on the same host (www and non-www count as the same site) are crawled; links to other sites are checked but not crawled.

## `maxPagesToCrawl` (type: `integer`):

Maximum number of HTML pages to crawl for links.

## `maxLinksToCheck` (type: `integer`):

Cap on unique links checked (and charged) per run.

## `outputMode` (type: `string`):

Which checked links to write to the dataset. Every checked link is charged the same, whatever you output.

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

Also check links that point to other websites.

## `checkAssets` (type: `array`):

Check these embedded resources too: img, script, css, iframe, source (video/audio).

## `includeSubdomains` (type: `boolean`):

Treat subdomains (e.g. blog.example.com) as part of the site.

## `maxCrawlDepth` (type: `integer`):

Clicks away from the start URL. 0 = only check links on the start page.

## `includeUrlPatterns` (type: `array`):

Crawl only pages whose URL matches one of these regular expressions, e.g. /blog/. Links found are still checked.

## `excludeUrlPatterns` (type: `array`):

Skip crawling pages matching these regular expressions, e.g. ?page= or /tag/.

## `treatAsOk` (type: `array`):

Many sites (LinkedIn, Cloudflare-protected pages) answer bots with 401/403/429/999 although the page works in a browser.

## `maxSourcesPerLink` (type: `integer`):

How many linking pages (with anchor text) to list in foundOn. foundOnCount always has the full count.

## `useHeadRequests` (type: `boolean`):

Check with HEAD first (faster) and confirm errors with GET.

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

Parallel requests overall.

## `perHostConcurrency` (type: `integer`):

Parallel requests to any one host; keep low to be polite.

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

Timeout per request.

## `maxRetries` (type: `integer`):

Retries on network errors, 429 and 502-504.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://books.toscrape.com/"
    }
  ],
  "maxPagesToCrawl": 20,
  "maxLinksToCheck": 2000,
  "outputMode": "all",
  "checkExternalLinks": true,
  "checkAssets": [],
  "includeSubdomains": false,
  "maxCrawlDepth": 10,
  "includeUrlPatterns": [],
  "excludeUrlPatterns": [],
  "treatAsOk": [
    "401",
    "403",
    "429",
    "999"
  ],
  "maxSourcesPerLink": 10,
  "useHeadRequests": true,
  "maxConcurrency": 10,
  "perHostConcurrency": 4,
  "requestTimeoutSecs": 15,
  "maxRetries": 1
}
```

# Actor output Schema

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

Dataset with one row per unique link, broken first

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

Totals for the run

# 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": [
        {
            "url": "https://books.toscrape.com/"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("thomson-digital/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": [{ "url": "https://books.toscrape.com/" }] }

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

```

## MCP server setup

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