# Hreflang Tag Checker API | SEO Validator (`andok/hreflang-checker`) Actor

Bulk validate website hreflang tags for international SEO. Audit multi-language sites for missing x-default tags, bidirectional errors, and ISO code compliance.

- **URL**: https://apify.com/andok/hreflang-checker.md
- **Developed by:** [Andok](https://apify.com/andok) (community)
- **Categories:** SEO tools, Developer tools
- **Features:** Limited permissions
- **Stats:** 10 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.47 / 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Hreflang Tag Checker

Validate hreflang tags across multilingual and multi-region sites to prevent international SEO issues. Incorrect hreflang implementation causes search engines to serve the wrong language version to users — costing traffic in every market you target. This actor checks HTML `<link>` elements and HTTP headers, validates language codes against ISO standards, and grades each page from A to F.

### Features

- **Dual source detection** — finds hreflang tags in both HTML `<link>` elements and HTTP `Link` headers
- **ISO validation** — checks language and region codes against ISO 639-1 and ISO 3166-1 standards
- **x-default check** — verifies the required x-default fallback tag is present
- **Self-reference validation** — confirms each page includes a self-referencing hreflang entry
- **Duplicate detection** — flags duplicate or conflicting hreflang entries for the same language
- **Compliance grading** — assigns A/B/C/F grades based on the severity of issues found
- **Batch processing** — check hundreds of URLs in a single run

### Input

| Field | Type | Required | Default | Description |
|-------|------|----------|---------|-------------|
| `urls` | `array` | Yes | — | List of page URLs to check for hreflang implementation |
| `checkBidirectional` | `boolean` | No | `true` | Verify that hreflang links point back to the source page |
| `timeout` | `integer` | No | `15000` | HTTP request timeout in milliseconds |

#### Input Example

```json
{
    "urls": [
        "https://example.com/en/",
        "https://example.com/de/",
        "https://example.com/fr/"
    ],
    "checkBidirectional": true,
    "timeout": 15000
}
```

### Output

Each URL produces one dataset item with the full hreflang audit results and a compliance grade.

- `url` (`string`) — the checked page URL
- `hreflangCount` (`number`) — total number of hreflang tags found
- `hasXDefault` (`boolean`) — whether an x-default tag is present
- `hasSelfReference` (`boolean`) — whether the page references itself in its hreflang tags
- `tags` (`array`) — all discovered hreflang tags with `hreflang` code and `href` URL
- `issues` (`string[]`) — list of errors and warnings found
- `grade` (`string`) — compliance grade: A (perfect), B (minor), C (warnings), F (errors)

#### Output Example

```json
{
    "url": "https://example.com/en/",
    "hreflangCount": 4,
    "hasXDefault": true,
    "hasSelfReference": true,
    "tags": [
        { "hreflang": "en", "href": "https://example.com/en/" },
        { "hreflang": "de", "href": "https://example.com/de/" },
        { "hreflang": "fr", "href": "https://example.com/fr/" },
        { "hreflang": "x-default", "href": "https://example.com/en/" }
    ],
    "issues": [],
    "grade": "A"
}
```

### Pricing

| Event | Cost |
|-------|------|
| URL Checked | $0.001 per URL |

You are charged per URL checked. Platform usage fees apply separately.

### Use Cases

- **International SEO audits** — validate hreflang implementation across all language versions of your site
- **Multi-region launch QA** — verify correct hreflang setup before launching new country-specific pages
- **Migration testing** — confirm hreflang tags survive intact after a CMS migration or URL restructure
- **Agency reporting** — schedule automated checks for multilingual client sites and flag regressions
- **Competitive benchmarking** — analyze how competitors structure their international targeting

### Related Actors

| Actor | What it adds |
|-------|-------------|
| [Broken Links Checker](https://apify.com/andok/broken-links-checker) | Verify that the URLs referenced in hreflang tags actually return 200 OK |
| [Redirect Chain Analyzer](https://apify.com/andok/redirect-chain-analyzer) | Check whether hreflang target URLs redirect, which can confuse search engines |
| [XML Sitemap URL Extractor](https://apify.com/andok/sitemap-extractor) | Extract all multilingual URLs from your sitemap to feed into the hreflang checker |

# Actor input Schema

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

List of page URLs to validate for hreflang tag implementation. Use the full page URL, not just the domain (e.g. https://example.com/en/).

## `checkBidirectional` (type: `boolean`):

Verify that hreflang target pages link back to the source page. Bidirectional references are required by Google's hreflang specification.

## `timeout` (type: `integer`):

HTTP request timeout in milliseconds for fetching each page. Increase for slow-loading pages with many hreflang tags.

## Actor input object example

```json
{
  "urls": [
    "https://crawlee.dev"
  ],
  "checkBidirectional": true,
  "timeout": 15000
}
```

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

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

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

```

## MCP server setup

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