# Broken Link Checker - Find 404s and Dead Links (`just_candlestand_hs1/broken-link-checker`) Actor

Crawl a website and check every internal and external link. Get the HTTP status, redirect target, and the pages and anchor text where each broken link appears.

- **URL**: https://apify.com/just_candlestand_hs1/broken-link-checker.md
- **Developed by:** [Nitesh Singh](https://apify.com/just_candlestand_hs1) (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.80 / 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 404s and Dead Links

Crawl your website and check every link on it, internal and external. For each broken link you get the HTTP status, the error, and **every page it appears on with its anchor text**, so you know exactly what to fix.

### What it does

1. Starts from the URLs you give it and crawls pages on the same domain (it respects `robots.txt`).
2. Collects every unique link on those pages.
3. Checks each link once and reports the result.

### Why use it

- **Fewer false alarms.** Sites like LinkedIn and Stack Overflow block automated checks with 403/999. These are marked `blocked`, not `broken`, so you can tell real dead links from bot blocking. Temporary 502/503/504 errors are retried before being reported.
- **Fix-ready output.** Each link lists the pages it appears on (`foundOn`) and its anchor text.
- **Pay only for what's checked.** $0.0008 per unique link checked. A 100-page site with 1,500 unique links costs about $1.20.

### Input

| Field | Description | Default |
| --- | --- | --- |
| `startUrls` | Pages to start from | required |
| `maxPages` | Max pages on your site to crawl | 100 |
| `checkExternal` | Also check links to other websites | true |
| `onlyBroken` | Only output broken and blocked links | false |
| `maxConcurrency` | Parallel requests | 10 |

### Output

One row per unique link:

```json
{
  "url": "https://example.com/old-page",
  "verdict": "broken",
  "status": 404,
  "ok": false,
  "error": null,
  "redirectedTo": null,
  "likelyBotBlock": false,
  "isExternal": false,
  "foundOn": ["https://example.com/blog/post-1", "https://example.com/about"],
  "foundOnCount": 2,
  "anchorText": "our old page",
  "responseMs": 143
}
```

`verdict` is `ok`, `broken` (4xx/5xx, DNS failure or timeout) or `blocked` (the site refuses automated checks; verify by hand).

A run summary (`linksFound`, `checked`, `broken`, `blockedBySite`) is saved in the key-value store under `SUMMARY`.

### Tips

- Set a **maximum cost per run** in the run options to cap spending; the Actor stops cleanly when it is reached.
- Schedule it weekly and connect the dataset to Slack or email to catch new broken links early.
- Only crawl websites you own or have permission to check.

# Actor input Schema

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

Pages to start crawling from. Only pages on the same domain are crawled; links to other domains are checked but not crawled.

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

Stop crawling after this many pages on your site.

## `checkExternal` (type: `boolean`):

Also check links that point to other websites.

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

Skip working links in the results. Every checked link is still billed, because it had to be checked.

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

How many requests to make at the same time. Lower this for small websites.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://crawlee.dev/"
    }
  ],
  "maxPages": 10,
  "checkExternal": true,
  "onlyBroken": false,
  "maxConcurrency": 10
}
```

# Actor output Schema

## `links` (type: `string`):

Every unique link found and checked, with its verdict (ok, broken, blocked), HTTP status and the pages it appears on.

## `brokenLinks` (type: `string`):

Same as Checked links, filtered to links that are not OK.

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

Totals for the run: links found, checked, broken, and blocked by the site.

# 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://crawlee.dev/"
        }
    ],
    "maxPages": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("just_candlestand_hs1/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://crawlee.dev/" }],
    "maxPages": 10,
}

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

```

## MCP server setup

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