# Broken Link Checker with Wayback Machine Rescue (`utility-belt-labs/broken-link-checker-wayback`) Actor

Find broken links (404s, DNS errors, timeouts, redirect chains) on your pages and get the closest Wayback Machine archive copy for each.

- **URL**: https://apify.com/utility-belt-labs/broken-link-checker-wayback.md
- **Developed by:** [Utility Belt Labs](https://apify.com/utility-belt-labs) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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 with Wayback Machine Rescue

**Find broken links on your web pages and get the closest archived copy from the Internet Archive's Wayback Machine for each one.** Give it a list of page URLs, or one site start URL with an optional shallow same-domain crawl. For every link it returns the HTTP status, the final URL after redirects, the number of redirects, a `broken` flag, the error (timeout, DNS failure, SSL error, redirect loop) and, for broken links, a ready-to-use Wayback Machine URL and timestamp to replace or reference the dead link.

No login or API key needed. Wayback snapshots come from the public Internet Archive availability API (archive.org/wayback/available).

### Use cases

- **SEO and content teams:** build a fix list of dead outbound and internal links, with a suggested archived replacement for each.
- **Documentation and blog maintenance:** find link rot in old posts, wikis, README pages and resource lists.
- **Site migrations and redesigns:** spot 404s, 5xx errors and long redirect chains before and after a launch.
- **Researchers and journalists:** recover the archived version of sources that have disappeared.
- **AI agents:** call it as a tool through the Apify MCP server ("check this page for dead links and give me archive.org copies").

### How it works

1. Downloads each page you list (and, if you turn on **Crawl same domain**, internal pages up to your depth and page limits). It reads `robots.txt` for page downloads.
2. Extracts links from `<a href>` (and `<img src>` if enabled), resolves relative URLs, skips `mailto:`, `tel:`, `javascript:` and `#fragment` links, and removes duplicates.
3. Checks each unique link with a **HEAD** request, falling back to **GET** when HEAD fails or is refused. Redirects are followed one hop at a time so the chain length is known (3+ hops is flagged as `redirect-chain`; loops and too many hops count as broken).
4. Requests are polite: limited total concurrency, at most 2 parallel requests per host, a short delay between requests to the same host, timeouts, and the user agent `UtilityBeltLabsLinkChecker`.
5. For each **broken** link, asks the Wayback Machine for the closest snapshot, one request at a time, with a minimum interval, `Retry-After` / exponential backoff and a cache (7 days) so repeated runs do not hit archive.org again for the same URL.

### Input

| Field | What it does |
|---|---|
| `urls` | Page URLs whose links you want checked. |
| `startUrl` | One site start page (combine with `crawl`). |
| `crawl`, `maxDepth`, `maxPages` | Shallow same-domain crawl (default off; depth 1; up to 10 pages). |
| `maxLinks` | Cap on output rows (page + link pairs), default 300, max 5000. |
| `checkExternalLinks`, `checkImages` | Include links to other domains (default on) and `<img>` sources (default off). |
| `onlyBroken` | Output only problem links (broken, redirect chains, unverifiable) for a short fix list. |
| `lookupWayback`, `maxWaybackLookups` | Turn Wayback rescue on/off and cap archive.org requests per run (default 50). |
| `respectRobotsTxt` | Skip pages that `robots.txt` disallows for page downloads (default on). |
| `concurrency`, `requestTimeoutSecs`, `maxRedirects` | Speed and safety limits. |

### Output

One row per link found on each page:

```json
{
  "sourcePage": "https://example.org/resources/",
  "link": "https://example.com/old-docs/removed.html",
  "status": 404,
  "finalUrl": "https://example.com/old-docs/removed.html",
  "redirectCount": 0,
  "broken": true,
  "verdict": "broken",
  "error": null,
  "waybackLookup": "found",
  "waybackUrl": "https://web.archive.org/web/20230114093021/https://example.com/old-docs/removed.html",
  "waybackTimestamp": "20230114093021"
}
```

- `verdict`: `ok`, `broken`, `redirect-chain` (works but 3+ redirects), or `unverifiable` (401/403/405/406/429/451/999: the server blocks automated checks, so the link may be fine in a browser; it is **not** counted as broken).
- `error`: `timeout`, `dns-error`, `ssl-error`, `connection-error`, `too-many-redirects`, `redirect-loop`, or empty.
- `waybackLookup`: `found`, `not-archived`, `rate-limited`, `skipped-limit`, `error`, `not-needed` (link is fine) or `not-requested`. `waybackTimestamp` is the snapshot time as `YYYYMMDDhhmmss` (UTC).
- Export as JSON, CSV, Excel or HTML, or use the **Link check results** view in the Output tab. A run summary is stored in the key-value store under `SUMMARY`.

### Limits and honest notes

- **archive.org rate-limits heavily.** When it answers HTTP 429 the Actor backs off, then stops asking for the rest of that run and marks the affected rows `waybackLookup: "rate-limited"`. The link check results are still complete; run again later (cached results are reused) to fill in the archive URLs. Large numbers of broken links will not all get a Wayback lookup in one run (`maxWaybackLookups`).
- **A snapshot is the closest one the Wayback Machine has**, not necessarily the page as you remember it; it may be years old or a different version. Many URLs are simply not archived (`not-archived`).
- **Not a full-site crawler.** The crawl is shallow, same-domain, capped at 200 pages, and does not run JavaScript, so links added by client-side scripts are not seen. Pages over 2 MB are truncated.
- **Some sites block automated checks** (403, 429, 999 from LinkedIn and others, bot protection pages). These show as `unverifiable`, not broken. Redirects to a login or "soft 404" page that returns HTTP 200 look fine to a status check.
- A timeout or DNS error can be temporary; re-check important links before you remove them.
- Link status checks are not filtered by `robots.txt` (like most link checkers, each is one lightweight request). Only check pages and sites you are allowed to check, and keep concurrency modest.
- Not affiliated with the Internet Archive. Wayback Machine is a trademark of its owner.

### Pricing

Currently free to run (you only pay normal Apify platform usage). Pricing may change to pay-per-result (one event per checked link) in the future; check the Store page.

### Support

Questions or feature requests: please open an issue in the Issues tab of this Actor.

# Actor input Schema

## `urls` (type: `array`):

Pages whose outgoing links you want to check, one URL per entry (http/https). Each page is downloaded once and every link on it is tested.

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

A single start page. Use together with 'Crawl same domain' to also visit internal pages of the same site (shallow crawl). Can be combined with the list above.

## `crawl` (type: `boolean`):

Follow internal links (same domain as the start URL / each listed page) up to the depth and page limits below. Off by default: only the pages you list are checked.

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

Upper limit on the number of source pages fetched (listed pages plus crawled pages).

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

How many clicks from the start page to follow when crawling. 1 = start page plus the pages it links to.

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

Upper limit on rows (page + link pairs). The run stops collecting links once reached.

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

Also test links that point to other domains. Turn off to check only links within the same site.

## `checkImages` (type: `boolean`):

Include <img> sources in addition to <a> links.

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

Output only broken links, long redirect chains and unverifiable links, to get a short fix list. Good-link rows are skipped (and not charged).

## `lookupWayback` (type: `boolean`):

For each broken link, ask the Internet Archive for the closest archived snapshot. Lookups are throttled and cached; if archive.org rate-limits the run, affected rows say 'rate-limited' instead of failing.

## `maxWaybackLookups` (type: `integer`):

Cap on archive.org requests (distinct broken URLs). Extra broken links get waybackLookup = 'skipped-limit'.

## `respectRobotsTxt` (type: `boolean`):

Pages disallowed by the site's robots.txt for our user agent are skipped. (Link status checks are single HEAD/GET requests and are not filtered by robots.txt.)

## `concurrency` (type: `integer`):

Total parallel link checks. At most 2 requests per host run at once, with a short delay between requests to the same host.

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

Per request. Slower responses are reported as 'timeout'.

## `maxRedirects` (type: `integer`):

Redirect chains of 3 or more hops are flagged as 'redirect-chain'; hitting this limit counts as broken (possible loop).

## Actor input object example

```json
{
  "urls": [
    "https://example.com/"
  ],
  "crawl": false,
  "maxPages": 10,
  "maxDepth": 1,
  "maxLinks": 300,
  "checkExternalLinks": true,
  "checkImages": false,
  "onlyBroken": false,
  "lookupWayback": true,
  "maxWaybackLookups": 50,
  "respectRobotsTxt": true,
  "concurrency": 5,
  "requestTimeoutSecs": 15,
  "maxRedirects": 5
}
```

# Actor output Schema

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

Dataset of checked links: source page, link, status, final URL, redirect count, broken flag, error and archived copy (Wayback Machine) when available.

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

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

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,utility-belt-labs/broken-link-checker-wayback"
        }
    }
}
```

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/qxmKbKaCnXMXdO8ls/builds/MSitg2WLGDsgEugib/openapi.json
