# Broken Link Checker — Find 404s and Dead Links on a Website (`ponderable_hydrometer/broken-links`) Actor

Website link checker and dead link checker: crawl a site, check every link, image, script and stylesheet, and get 404 errors, server errors and timeouts with the status code, redirect target and the page where each broken link sits. Internal and external links.

- **URL**: https://apify.com/ponderable_hydrometer/broken-links.md
- **Developed by:** [Ponderable Hydrometer](https://apify.com/ponderable_hydrometer) (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.50 / 1,000 results

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 on a Website

**Every dead link on your site, with the page it sits on.** This website link checker crawls your pages, collects every link, image, stylesheet and script, and checks each one once. You get the status code, where a redirect lands, and the exact page and anchor text to fix. It reads plain HTML, so there is no browser and no proxy.

### What you can do with it

- **Find 404 errors and dead links** on your own site before visitors and search engines do, as part of an SEO or content audit.
- **Check outbound links** to other sites and catch pages that moved or disappeared (`checkExternal`).
- **Check broken images, stylesheets and scripts**, not only text links.
- **Run it after a migration or redesign** to confirm old URLs still resolve or redirect.
- **Schedule it weekly** with `onlyBroken` on: a healthy site returns no rows and costs nothing.

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `startUrls` | array | — | Sites to check. The crawl stays on each start URL's site. |
| `maxPages` | integer | `100` | Pages to crawl per site. |
| `checkExternal` | boolean | `true` | Also check outbound links. |
| `onlyBroken` | boolean | `false` | Return only failing links. |

Example: `{"startUrls": ["https://books.toscrape.com"], "maxPages": 50, "onlyBroken": true}`

### What you get

One row per checked link: `site`, `url`, `status`, `broken`, `error` (timeout, DNS failure…), `redirectedTo`, `foundOn`, `anchorText`, `element`, `internal`, `responseMs`.

### Output sample

```json
{
  "site": "https://books.toscrape.com",
  "url": "https://books.toscrape.com/catalogue/page-51.html",
  "status": 404,
  "broken": true,
  "error": null,
  "redirectedTo": null,
  "foundOn": "https://books.toscrape.com/catalogue/page-50.html",
  "anchorText": "next",
  "element": "a",
  "internal": true,
  "responseMs": 212
}
```

### Use it from the API or an AI agent

Start a run and read the broken links back in one HTTP call:

```bash
curl -X POST "https://api.apify.com/v2/acts/ponderable_hydrometer~broken-links/run-sync-get-dataset-items?token=<YOUR_API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"startUrls": ["https://books.toscrape.com"], "maxPages": 20, "onlyBroken": true}'
```

AI agents can call it through the Apify MCP server: `https://mcp.apify.com?tools=ponderable_hydrometer/broken-links`.

### How it works

The Actor reads each start page, collects the links on it (`a`, `img`, stylesheet and `script` elements) and follows same-site page links until `maxPages` is reached. Then it checks every unique link: a HEAD request first, and a GET request when the server rejects HEAD (403, 405 or 501). Redirects are followed, so `status` is the final status and `redirectedTo` is where the link ended up. A link is `broken` when the final status is 400 or higher or when there was no answer at all (timeout, DNS failure, connection error).

### Limits and good to know

- Each unique link is checked once, even if it appears on many pages; `foundOn` shows the first page where it was seen.
- Pages are read as static HTML. Links that only exist after JavaScript runs are not seen, and image `srcset` and CSS background images are not checked.
- `mailto:`, `tel:`, `javascript:` and `#anchor` links are skipped, and so are fragments (`#section`) when comparing URLs.
- Some sites answer automated checks with 403 or 429 although the link works in a browser; treat those as "verify by hand".
- A request that takes longer than 15 seconds is reported as `timeout`. The Actor does not read `robots.txt`: run it on sites you own or have permission to check.
- It lists broken links and redirect targets. It does not follow whole redirect chains hop by hop, and it does not check page content such as titles or canonical tags.
- With `onlyBroken`, a healthy site returns no rows and costs nothing.

### FAQ

**Does it check links on other sites?** Yes, by default (`checkExternal`). Pages on other sites are checked but never crawled.

**How do I check a list of URLs without crawling?** This Actor starts from a site and discovers links itself; it is not a bulk URL list checker.

**Why is a working link reported as broken?** Some servers block automated requests (403, 429) or are slow; the `status` and `error` fields show which. Re-check those by hand.

**Does it count redirects as broken?** No. A redirect that ends on a page that works is `broken: false` with `redirectedTo` filled in. A redirect that ends on a 404 is broken.

### Pricing

Pay per result — **$0.50 per 1,000 results** (one checked link = one result), plus Apify's standard per-run start event ($0.00005 per GB of memory, so a fraction of a cent per run). No subscription.

# Actor input Schema

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

Start pages; the crawl stays on each start URL's site.

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

Pages of the site to read links from.

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

Also check links that point to other sites.

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

Off: every checked link is a row, with its status. On: only links that fail.

## Actor input object example

```json
{
  "startUrls": [
    "https://books.toscrape.com"
  ],
  "maxPages": 5,
  "checkExternal": true,
  "onlyBroken": false
}
```

# Actor output Schema

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

All rows produced by this run, as JSON.

# 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://books.toscrape.com"
    ],
    "maxPages": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("ponderable_hydrometer/broken-links").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://books.toscrape.com"],
    "maxPages": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("ponderable_hydrometer/broken-links").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://books.toscrape.com"
  ],
  "maxPages": 5
}' |
apify call ponderable_hydrometer/broken-links --silent --output-dataset

```

## MCP server setup

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

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/VZP1OtVLpFkU2QEJs/builds/vtdYZ5pECndUKdRQc/openapi.json
