# Broken Link Checker - Find Dead Links on a Page (`devoted_laureate_r8f/broken-link-checker`) Actor

Scan a web page, check every link it contains (internal and optionally external) and report broken links (404, 5xx, timeouts) with status codes, so you can fix dead links fast.

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

## Pricing

$10.00 / 1,000 page scanneds

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 Dead Links on Any Page

Scans a webpage, extracts every link, and checks each one's HTTP status to find broken (404/5xx/timeout) links. Returns a clear report of dead links with their status codes so you can fix them fast.

### What it does

Give it a page URL and it will:

1. Download the page and extract every unique `<a href>` link (relative links are resolved to absolute URLs). Non-navigable links (`#anchors`, `mailto:`, `tel:`, `javascript:`) are ignored and not counted.
2. Check the HTTP status of each link (up to the configured limit), using a `HEAD` request first and falling back to `GET` only when the server responds `405 Method Not Allowed` or `501 Not Implemented` (other rejections, e.g. `403` or `400`, are reported as-is without a GET retry).
3. Report every link whose status is `404`, any `5xx`, a network error, or a timeout as broken, together with its anchor text.

Useful for developers, SEO managers and site owners who want to catch dead links on a page without installing a heavy crawler.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `startUrl` | string (required) | — | The URL of the page to scan for links. |
| `maxLinks` | integer | `50` | Maximum number of links to check in a single run (1–500), to control cost and runtime. |
| `checkExternalLinks` | boolean | `true` | If `true`, also checks links pointing to other domains, not just the start page's own domain. |

Example input:

```json
{
  "startUrl": "https://example.com",
  "maxLinks": 50,
  "checkExternalLinks": true
}
```

### Output

One dataset row per run:

```json
{
  "sourceUrl": "https://example.com",
  "totalLinksFound": 12,
  "checkedCount": 12,
  "brokenLinks": [
    { "url": "https://example.com/old-page", "anchorText": "Old page", "status": 404 },
    { "url": "https://example.com/down", "anchorText": "Down", "status": "TIMEOUT", "error": "timeout" }
  ]
}
```

- `sourceUrl` — the page that was analyzed.
- `totalLinksFound` — total number of unique links found on the page.
- `checkedCount` — number of links actually checked (limited by `maxLinks`).
- `brokenLinks` — links that returned `404`, `5xx`, a network error, or timed out, each with its URL, status (or error type), and anchor text.

### Pricing

Pay per event: **$0.01 per page scanned**. One page scanned and all its links checked (up to 'Max links'), charged once per page whatever the number of broken links found.

You only pay for these events: the platform usage of the run is covered by the Actor. Failed fetches are not charged. You can cap the cost of a run with the maximum charge setting of your run.

### Limits

- The start page must respond with HTML within 15 seconds, or the run fails immediately with no charge (network error, non-HTML content, or timeout).
- Up to 500 links are checked per run (default 50), to keep cost and runtime predictable.
- No login, no proxy, no personal data collected — only public pages you point it at.

### Use in your workflow

Replace `<APIFY_TOKEN>` with your token from Apify Console → Settings → API & Integrations.

**HTTP API (curl)** — run and get the results in one call:

```bash
curl -X POST "https://api.apify.com/v2/acts/devoted_laureate_r8f~broken-link-checker/run-sync-get-dataset-items" \
  -H "Authorization: Bearer <APIFY_TOKEN>" -H "Content-Type: application/json" \
  -d '{"startUrl": "https://www.python.org/", "maxLinks": 50, "checkExternalLinks": true}'
```

**JavaScript** (`npm install apify-client`):

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

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('devoted_laureate_r8f/broken-link-checker').call({"startUrl": "https://www.python.org/", "maxLinks": 50, "checkExternalLinks": true});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

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

```python
import os
from apify_client import ApifyClient

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("devoted_laureate_r8f/broken-link-checker").call(run_input={"startUrl": "https://www.python.org/", "maxLinks": 50, "checkExternalLinks": True})
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)
```

**AI agents (MCP)** — expose only this Actor as a tool through the Apify MCP server:

```json
{
  "mcpServers": {
    "find-broken-links-on-page": {
      "url": "https://mcp.apify.com?tools=devoted_laureate_r8f/broken-link-checker",
      "headers": {
        "Authorization": "Bearer <APIFY_TOKEN>"
      }
    }
  }
}
```

For agents: call it when you need to find dead links (404, 5xx, timeouts) on a web page. Input: `startUrl`; optional `maxLinks` (up to 500) and `checkExternalLinks`. Output: one record per page with the links checked and `brokenLinks[]` (url, anchor text, status). Cost: $0.01 per page scanned; failures are not charged.

### FAQ

**Which links are checked?**

All links found on the start page, up to 'Max links'. External links are included when 'Check external links' is on.

**Am I charged if no broken link is found?**

Yes, one event per page scanned: every link was still checked and reported.

### Related tools

- [Hreflang Checker - Validate hreflang Tags](https://apify.com/devoted_laureate_r8f/audit-hreflang) — dead alternate URLs also break hreflang
- [Canonical Tag Checker - Bulk Canonical URL Audit](https://apify.com/devoted_laureate_r8f/canonical-tag-checker) — pages you link to should also have a correct canonical

# Actor input Schema

## `startUrl` (type: `string`):

The URL of the page to scan for links.

## `maxLinks` (type: `integer`):

Maximum number of links to check in a single run (controls cost and runtime).

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

If true, also checks links pointing to other domains, not just the start page's own domain.

## Actor input object example

```json
{
  "startUrl": "https://example.com",
  "maxLinks": 50,
  "checkExternalLinks": true
}
```

# Actor output Schema

## `results` (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 = {
    "startUrl": "https://example.com"
};

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

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

```

## MCP server setup

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