# Broken Link Checker — find dead links on your website (`openregistry/broken-link-checker`) Actor

Crawl your website and find every broken internal and external link (404, 500, DNS errors, timeouts), with the page it appears on and its anchor text. Polite crawler: robots.txt respected, delay between requests, no proxy.

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

## Pricing

$1.00 / 1,000 page crawleds

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 — find dead links on your website

Give the address of your website. The Actor crawls its pages, tests every link it finds (internal pages, external sites and optionally images) and tells you **which links are broken, on which page, with which anchor text**, so you can fix them in minutes.

Broken means: HTTP 4xx or 5xx, DNS failure, refused connection or timeout. Redirects are followed and reported, not counted as broken.

### A polite crawler, by design

- **robots.txt is always respected**, for your site and for every external host it tests (RFC 9309, including `Crawl-delay`). A link that robots.txt forbids is reported as `blocked_by_robots`, never requested.
- **One request at a time per host**, with a configurable pause (500 ms by default, 200 ms minimum).
- **Honest identity**: requests carry the User-Agent `OpenRegistryLinkChecker/0.1` with a link to this page. No browser imitation, no proxy rotation, no CAPTCHA tricks. If a site blocks the checker, the link is reported as it was answered.
- **Each link is tested once** per run, even if it appears on hundreds of pages: `HEAD` first, then `GET` when the server refuses `HEAD` or answers with an error, to avoid false alarms.
- Only the site you enter is crawled. External sites are tested link by link, never crawled.

Use it on websites you own or manage.

### Typical uses

- **SEO maintenance**: broken links waste crawl budget and hurt user experience. Run it monthly on a schedule.
- **Website migrations**: check that no internal link points to an old URL after a redesign.
- **Content audits**: find outbound links to sites that disappeared (`linkType: "external"`).
- **Agencies**: deliver a broken link report to a client in one run, as a table or JSON.

### Input example

```json
{
  "startUrls": [{ "url": "https://www.example.com/" }],
  "maxPages": 500,
  "maxDepth": 4,
  "checkExternalLinks": true,
  "checkImages": false,
  "delayMs": 500
}
```

### Output

One row per crawled page (Output tab, view **Pages**):

| Field | Meaning |
|---|---|
| `url`, `finalUrl`, `statusCode`, `title` | the page and how it answered |
| `depth`, `foundOn` | clicks from the start page, and the page where it was found |
| `linksFound`, `linksChecked` | distinct links on the page, links tested |
| `brokenCount`, `brokenLinks` | broken links with `url`, `statusCode`, `error`, `anchorText`, `linkType` (`internal`, `external`, `image`), `redirectedTo` |
| `redirectedLinks`, `blockedByRobots`, `linksNotChecked` | links that redirect, links robots.txt forbids, links over your limit |
| `allLinks` | every link with its status, when `includeAllLinks` is on |
| `error` | why a page could not be fetched |

A **flat list of all broken links** (one entry per link and page, with `foundOn`) is also saved in the key-value store record `BROKEN_LINKS`, linked from the run's Output tab: handy for a spreadsheet.

Sample page row:

```json
{
  "url": "https://www.example.com/blog/", "statusCode": 200, "title": "Blog", "depth": 1,
  "linksFound": 84, "linksChecked": 84, "brokenCount": 2,
  "brokenLinks": [
    { "url": "https://www.example.com/old-post", "statusCode": 404, "error": null, "anchorText": "Our 2019 guide", "linkType": "internal", "redirectedTo": null },
    { "url": "https://gone.example.org/", "statusCode": null, "error": "network error (ENOTFOUND)", "anchorText": "partner", "linkType": "external", "redirectedTo": null }
  ]
}
```

### Limits to know

- The crawler reads the HTML sent by the server. Links created only by JavaScript in the browser are not seen.
- Some sites answer automated requests with 403 or 429 even when the link works for people. A 429 is not counted as broken; a 403 is reported as returned, check those by hand.
- If your robots.txt cannot be reached (server error), nothing is crawled, as the standard requires. Fix robots.txt or the server first.
- Very large sites: raise `maxPages` and `maxLinksChecked`; at 500 ms per request, expect about 5,000 requests per hour per host.

### Pricing

Pay per page crawled: **$0.001 per page** ($1 per 1,000 pages). Link tests are included, whatever their number. Pages that never answered are not charged. Cap any run with `maxPages` or Apify's maximum charge per run.

# Actor input Schema

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

Home page (or any page) of your site. The crawler follows links on the same host only. Several start pages of the same site are allowed.

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

Pages of your site that are fetched and analysed. Each crawled page is one billed event.

## `maxDepth` (type: `integer`):

0 = only the start pages, 1 = pages linked from them, and so on.

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

Also test links to other websites (they are tested, never crawled).

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

Also test the src of <img> tags.

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

Treat blog.example.com as part of example.com.

## `includeAllLinks` (type: `boolean`):

Adds allLinks to each page row, with the status of every link.

## `maxLinksChecked` (type: `integer`):

Safety limit on the number of distinct links tested in a run. Each link is tested once even if it appears on many pages.

## `delayMs` (type: `integer`):

Minimum pause between two requests to the same host. A Crawl-delay in robots.txt is honoured when it is longer (up to 30 s).

## `maxResults` (type: `integer`):

Optional. The run stops once this many pages are delivered.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.wikipedia.org/"
    }
  ],
  "maxPages": 100,
  "maxDepth": 3,
  "checkExternalLinks": true,
  "checkImages": false,
  "includeSubdomains": false,
  "includeAllLinks": false,
  "maxLinksChecked": 5000,
  "delayMs": 500
}
```

# Actor output Schema

## `pages` (type: `string`):

No description

## `brokenLinks` (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 = {
    "startUrls": [
        {
            "url": "https://www.wikipedia.org/"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("openregistry/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://www.wikipedia.org/" }] }

# Run the Actor and wait for it to finish
run = client.actor("openregistry/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://www.wikipedia.org/"
    }
  ]
}' |
apify call openregistry/broken-link-checker --silent --output-dataset

```

## MCP server setup

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