# Broken Link Checker + Redirect Chain SEO Audit CSV (`badboxx_newlife/broken-link-checker`) Actor

- **URL**: https://apify.com/badboxx_newlife/broken-link-checker.md
- **Developed by:** [Francesco Correnti](https://apify.com/badboxx_newlife) (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

Pay per event

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: 404 Finder, Redirect Chain Audit & SEO Audit CSV

Broken link checker and 404 finder for SEO folks and site owners. Crawls one site, runs a redirect chain audit on every internal and external link, and hands you a ready-made SEO audit CSV (`OUTPUT.csv`) plus a `SUMMARY` record. No post-processing.

### What it does

- Crawls one site (same domain only) with Crawlee `CheerioCrawler`, up to `maxPages` and `maxDepth`.
- Checks every unique internal and external link once (HEAD, GET fallback on 403/405/501 or network error).
- Follows redirects manually (max 10 hops) and records every hop URL + status.
- Writes one dataset row per (source page, link) pair, a `SUMMARY` JSON and `OUTPUT.csv` to the key-value store.

### Why this one

- **Redirect chains**: the full chain per link (`301 -> 302 -> 200`), not just the final status.
- **Summary**: counts of 2xx, 404, 4xx, 5xx, redirects, chains longer than 1 hop, timeouts.
- **CSV**: open `OUTPUT.csv` in Excel/Sheets straight away. Quotes, commas and newlines are escaped.

### Input

| field | default | note |
|---|---|---|
| `startUrl` (required) | `https://crawlee.dev` | |
| `maxPages` | 500 | 1-10000 |
| `maxDepth` | 3 | 0 = start page only |
| `checkExternal` | true | false: external links listed with error `skipped`, never requested |
| `respectRobots` | true | disallowed pages are not crawled, links to them are still checked |
| `maxConcurrency` | 10 | max 20, also caps link-check concurrency |
| `requestTimeoutSecs` | 15 | per link check / page |

### Output

Dataset row:

```json
{"source_page":"https://quotes.toscrape.com","link":"https://quotes.toscrape.com/author/Albert-Einstein","status":200,"redirect_chain":[{"url":"https://quotes.toscrape.com/author/Albert-Einstein","status":308}],"final_url":"http://quotes.toscrape.com/author/Albert-Einstein/","type":"internal","anchor":"(about)","error":null}
```

`error` is `null`, `timeout`, `too_many_redirects`, `skipped` or the network error message (`status` is then `null`).

`SUMMARY` (key-value store): see the example run below.

`OUTPUT.csv`:

```csv
source_page,link,status,redirect_chain,final_url,type,anchor,error
https://quotes.toscrape.com,https://quotes.toscrape.com/login,200,,https://quotes.toscrape.com/login,internal,Login,
https://quotes.toscrape.com,https://quotes.toscrape.com/author/Albert-Einstein,200,https://quotes.toscrape.com/author/Albert-Einstein (308),http://quotes.toscrape.com/author/Albert-Einstein/,internal,(about),
```

Chains are written `url1 (301) -> url2 (302)`.

### Pricing

Pay per event: **$0.005 per run start** + **$0.003 per page crawled**. Link checks are free. 500 pages is about $1.50 + start fee.

### Example run

Smoke run, `{"startUrl":"https://quotes.toscrape.com","maxPages":20,"maxDepth":2,"requestTimeoutSecs":10}` against https://quotes.toscrape.com (2026-10-15):

```json
{"startUrl":"https://quotes.toscrape.com","pages_crawled":20,"links_total":458,"unique_links":121,"ok_2xx":121,"broken_404":0,"errors_4xx":0,"errors_5xx":0,"redirects":31,"redirect_chains_gt1":0,"timeouts":0,"other_errors":0,"finished_at":"2026-10-15T03:21:57.150Z"}
```

### FAQ

- **robots.txt?** Respected by default for crawling. Disallowed pages are not fetched as pages, but links pointing to them are still checked (HEAD).
- **External links?** Checked by default. Set `checkExternal` false to skip them (they stay in the output with `skipped`).
- **Limits?** 10000 pages, 20 concurrent requests, 300 page requests/min, 10 redirect hops per link. Internal links beyond `maxPages`/`maxDepth` get a status but are not crawled.
- **JS-rendered links?** Not seen: plain HTML only.
- **Summary counts** are per unique link; `links_total` counts dataset rows.

### Run and test locally

```
npm ci
echo '{"startUrl":"https://example.com"}' > storage/key_value_stores/default/INPUT.json   # mkdir -p first
npm start
npm test   # local fixture servers, no internet, ~30-60 s
```

# Actor input Schema

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

Site to crawl. Only pages on the same domain are crawled.

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

Maximum pages to crawl.

## `maxDepth` (type: `integer`):

Link depth from the start page. 0 = start page only.

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

If off, external links are listed with error 'skipped'.

## `respectRobots` (type: `boolean`):

Do not crawl pages disallowed by robots.txt (links to them are still checked).

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

Parallel page crawls and link checks.

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

Timeout per link check / page.

## Actor input object example

```json
{
  "startUrl": "https://crawlee.dev",
  "maxPages": 500,
  "maxDepth": 3,
  "checkExternal": true,
  "respectRobots": true,
  "maxConcurrency": 10,
  "requestTimeoutSecs": 15
}
```

# Actor output Schema

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

No description

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

No description

## `csv` (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://crawlee.dev"
};

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

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

```

## MCP server setup

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