# Sitemap Change Monitor (`your_friendly_developer/sitemap-change-monitor`) Actor

Watches public sitemaps for changes: compares URL sets and lastmod values against the previous snapshot and emits one dataset record per added, removed, or changed URL. Built for SEO operators and site owners.

- **URL**: https://apify.com/your_friendly_developer/sitemap-change-monitor.md
- **Developed by:** [Jason Ramirez](https://apify.com/your_friendly_developer) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 change rows

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

## Sitemap Change Monitor

An Apify Actor for SEO operators and site owners watching their own or client public sitemaps. It compares URL sets and sitemap lastmod values, emitting one machine-readable dataset record per detected change.

### Input

```json
{
  "sitemaps": ["https://example.com/sitemap.xml"],
  "maxUrlsPerSitemap": 5000,
  "includeUnchangedSummary": true
}
```

The positive integer cap applies to all page entries across the children of each supplied sitemap. Child requests are also bounded by that cap. An exceeded cap fails the sitemap and preserves its snapshot, avoiding false removals. Requests run sequentially, with a 30 second timeout each. Sitemap indexes are followed one level deep; deeper indexes fail. Duplicate input sitemaps are processed once.

### Baseline rule

The first successful run saves a baseline and emits exactly one baseline item with a URL count. It does not emit thousands of added rows. Subsequent successful runs emit added, removed, and lastmod-changed rows. A successful run with no changes emits one no-changes status item per sitemap, so the output is never empty and you can prove the check ran (set includeUnchangedSummary to false to skip it). Baseline and no-changes status items are free: you only pay for added, removed, and lastmod-changed rows. A failed fetch or parse preserves the old snapshot.

### Dataset output

| Type | Fields |
| --- | --- |
| baseline | type, sitemap, urlCount, seenAt |
| no-changes | type, sitemap, urlCount, seenAt |
| added | type, sitemap, url, lastmod, seenAt |
| removed | type, sitemap, url, lastmod, previousSeenAt, seenAt |
| lastmod-changed | type, sitemap, url, previousLastmod, lastmod, previousSeenAt, seenAt |

Dates in seenAt are monitor timestamps. lastmod values are strings from the sitemap, or null. Removed records retain the previous lastmod. The sitemap field identifies the supplied top-level source.

Snapshots use SHA-256-derived keys in the default key-value store: `{ fetchedAt, entries: { url: lastmodOrNull } }`. `LAST_RUN_SUMMARY` is stored and logged with runAt, sitemapsRequested, sitemapsOk, sitemapsFailed, baselinesCreated, added, removed, lastmodChanged, skippedPrivateUrls, and sitemapTotals. Each successful sitemap total includes URL count, baseline status, and change counts. Setting includeUnchangedSummary to false omits unchanged sitemap totals, while retaining aggregate counts. Failure errors are deliberately sanitized to avoid echoing response content or sensitive URL parameters.

### Privacy and limits

Use only public page URLs without personal data. Obvious query keys containing token, session, auth, password, secret, API key, signature, or credential are skipped. Credentials in URLs, literal IP hosts, localhost and .local hosts, and non-HTTP schemes are excluded. This heuristic is not a personal-data detector or a DNS-based network access control. Operators must supply public sitemaps and avoid personal data in paths or other query fields. skippedPrivateUrls counts excluded page and child sitemap URLs on successful sitemap fetches; failures do not report partial skip counts. Unsafe input sitemap URLs are redacted in failure summaries.

Polling only detects changes visible when the Actor runs. lastmod is whatever the sitemap claims, without validation of page contents. Duplicate page URLs collapse into one entry, with the final lastmod winning. The parser supports a strict sitemap XML subset, namespaces, XML entities, and CDATA. It rejects DTDs, external entities, malformed documents and HTML responses. Node fetch handles HTTP gzip content encoding; standalone .gz files without that encoding are unsupported. Redirects are rejected. Responses are read into memory before page-cap validation, so the cap is not a byte limit.

Dataset writes precede snapshot writes. An interrupted run can repeat changes on retry; delivery is not transactional or exactly once. Persistent monitoring requires the same underlying key-value store across runs. If the platform assigns a fresh default store each run, arrange reuse of the prior store or copy its snapshots before the next run. Charging configuration, scheduling, publishing and persistent-store orchestration are owner tasks outside this local build. No pricing is configured.

### Local run

Use Node.js 20 or later. Install dependencies with `npm install` when registry access is available. Put input in `storage/key_value_stores/default/INPUT.json`, then run `npm start`. Reuse that storage directory for comparisons. Run `npm test` for the offline test suite; it uses built-in Node modules and injected fetch fixtures and needs no installed SDK.

The repository also retains pre-existing Next.js source and configuration. The root package scripts now target this Actor.

# Actor input Schema

## `sitemaps` (type: `array`):

One or more public sitemap URLs to watch. Each run compares them against the previous snapshot for the same sitemap and emits one record per change.

## `maxUrlsPerSitemap` (type: `integer`):

Maximum URLs accepted from one sitemap; sitemap indexes are traversed one level. A sitemap with more URLs fails safely and keeps its previous snapshot.

## `includeUnchangedSummary` (type: `boolean`):

When true, the run summary includes totals for sitemaps with no changes. Dataset records are emitted for baselines and changes either way.

## Actor input object example

```json
{
  "sitemaps": [
    "https://www.apple.com/sitemap.xml"
  ],
  "maxUrlsPerSitemap": 5000,
  "includeUnchangedSummary": true
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing one record per baseline, added, removed, or lastmod-changed URL

## `keyValueStore` (type: `string`):

Default key-value store holding the LAST_RUN_SUMMARY record

# 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 = {
    "sitemaps": [
        "https://www.apple.com/sitemap.xml"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("your_friendly_developer/sitemap-change-monitor").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 = { "sitemaps": ["https://www.apple.com/sitemap.xml"] }

# Run the Actor and wait for it to finish
run = client.actor("your_friendly_developer/sitemap-change-monitor").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 '{
  "sitemaps": [
    "https://www.apple.com/sitemap.xml"
  ]
}' |
apify call your_friendly_developer/sitemap-change-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,your_friendly_developer/sitemap-change-monitor"
        }
    }
}
```

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/LhSvsgRZVvRepzQ2a/builds/LKyxUvwi7MvTupsLb/openapi.json
