# Broken Link Checker: Find 404s, Broken Images & Redirects (`patrickballard/broken-link-checker`) Actor

Crawl your website and find every broken link, broken image, script or stylesheet, dead external link and redirect, with the exact pages and anchor text where each one appears. Respects robots.txt. Pay per page scanned.

- **URL**: https://apify.com/patrickballard/broken-link-checker.md
- **Developed by:** [Paddy Ballard](https://apify.com/patrickballard) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 pages scanned

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/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 404s, Broken Images & Redirects

Point it at your home page. It crawls your site and checks **every link, image, script and stylesheet** it finds, including links to other websites. Then it tells you exactly **which pages** each broken link sits on and **what the link text says**, so you can fix it in minutes.

- **Broken links (404, 410, 5xx)** and **unreachable links** (dead domains, timeouts)
- **Broken images and assets**: `<img>`, scripts, stylesheets, iframes, video and audio
- **Redirects** (optional), with the final URL, handy after a site migration or a domain change
- **Where it's found**: up to 25 pages per broken link, with anchor text, worst problems first
- **Polite**: respects `robots.txt` and `nofollow`, has a concurrency limit, checks each URL once, and tries HEAD before GET
- **Skip patterns** so it never touches `/logout`, `/cart` or similar

### Output (one row per problem link)

```json
{
  "url": "https://yoursite.com/old-pricing",
  "result": "broken",
  "status": 404,
  "internal": true,
  "kind": "link",
  "foundOnCount": 2,
  "foundOn": [
    { "page": "https://yoursite.com/", "anchorText": "See pricing" },
    { "page": "https://yoursite.com/blog/launch", "anchorText": "our plans" }
  ],
  "finalUrl": "https://yoursite.com/old-pricing",
  "redirectChain": [],
  "error": null
}
```

`result` is `broken`, `error` (unreachable) or `redirect`. If nothing is wrong you get a single `all-clear` row with a short note, so a clean result is never just an empty table. The run's `OUTPUT` record has totals: pages scanned, links checked, broken, unreachable and redirects.

**Schedule it weekly** to catch new broken links before your visitors (and Google) do.

### Pricing

**$0.002 per page scanned** on your site. Every link on that page is checked at no extra cost, external ones included. A 200-page site costs about **$0.40** per full check. Set a maximum cost per run and it stops cleanly, reporting what it found so far.

### Good to know

- Crawl **your own sites** or sites you have permission to check.
- Pages are fetched like a normal visitor, with a clear `BrokenLinkChecker` user agent. It doesn't log in, fill forms or run JavaScript, so links that only appear after JavaScript runs aren't seen.
- Some sites block automated checks (e.g. return 403 or 429). Those are reported as they are, so check them by hand.
- No personal data is collected. Only URLs, status codes and link text are stored.

# Actor input Schema

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

Your site's home page (or any pages to start from). The crawl stays on these domains.

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

Most pages on your site to crawl. Links on every scanned page are still checked.

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

Also check links that point to other websites (each external URL is checked once).

## `checkImagesAndAssets` (type: `boolean`):

Also report broken <img>, <script>, stylesheet, iframe and media URLs.

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

Also list links that redirect (useful for cleaning up after a site migration).

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

Never request URLs containing any of these strings, e.g. /logout, /cart, ?replytocom=.

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

Keep it low to be gentle on your server.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://example.com"
    }
  ],
  "maxPages": 200,
  "checkExternalLinks": true,
  "checkImagesAndAssets": true,
  "reportRedirects": false,
  "maxConcurrency": 5
}
```

# Actor output Schema

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

One row per broken, unreachable or redirecting link, worst first.

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

Pages scanned, links checked, broken, unreachable and redirects.

# 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://example.com"
        }
    ]
};

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

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

```

## MCP server setup

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