# Canonical Tag Checker - Bulk Canonical URL Audit (`devoted_laureate_r8f/canonical-tag-checker`) Actor

Check the canonical tag of one or many URLs: missing or relative canonicals, canonicals pointing to another page, redirected URLs and HTTP status. One row per URL.

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

## Pricing

$4.00 / 1,000 url 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

## Canonical Tag Checker

Checks canonical link tags on a list of public URLs and flags missing, broken, or inconsistent canonicals. Returns a clean per-URL report ready for export.

### What it does

SEOs and web developers often need to confirm, in bulk, that every important page carries a correct `<link rel="canonical">` tag. This Actor fetches each URL you provide (following redirects up to a configurable limit), reads the resulting HTML, and reports whether a canonical tag exists, whether it is a well-formed absolute URL, and whether it points back to the page itself (self-referencing) or somewhere else.

### Input

| Field | Type | Description |
|---|---|---|
| `urls` | array of strings | Public page URLs to audit (max 200; URLs beyond the 200th are reported as errored rows, not silently dropped). **Required.** |
| `maxRedirects` | integer | Maximum HTTP redirects followed per URL before giving up. Default `5`, range `0-10`. |
| `timeoutMs` | integer | Total timeout in milliseconds for a URL, covering its whole redirect chain (the clock is not reset at each hop). Default `10000`, range `1000-30000`. |

Example input:

```json
{
  "urls": ["https://example.com/", "https://example.com/page1"],
  "maxRedirects": 5,
  "timeoutMs": 10000
}
```

### Output

One dataset row per input URL:

| Field | Description |
|---|---|
| `url` | Original URL provided as input. |
| `finalUrl` | URL after following redirects, or `null` on error. |
| `statusCode` | HTTP status code returned by the server, or `null` on error. |
| `canonicalUrl` | Value of the canonical link tag found in the HTML, or `null` if missing. |
| `isMissing` | `true` if no canonical tag was found on the page. |
| `isSelfReferencing` | `true` if the canonical tag points to the final URL itself. |
| `isValid` | `true` if the canonical value is a well-formed absolute URL. |
| `error` | Error message if the URL could not be fetched or was invalid; otherwise `null`. |

For URLs that cannot be fetched (invalid format, timeout, too many redirects, network error, or beyond the 200-URL limit), the boolean/analysis fields are returned as `null` and `error` describes the failure.

### Network access

This Actor only fetches the public HTTP(S) URLs you provide as input; it makes no other outbound calls.

### Pricing

Pay per event: **$0.004 per url checked**. One URL fetched and its canonical tag fully validated (charged even when the canonical is correct).

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

- Up to 200 URLs per run.
- Public pages only — no login or authenticated content, no personal data collected.
- Redirects and timeout are bounded (0-10 redirects, 1-30 seconds) to keep runs predictable.

### 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~canonical-tag-checker/run-sync-get-dataset-items" \
  -H "Authorization: Bearer <APIFY_TOKEN>" -H "Content-Type: application/json" \
  -d '{"urls": ["https://www.python.org/", "https://docs.python.org/3/"], "maxRedirects": 5, "timeoutMs": 10000}'
```

**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/canonical-tag-checker').call({"urls": ["https://www.python.org/", "https://docs.python.org/3/"], "maxRedirects": 5, "timeoutMs": 10000});
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/canonical-tag-checker").call(run_input={"urls": ["https://www.python.org/", "https://docs.python.org/3/"], "maxRedirects": 5, "timeoutMs": 10000})
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": {
    "canonical-tag-check": {
      "url": "https://mcp.apify.com?tools=devoted_laureate_r8f/canonical-tag-checker",
      "headers": {
        "Authorization": "Bearer <APIFY_TOKEN>"
      }
    }
  }
}
```

For agents: call it when you need to validate the rel=canonical tag of one or many URLs. Input: `urls` (list of URLs); optional `maxRedirects`, `timeoutMs`. Output: one record per URL: canonical URL, missing/relative/self-referencing flags, final URL after redirects, status code. Cost: $0.004 per url checked; failures are not charged.

### FAQ

**Can I check many URLs at once?**

Yes, pass a list of URLs; you get one row per URL.

**Am I charged for a correct canonical?**

Yes, one event per URL checked; failed fetches are not charged.

### Related tools

- [Hreflang Checker - Validate hreflang Tags](https://apify.com/devoted_laureate_r8f/audit-hreflang) — hreflang alternates should be the canonical URLs
- [Broken Link Checker - Find Dead Links on a Page](https://apify.com/devoted_laureate_r8f/broken-link-checker) — find links that point to dead pages

# Actor input Schema

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

Public page URLs to audit for their canonical link tag. Only the first 200 are fetched; any extra URLs are reported as errored rows, not silently dropped.

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

Maximum number of HTTP redirects to follow per URL before giving up.

## `timeoutMs` (type: `integer`):

Total timeout in milliseconds before giving up on a URL, covering the whole redirect chain (not reset at each hop).

## Actor input object example

```json
{
  "urls": [
    "https://example.com/",
    "https://example.com/page1"
  ],
  "maxRedirects": 5,
  "timeoutMs": 10000
}
```

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

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

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

```

## MCP server setup

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