# Broken Link Monitor: new dead links on your sites (`asunoki/broken-link-monitor`) Actor

Crawl a site (robots.txt respected), check every internal and external link, and get the broken ones with the pages they are on. Schedule it with Only new to see just the links that broke since the last run, plus how many were fixed.

- **URL**: https://apify.com/asunoki/broken-link-monitor.md
- **Developed by:** [Seisuke Nagahara](https://apify.com/asunoki) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $50.00 / 1,000 site reports

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 Monitor: new dead links on your sites

Crawl a website (robots.txt respected), check every link on it, and get the **broken ones with the pages they are on**. Schedule it with **Only links that broke since the last run** and you see what broke this week and how many were fixed, instead of the same long list every time.

No browser, no proxies: plain HTTP requests, so runs are fast and cheap.

### Who uses it

- **Site owners, agencies and SEO teams**: weekly 404 report per client site.
- **Documentation and help-center teams**: catch links that rot after other sites move pages.
- **Affiliate and content publishers**: spot dead outbound links that lose commissions.

### What you get

One row per broken link, plus one summary row per site.

Broken-link row: `site`, `url`, `issue` (`not_found`, `gone`, `server_error`, `unavailable`, `dns_error`, `tls_error`, `timeout`, `connection_error`, `too_many_redirects`, `client_error`), `statusCode`, `linkType` (internal or external), `anchorText`, `foundOn` (up to 5 pages) and `foundOnCount`, `newSinceLastRun`.

Summary row: `pagesCrawled`, `linksFound`, `linksChecked`, `brokenLinks`, `newlyBroken`, `fixedSinceLastRun`, `stillBroken`, `truncated`.

Example row (illustrative values):

```json
{ "site": "https://example.com", "url": "https://example.com/old-guide", "status": "ok", "issue": "not_found", "statusCode": 404, "linkType": "internal", "anchorText": "Setup guide", "foundOn": ["https://example.com/", "https://example.com/docs"], "foundOnCount": 2, "newSinceLastRun": true }
```

### Input

- **Websites**: start pages. Only same-site pages are crawled; links to other sites are checked, not crawled.
- **Max pages crawled / max links checked** per site.
- **Check links to other sites**: on by default.
- **Skip URLs containing**: ignore `/cart`, tracking parameters and so on.
- **Only links that broke since the last run**: the first run returns every broken link and remembers them. Later runs return only newly broken links; the summary row always shows new, fixed and still-broken counts. Use a different memory-store name for each list you track.

### Run it from code

```python
from apify_client import ApifyClient
client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("asunoki/broken-link-monitor").call(run_input={
    "sites": ["https://example.com"], "maxPagesPerSite": 200, "onlyNew": True, "stateStoreName": "example-weekly"})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row.get("issue"), row.get("url"))
```

Put it on a weekly Apify Schedule and send the dataset to Slack, email or Google Sheets.

### Pricing (pay per event)

- **site-report**: $0.05 per site summary row.
- **broken-link**: $0.002 per broken link row.
- Plus a small start fee. Sites that are blocked by robots.txt, unreachable or invalid are saved as error rows and **are not charged**. A site with no broken links costs just the summary. You do not pay platform usage on top of these events.

Example: a 100-page site with 12 broken links costs about $0.07 per run.

### How it behaves

- **robots.txt is respected** for pages we crawl. Internal URLs that robots.txt disallows are not requested at all.
- One request at a time per host, with a short delay. Links are checked with HEAD (GET only when a server refuses HEAD), up to 6 redirects followed, one retry on network errors.
- **Not counted as broken**: HTTP 401, 403, 429, 451 and 999. Those usually mean a site blocks automated checks, not that the link is dead. The Actor does not try to get past bot protection.
- Only `<a href>` links in HTML pages are checked. Links created by JavaScript after the page loads, images, scripts and files such as PDFs are not.
- The default run timeout is short; for sites over about 300 pages raise the run timeout. `truncated: true` in the summary means the link limit was reached.

# Actor input Schema

## `sites` (type: `array`):

Start pages to crawl, e.g. https://example.com. Only pages on the same site are crawled; links to other sites are checked but not crawled.

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

Pages are crawled breadth-first from the start page.

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

Upper limit of distinct links whose status is checked.

## `includeExternal` (type: `boolean`):

Off = only links within the same site.

## `excludeUrlsContaining` (type: `array`):

Links containing any of these texts are ignored, e.g. /cart or ?utm\_.

## `onlyNew` (type: `boolean`):

The first run returns every broken link and remembers them. Later runs return only newly broken links; the site summary row always shows new, fixed and still-broken counts. Use a different memory-store name for each list you track.

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

Never more than one request at a time to the same host.

## `stateStoreName` (type: `string`):

Use different names to track different lists separately.

## Actor input object example

```json
{
  "sites": [
    "https://example.com"
  ],
  "maxPagesPerSite": 100,
  "maxLinksPerSite": 1000,
  "includeExternal": true,
  "excludeUrlsContaining": [],
  "onlyNew": false,
  "maxConcurrency": 10,
  "stateStoreName": "broken-link-monitor-state"
}
```

# Actor output Schema

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

All rows.

## `runStatistics` (type: `string`):

Counts and charged events (key-value store record STATS).

# 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 = {
    "sites": [
        "https://example.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("asunoki/broken-link-monitor").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 = { "sites": ["https://example.com"] }

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,asunoki/broken-link-monitor"
        }
    }
}
```

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/W360TqR06pXv3o3bd/builds/5KlIaaMGGBf2FZscc/openapi.json
