# Broken Link Checker: crawl, sitemap or URL list (`kvnloo/broken-link-checker`) Actor

Find broken links on a website. Crawls your site (or reads its sitemap or a URL list), checks every unique link once, and returns status, redirect chain, response time, source pages and anchor text. $0.50 per 1,000 unique links.

- **URL**: https://apify.com/kvnloo/broken-link-checker.md
- **Developed by:** [Kevin Rajan](https://apify.com/kvnloo) (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

from $0.50 / 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

Find every broken link on your website before your visitors and Google do. Give it a website, a sitemap or a plain list of URLs. It checks each unique link once and tells you which ones return 404 or 410, server errors, timeouts, dead hosts or redirect loops. For each link you also get **which pages link to it and with what anchor text**.

**$0.50 per 1,000 unique links checked**, plus a $0.00005 start fee. Each URL is charged once, however many pages link to it, and fetching your pages during the crawl is not charged separately.

#### What you get for each link

| Field | Example |
|---|---|
| `url` | `https://example.com/old-pricing` |
| `classification` | `not_found` (also `ok`, `redirected`, `client_error`, `server_error`, `timeout`, `unreachable`, `too_many_redirects`, `blocked`) |
| `isBroken` | `true` |
| `statusCode` | `404` |
| `finalUrl` / `redirectChain` / `redirectCount` | every hop with its status code, e.g. `301 → 302 → 200` |
| `responseTimeMs` | `412` |
| `linkType` | `internal` or `external` |
| `tag` | `a`, `img`, `script`, `link`, `iframe`, … |
| `sourceCount` / `sources` | how many pages link here, and up to 10 `{sourceUrl, anchorText}` pairs |

The run's `REPORT` record also counts links per classification and lists the **20 broken links that the most pages link to**, so you know which to fix first.

#### Three ways to start

- **Crawl** (default): starts at your URLs and follows links on the same site for up to `maxPages` pages. It checks every internal link, and external links too unless you turn that off. Other websites are only checked, never crawled.
- **Sitemap**: reads `robots.txt`, sitemap indexes, gzip and text sitemaps, then checks every listed URL. Use it for migrations and to clean up a sitemap.
- **List**: checks up to 10,000 URLs you paste or send through the API, such as backlinks, outreach lists or ad landing pages.

#### Example input

```json
{
  "mode": "crawl",
  "startUrls": ["https://crawler-test.com/links/broken_links_internal"],
  "maxPages": 1,
  "maxLinks": 20
}
```

Input with no `startUrls` and no `urls` (for example `{}`) checks this example: 1 page and its 7 links, charged like any other run.

#### Example output (one row)

```json
{
  "url": "https://crawler-test.com/links/not_found/foo1",
  "linkType": "internal",
  "tag": "a",
  "statusCode": 404,
  "finalUrl": "https://crawler-test.com/links/not_found/foo1",
  "redirectChain": [],
  "redirectCount": 0,
  "responseTimeMs": 141,
  "classification": "not_found",
  "isBroken": true,
  "sourceCount": 1,
  "sources": [{"sourceUrl": "https://crawler-test.com/links/broken_links_internal", "anchorText": "Broken Internal Link 1"}]
}
```

#### Why fewer false alarms

- **Every failure is checked twice.** Many servers answer a quick `HEAD` request with 404 or 405 even though the page works. Each failing `HEAD` is retried as a 1-byte `GET`, and only a failure that repeats is reported as broken.
- **Bot walls are not counted as broken.** `401`, `403`, `429` and LinkedIn-style `999` responses are classed as `blocked`, not broken, so your report is not flooded with links that work fine in a browser.
- **Non-ASCII and international domain URLs** are encoded correctly instead of being reported as dead.
- **It is polite to every server.** Requests to a single host are capped at 4 per second, `robots.txt` is respected while crawling, and a `429` is retried once after its `Retry-After` delay.

#### Pricing

You pay once per unique link checked.

| | This Actor | Typical alternative |
|---|---|---|
| Per 1,000 links | **$0.50** | $1.00 to $2.50 |
| Start fee | $0.00005 | $0.00005 to $0.02 |
| Start URLs per run | up to 20 sites | 1 (market leader) |
| Include / exclude regex filters | yes, applied before charging | none (market leader) |

`maxLinks` caps the number of links checked and charged. `onlyBroken` shortens the output to broken links but does not change the price. If you set a maximum charge for the run, it stops checking at that budget, so you never pay for work it cannot deliver.

#### Filters

- `includePattern` / `excludePattern`: regular expressions applied **before** checking and charging, e.g. exclude `\?replytocom=|/tag/`.
- `checkExternalLinks`: turn it off to audit only your own site.
- `checkAssets`: also check images, scripts, stylesheets, iframes and media.

#### FAQ

**Does it run JavaScript?** No. It reads the HTML your server sends, which is fast and cheap. Links that only a client-side script inserts are not found. The sitemap mode covers those pages.

**Does it use proxies or get around blocking?** No. It identifies itself with its own user agent and respects `robots.txt` while crawling. Sites that block bots are reported as `blocked`.

**Why is a page I know works reported as `blocked`?** The site refused automated requests with 401, 403, 429 or 999. Open it in a browser to confirm. It is not counted as broken.

**Can I schedule it?** Yes. Use an Apify Schedule with `onlyBroken: true` for a weekly link-rot alert, and connect the dataset to Slack, email, Google Sheets or a webhook.

**Is any personal data collected?** No. Output contains URLs, HTTP metadata and anchor text from the pages you choose to check. Page bodies are not stored.

#### Related Actors

- [Sitemap URL Extractor](https://apify.com/kvnloo/sitemap-url-extractor): every URL from a site's sitemaps with lastmod, hreflang and robots flags.
- [Technical SEO Check](https://apify.com/kvnloo/technical-seo-check): on-page SEO checks for HTML you supply.

# Actor input Schema

## `mode` (type: `string`):

crawl: fetch up to maxPages same-site pages starting at startUrls and check every link on them. sitemap: read the sitemap(s) of each start URL (robots.txt, sitemap index and gzip supported) and check every listed URL. list: check only the URLs in urls.

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

1 to 20 website, page or sitemap URLs. Bare domains get https://. The crawl stays on the same host (www. is ignored). With no startUrls and no urls, the Actor checks the small built-in example page.

## `urls` (type: `array`):

1 to 10,000 URLs, used only when mode is list.

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

Crawl mode only. Pages fetched to discover links. Crawling is free; you pay per checked link.

## `maxLinks` (type: `integer`):

Hard cap on unique links checked and charged. Each unique URL is checked once however many pages link to it.

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

Crawl mode: also check links to other websites. External sites are never crawled, only checked.

## `checkAssets` (type: `boolean`):

Crawl mode: also check <img>, <script>, <link rel=stylesheet>, <iframe>, <source>, <video> and <audio> URLs.

## `onlyBroken` (type: `boolean`):

Output only broken links: 404/410, other 4xx, 5xx, timeouts, unreachable hosts and redirect loops. Every link is still checked and charged once; the REPORT record counts them all.

## `includePattern` (type: `string`):

Only check links whose URL matches this regular expression. Applied before checking and charging.

## `excludePattern` (type: `string`):

Skip links whose URL matches this regular expression, e.g. ?replytocom= or /tag/.

## `concurrency` (type: `integer`):

Parallel requests across hosts. Requests to any single host are always paced to at most 4 per second.

## Actor input object example

```json
{
  "mode": "crawl",
  "startUrls": [
    "https://crawler-test.com/links/broken_links_internal"
  ],
  "urls": [
    "https://crawler-test.com/",
    "https://crawler-test.com/status_codes/status_404"
  ],
  "maxPages": 5,
  "maxLinks": 50,
  "checkExternalLinks": true,
  "checkAssets": false,
  "onlyBroken": false,
  "includePattern": "",
  "excludePattern": "",
  "concurrency": 10
}
```

# Actor output Schema

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

No description

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

No description

## `report` (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": [
        "https://crawler-test.com/links/broken_links_internal"
    ],
    "urls": [
        "https://crawler-test.com/",
        "https://crawler-test.com/status_codes/status_404"
    ],
    "maxPages": 5,
    "maxLinks": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("kvnloo/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://crawler-test.com/links/broken_links_internal"],
    "urls": [
        "https://crawler-test.com/",
        "https://crawler-test.com/status_codes/status_404",
    ],
    "maxPages": 5,
    "maxLinks": 50,
}

# Run the Actor and wait for it to finish
run = client.actor("kvnloo/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://crawler-test.com/links/broken_links_internal"
  ],
  "urls": [
    "https://crawler-test.com/",
    "https://crawler-test.com/status_codes/status_404"
  ],
  "maxPages": 5,
  "maxLinks": 50
}' |
apify call kvnloo/broken-link-checker --silent --output-dataset

```

## MCP server setup

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