# Website Robots & Sitemap Indexability Audit (`practical_ai_lab_jp/pal-website-robots-sitemap-indexability-audit`) Actor

Checks robots.txt, bounded sitemap URLs and canonical/noindex signals on a site you are authorized to audit, then reports changes between runs.

- **URL**: https://apify.com/practical_ai_lab_jp/pal-website-robots-sitemap-indexability-audit.md
- **Developed by:** [Practical AI Lab](https://apify.com/practical_ai_lab_jp) (community)
- **Categories:** E-commerce, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 change reports

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

## Website Robots & Sitemap Indexability Audit

Checks a public HTTPS site you are authorized to audit for **contradictions between what the sitemap promises and what the pages and robots.txt say**, then reports **what changed since the previous run**. It is a bounded sampling tool, not a full-site crawler.

### What it checks

1. Reads `robots.txt` first and obeys it (longest-match rules, `*` and `$` wildcards) for its own user agent.
2. Reads sitemaps declared in robots.txt (or `/sitemap.xml`) within strict file, size and URL limits.
3. Requests a limited number of listed pages and flags, per URL:
   - `SITEMAP_URL_NOINDEX` (meta robots / googlebot or `X-Robots-Tag`)
   - `SITEMAP_URL_CANONICAL_MISMATCH`, `SITEMAP_URL_CANONICAL_OFFSITE`, `MULTIPLE_CANONICALS`
   - `SITEMAP_URL_DISALLOWED_BY_ROBOTS` (not fetched) and `SITEMAP_URL_DISALLOWED_FOR_GOOGLEBOT`
   - `SITEMAP_URL_REDIRECTS`, `SITEMAP_URL_UNSAFE_REDIRECT`, `SITEMAP_URL_ERROR_STATUS`
   - Site-level: `SITEMAP_NOT_FOUND`, `SITEMAP_BROKEN_XML`, `SITEMAP_TOO_LARGE`, `SITEMAP_EMPTY`, `SITEMAP_BLOCKED_BY_ROBOTS`
4. Compares with the stored baseline for that domain and emits `CHANGE` records: URLs added/removed, issues appeared/resolved, status or canonical changed.

### Sample input

```json
{
    "startUrl": "https://www.your-own-site.com",
    "maxPages": 25,
    "maxSitemapUrls": 1000,
    "maxSitemapFiles": 5,
    "requestDelayMs": 1000
}
```

Only `startUrl` is required. Use a site you own or may audit. The default `https://example.com` is a placeholder and will mostly report a missing sitemap.

### Run statuses

| Status | Meaning | Charged |
| --- | --- | --- |
| `BASELINE_CREATED` | First run for this domain; baseline stored, current findings listed | No |
| `CHANGES_DETECTED` | Differences versus the baseline were found | Event `change-report` once (price set by the publisher, if any) |
| `NO_CHANGES` | Nothing differs in the audited sample | No |
| `BLOCKED_BY_ROBOTS` | robots.txt forbids this crawler (or returns 401/403); nothing fetched | No |
| `INVALID_INPUT`, `FAILED_*` | Bad input, unreadable robots.txt, or sitemap network error; run fails | No |

### Output

- **Dataset** rows with `recordType` = `FINDING`, `CHANGE` or `SUMMARY`, each with `sourceUrl` and `checkedAt`. Export as JSON or CSV from the Console/API.
- Key-value store `OUTPUT` (JSON) and `REPORT_CSV` (CSV) in the run's default store.
- The baseline lives in a **named** key-value store (`snapshotStoreName`, default `pal-indexability-snapshots`) with one key per domain, so it survives between runs. The latest run replaces the baseline.

### Scheduling

Create an Apify Task with your input and schedule it (for example weekly). Keep `snapshotStoreName` identical across runs and tasks that should share a baseline. Use distinct names to keep separate baselines for the same domain.

### Safety rules built in

- HTTPS site root only; rejects credentials, custom ports, IP addresses, localhost/internal names, and hosts resolving to non-public addresses.
- Redirects are followed only within the same origin, up to 3 hops, and only to robots-permitted URLs. Others are reported and not followed.
- Page requests are hard-capped by `maxPages` (redirect hops count); at least 500 ms between requests; no proxies, cookies or logins; 401/403/blocked pages are reported, never retried or bypassed.
- Response sizes are capped (page 256 KB, sitemap 2 MB, robots.txt 500 KB). Sitemaps with DTD/entity declarations are rejected.
- Only URLs, status codes and indexability directives are stored. Page text, emails and phone numbers are never extracted; URLs containing `@` are skipped.

### Limitations and sample-size caveats

- **Sampling:** pages are checked in sitemap order up to `maxPages`. A clean result covers only that sample; it does not prove the whole site is clean. Check `pagesNotRequestedDueToLimit` in the summary.
- If a sitemap limit is reached, additions/removals are not compared for that run.
- Only the document head is parsed: JavaScript-rendered tags, `<base>`, HTTP `Link` canonical headers and `.xml.gz` sitemaps are not evaluated.
- Canonical and noindex are reported as signals; search engines may decide differently. Googlebot disallow is evaluated from the same robots.txt and is informational.
- Robots matching is a careful reimplementation, not an official parser, and does not normalize percent-encoding. DNS is checked before each request, but a determined DNS rebinding race cannot be fully excluded.
- Changes caused by A/B tests, geo-dependent or flaky responses may appear as changes.
- It does not measure actual index coverage, rankings or traffic.

### Local development

```bash
python -m unittest discover -s tests -t .
```

# Actor input Schema

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

Public HTTPS site root such as https://www.example.com. No path, query, credentials or custom port. Only audit sites you own or have permission to check.

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

Hard cap on page requests (redirect hops count). Pages are taken from the sitemap in listed order, so this is a sample for large sites.

## `maxSitemapUrls` (type: `integer`):

Stops reading sitemaps after this many unique same-site URLs.

## `maxSitemapFiles` (type: `integer`):

Limits sitemap index recursion (index depth is capped at 2).

## `requestDelayMs` (type: `integer`):

Pause between requests to the audited site. Minimum 500.

## `snapshotStoreName` (type: `string`):

Named key-value store that keeps one baseline per domain between runs. Lowercase letters, digits and hyphens, 3-63 characters.

## Actor input object example

```json
{
  "startUrl": "https://www.python.org/",
  "maxPages": 25,
  "maxSitemapUrls": 1000,
  "maxSitemapFiles": 5,
  "requestDelayMs": 1000,
  "snapshotStoreName": "pal-indexability-snapshots"
}
```

# Actor output Schema

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

Download rows from the latest run in JSON/CSV.

# 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://www.python.org/"
};

// Run the Actor and wait for it to finish
const run = await client.actor("practical_ai_lab_jp/pal-website-robots-sitemap-indexability-audit").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://www.python.org/" }

# Run the Actor and wait for it to finish
run = client.actor("practical_ai_lab_jp/pal-website-robots-sitemap-indexability-audit").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://www.python.org/"
}' |
apify call practical_ai_lab_jp/pal-website-robots-sitemap-indexability-audit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,practical_ai_lab_jp/pal-website-robots-sitemap-indexability-audit"
        }
    }
}
```

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/uzK4wnxjvf25oRFTq/builds/jfrHlNqKhkNBtYDz8/openapi.json
