# Broken Link Checker & Redirect Auditor - Whole-Site 404 Finder (`batreek/broken-link-checker`) Actor

Crawl a whole website and find every broken link (404, 410, 5xx, DNS, SSL, timeouts), broken images and long redirect chains, with the page and anchor text where each one appears. Fast, robots.txt-aware, priced per page.

- **URL**: https://apify.com/batreek/broken-link-checker.md
- **Developed by:** [Adam Abdou-Gustavson](https://apify.com/batreek) (community)
- **Categories:** SEO tools, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.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 & Redirect Auditor — Find Every 404 on Your Website

Crawl an entire website and get a clean list of **every broken link, broken image, dead script/stylesheet, server error and long redirect chain**, together with **the page it appears on and its anchor text** — so you can fix it in minutes.

Built for SEO specialists, agencies, web developers and site owners who need a fast, affordable **website link audit** without installing desktop crawlers.

### What it finds

| Issue | Severity |
|---|---|
| 404 / 410 not found (internal or external) | 🔴 high |
| 5xx server errors | 🔴 high |
| DNS failures, SSL/TLS errors, timeouts, redirect loops | 🔴 high |
| Other 4xx errors | 🔴/🟠 |
| Redirect chains longer than your threshold | 🟠 medium |
| Mixed content (http resources on https pages) | 🟠 medium |
| Internal links that redirect (update them to the final URL) | 🟢 low |
| External links that block bots (401/403/429/999, e.g. LinkedIn) | ⚪ info — verify manually, not counted as broken |

Every URL is checked **once**, even if it appears on hundreds of pages; you see the number of occurrences and up to 25 source pages.

### Why this link checker?

- ✅ **Whole-site crawl** — follows internal links up to your page/depth limits, checks external links without crawling them.
- ✅ **Fewer false positives** — HEAD first, then confirms with GET before calling anything broken; bot-blocking sites are flagged as "info", not "broken".
- ✅ **Images, CSS, JS, iframes** — not just `<a>` tags.
- ✅ **Polite** — respects robots.txt (Google-style wildcards), modest concurrency, honest user agent.
- ✅ **Cheap & predictable** — pay only for pages that were actually crawled (on-site HTML pages that load with status 200); all link checks on those pages are included. Error pages, PDFs/images and pages that redirect to another site are reported but never charged.
- ✅ **Schedulable** — run weekly and send results to Slack, email, Google Sheets, n8n, Make or Zapier.

### Input

```json
{
  "startUrls": [{ "url": "https://www.example.com/" }],
  "maxPages": 50,
  "maxDepth": 10,
  "checkExternalLinks": true,
  "checkImages": true,
  "redirectChainThreshold": 1,
  "reportRedirects": true,
  "excludeUrlPatterns": ["/wp-admin/", "\\?replytocom="]
}
```

### Output (one row per problem URL)

```json
{
  "url": "https://www.example.com/old-pricing",
  "severity": "high",
  "issue": "broken (not found)",
  "statusCode": 404,
  "linkType": "internal",
  "elementType": "a",
  "foundOn": "https://www.example.com/blog/launch",
  "anchorText": "see our pricing",
  "occurrences": 14,
  "allSources": [{ "page": "https://www.example.com/blog/launch", "anchorText": "see our pricing" }],
  "redirectCount": 0,
  "redirectChain": [],
  "finalUrl": "https://www.example.com/old-pricing"
}
```

Export to CSV/Excel/JSON or fetch via API. A `SUMMARY` record shows pages crawled, links checked and issue counts. Turn on **Output every link** for a full link inventory.

### Pricing

**$2.00 per 1,000 pages crawled** (pay-per-event, `page-crawled`). A page counts as crawled only when it is an HTML page on your site that loads with status 200. Checking all links, images and resources found on those pages is included.

#### What will it cost?

| Pages crawled | Cost |
|---|---|
| 50 pages (the pre-filled form) | $0.10 |
| 300 pages | $0.60 |
| 1,000 pages | $2.00 |
| 10,000 pages | $20.00 |

`maxPages` caps how many pages are fetched, so it also caps the cost. Each run also has a $0.00005 start fee (one per GB of memory; the default memory needs one), which is too small to change these numbers. You pay only for these events: no rental fee and no separate compute charge. Set a **maximum cost per run** in the run options (or `maxTotalChargeUsd` in the API) and the Actor stops cleanly when it reaches it.

### Use it via API, code or AI agents

Everything in the Console also works over the API, so you can run it from code, a scheduler or an AI agent. Replace `<YOUR_APIFY_TOKEN>` with your token from **Apify Console → Settings → API & Integrations**.

**REST: run and get the results in one call** (waits up to 5 minutes; `maxTotalChargeUsd` caps what the run can cost):

```bash
curl -X POST "https://api.apify.com/v2/acts/batreek~broken-link-checker/run-sync-get-dataset-items?maxTotalChargeUsd=1" \
  -H "Authorization: Bearer <YOUR_APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"startUrls": [{"url": "https://www.example.com/"}], "maxPages": 50}'
```

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("batreek/broken-link-checker").call(run_input={
    "startUrls": [
        {
            "url": "https://www.example.com/"
        }
    ],
    "maxPages": 50
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

**JavaScript / Node.js** (`npm install apify-client`):

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });
const run = await client.actor('batreek/broken-link-checker').call({"startUrls": [{"url": "https://www.example.com/"}], "maxPages": 50});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

**AI agents (MCP):** add this Actor as a tool in Claude, ChatGPT, Cursor or any MCP client through Apify's hosted MCP server at `https://mcp.apify.com?tools=batreek/broken-link-checker`. The agent can then audit a website for broken links and read the structured results. Runs are billed to your Apify account like any other run.

**No-code:** use Apify's integrations (Zapier, Make, n8n, Google Sheets, Slack, webhooks) or put it on an Apify **Schedule**.

### FAQ

**Will it crawl other websites?** No. It only crawls the host of your start URL; external links are checked with a single request each.
**Does it render JavaScript?** No — it checks links present in the HTML, which is what search engines see first. JS-only links are not discovered.
**Why is a link marked "info"?** Some sites (LinkedIn, Amazon, some CDNs) refuse automated requests. The link may be fine in a browser.
**Can I audit a site I don't own?** Yes, for public pages, but please keep concurrency low; the Actor respects robots.txt by default.

# Actor input Schema

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

Website(s) to audit. The crawler stays on the same host as each start URL.

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

Maximum number of internal pages fetched per run. You pay only for on-site HTML pages that load successfully (status 200): 50 pages ≈ $0.10.

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

How many clicks away from the start URL to crawl. 0 = only the start pages.

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

Also verify links pointing to other websites (they are checked, never crawled).

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

Also verify <img>, <script> and <link rel=stylesheet> resources.

## `redirectChainThreshold` (type: `integer`):

Report links that need more than this many redirect hops (SEO best practice: 1).

## `reportRedirects` (type: `boolean`):

Include internal links that redirect (worth updating for SEO) as low-severity issues.

## `includeOkLinks` (type: `boolean`):

Output all checked links including healthy ones. Useful for full link inventories.

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

Regular expressions; matching URLs are neither crawled nor checked (e.g. /wp-admin/, ?replytocom=).

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

Parallel requests. Keep it modest to be gentle on the audited site.

## `respectRobotsTxt` (type: `boolean`):

Do not crawl internal pages disallowed by robots.txt. Leave on unless you own the site.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://crawler-test.com/"
    }
  ],
  "maxPages": 50,
  "maxDepth": 10,
  "checkExternalLinks": true,
  "checkImages": true,
  "redirectChainThreshold": 1,
  "reportRedirects": true,
  "includeOkLinks": false,
  "maxConcurrency": 8,
  "respectRobotsTxt": true
}
```

# Actor output Schema

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

Broken links, broken images, redirect chains and other link issues, with the page and anchor text where each appears.

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

Pages crawled, links checked and issue counts by severity.

# 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://crawler-test.com/"
        }
    ],
    "maxPages": 50
};

// Run the Actor and wait for it to finish
const run = await client.actor("batreek/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://crawler-test.com/" }],
    "maxPages": 50,
}

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

```

## MCP server setup

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