# Broken Link Checker from Sitemap (with Monitor Mode) (`pennapixel/broken-link-checker`) Actor

Find broken links on a website starting from its sitemap: reads every page, checks internal and external links (HEAD, then GET) and returns one row per broken link. Monitor mode returns only links that broke since the last run.

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

## Pricing

from $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 from Sitemap (with Monitor Mode)

Find the **broken links of a website** without feeding it a list of pages: the actor starts from the site's **sitemap**, reads each page, collects its links (internal and, if you want, external) and checks every one. You get **one row per broken link**: the page where it is, the link, the HTTP status or the error, and the link text, so you know exactly what to fix.

Schedule it and switch on **monitor mode**: you are told only about the links that **broke since the last run**, not the same old list every day.

### Features

- **Starts from the sitemap**: give `example.com`, the sitemaps are found through `robots.txt` (nested indexes and .gz included). Or give a sitemap URL. No sitemap? The page you gave is checked.
- **Internal and external links** (external can be switched off). Each distinct link is checked **once per run**, even if it appears on 200 pages, and you still get a row for every page that contains it.
- **HEAD first, GET if needed**: a server that does not support HEAD, drops the connection or answers it badly is asked again with GET, so working links are not reported as broken.
- **Clear reasons**: `404 Not found`, `410 Gone`, `500 Server error`, `DNS error: the domain does not exist`, `Timeout`, `Too many redirects`, TLS errors.
- **Sites that block bots are not blamed on you**: `401`, `403`, `429` and `999` answers are counted as *blocked* in the summary, not as broken.
- **Monitor mode** (`onlyNewBrokenLinks`): remembers the broken links of the previous run and returns only the new ones (`isNew: true`). The summary also says how many were fixed.
- **Pages of the sitemap that no longer work** (404, 5xx) are reported too, with the sitemap as the source.
- **Limits you control**: max pages, max links, parallel requests, timeout per request, time limit per website. A run can never hang.
- **Polite**: honours `robots.txt` (and Crawl-delay), spaces requests to the same host, identifies itself as `PennaPixelBot`, never touches private network addresses.

### Use cases

- Monthly clean-up of a blog, a shop or a documentation site: fix what readers (and Google) hit as errors
- SEO audits: broken internal links waste crawl budget, broken outbound links look neglected
- **Alerts**: run it daily or weekly in monitor mode and send new broken links to e-mail, Slack, Google Sheets or a webhook through Apify integrations
- After a migration or a redesign: find the links that now lead nowhere

### Input

```json
{
  "startUrls": ["https://www.sitemaps.org"],
  "checkExternalLinks": true,
  "maxPagesPerSite": 50,
  "maxLinksPerSite": 1000,
  "excludeLinkPatterns": ["linkedin\\.com", "\\?utm_"]
}
```

For monitoring add `"onlyNewBrokenLinks": true` and create a **schedule**. The first run returns all broken links and saves them as the baseline; from the second run on you get only the new ones. Use `includeWorkingLinks` to also get a row for the links that work (a full inventory).

### Output

A real row (from sitemaps.org, a page that links to a domain that no longer exists):

```json
{
  "site": "https://www.sitemaps.org",
  "sourceUrl": "https://www.sitemaps.org/faq.html",
  "link": "http://asg.web.cmu.edu/rfc/rfc3986.php",
  "linkText": "RFC-3986",
  "linkType": "external",
  "broken": true,
  "status": null,
  "error": "DNS error: the domain does not exist",
  "category": "dns",
  "finalUrl": null,
  "method": "HEAD",
  "checkedAt": "2026-11-13T08:23:35+00:00"
}
```

`category` is one of `not-found`, `gone`, `client-error`, `server-error`, `dns`, `connection`, `timeout`, `redirect-loop`, `tls` for broken links (and `ok` when you ask for working links). The **SUMMARY** record in the run's key-value store has, for each website: pages found and read, links found and checked, broken links, blocked links, links skipped by robots.txt, new and fixed links in monitor mode, and any limit that stopped the run.

### Pricing

- **$0.0007 per link checked** ($0.70 per 1,000 links)
- **$0.00005 per run** start

A link is charged once per run, working or broken. Links skipped because of `robots.txt`, and pages and sitemaps read, are free. Set a maximum cost per run in the run options to stay in control.

Example: a 100-page blog with 600 different links costs about **$0.42** per check. Monitoring it every day costs the same per day, and you only read the new broken links.

### Good to know

- Only `<a href>` links are checked (not images, scripts or stylesheets), and only the pages listed in the sitemap, up to your page limit.
- Some sites never answer automated requests or take very long: they are reported as `timeout` (it can be temporary: open the link to be sure). Sites that answer `403` or `429` are counted as blocked, not broken.
- Links disallowed by the target site's `robots.txt` are not requested: they are counted as *skipped by robots.txt*.
- The monitor memory is a key-value store named `broken-link-checker-state` in your account (short hashes only). Delete it to start fresh.
- Pages that need JavaScript to show their links are read as plain HTML: links added by scripts are not seen.

### Support

A link reported as broken that works for you? Open an issue with the page and the link: fixes are usually quick.

# Actor input Schema

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

A website (example.com or https://example.com), or the URL of a sitemap. Pages are taken from the site's sitemaps (found through robots.txt). If the site has no sitemap, only the page you gave is checked.

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

Check links that point to other websites as well as internal ones. Each distinct link is checked once per run.

## `onlyNewBrokenLinks` (type: `boolean`):

Compare with the previous run on the same website and return only the links that became broken (flagged isNew). The first run returns all broken links and saves them as the baseline. The list is kept in a key-value store named 'broken-link-checker-state' in your account. Schedule the run (daily, weekly) to be told when a link breaks.

## `includeWorkingLinks` (type: `boolean`):

Add a row (broken: false) for every link that works, not only for broken ones. Useful for a full link inventory. Charging does not change: every checked link is one event.

## `maxPagesPerSite` (type: `integer`):

Cost cap: how many pages of the sitemap are downloaded and searched for links.

## `maxLinksPerSite` (type: `integer`):

Cost cap: how many different links are checked (each one is a charged event). Pages are read first, then links are checked in the order they were found.

## `includePagePatterns` (type: `array`):

Optional regular expressions. A sitemap page is read only if its URL matches at least one. Example: /blog/

## `excludeLinkPatterns` (type: `array`):

Optional regular expressions for links that must not be checked. Example: linkedin.com or ?utm\_

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

How many requests run at the same time. Requests to the same host are also spaced out, and the site's Crawl-delay is honoured.

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

A link that does not answer within this time is reported as a timeout.

## `maxSecondsPerSite` (type: `integer`):

Time limit for one website. When it is reached the run keeps what it has checked so far and moves on, so a slow site can never keep your run (and your bill) open.

## Actor input object example

```json
{
  "startUrls": [
    "https://www.sitemaps.org"
  ],
  "checkExternalLinks": true,
  "onlyNewBrokenLinks": false,
  "includeWorkingLinks": true,
  "maxPagesPerSite": 5,
  "maxLinksPerSite": 60,
  "maxConcurrency": 8,
  "requestTimeoutSecs": 15,
  "maxSecondsPerSite": 300
}
```

# Actor output Schema

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

No description

## `summary` (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://www.sitemaps.org"
    ],
    "includeWorkingLinks": true,
    "maxPagesPerSite": 5,
    "maxLinksPerSite": 60
};

// Run the Actor and wait for it to finish
const run = await client.actor("pennapixel/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://www.sitemaps.org"],
    "includeWorkingLinks": True,
    "maxPagesPerSite": 5,
    "maxLinksPerSite": 60,
}

# Run the Actor and wait for it to finish
run = client.actor("pennapixel/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://www.sitemaps.org"
  ],
  "includeWorkingLinks": true,
  "maxPagesPerSite": 5,
  "maxLinksPerSite": 60
}' |
apify call pennapixel/broken-link-checker --silent --output-dataset

```

## MCP server setup

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