# Page & Document Semantic Diff for AI Agents (`geeky_goth_gamer/page-doc-semantic-diff`) Actor

Compare two versions of a page or document and report only meaningful changes. Ignores timestamps, nonces, cookie banners, nav/footer boilerplate and whitespace. Elevates price, SLA, negation and watched-keyword changes. $0.003 inline or $0.006 per URL.

- **URL**: https://apify.com/geeky_goth_gamer/page-doc-semantic-diff.md
- **Developed by:** [Chris Day](https://apify.com/geeky_goth_gamer) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 diff inlines

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## Page & Document Semantic Diff for AI Agents

Give this Actor two versions of a **page or document** — inline, from public URLs, or mixed (a cached snapshot plus a live URL) — and it reports **only meaningful changes**. Timestamps, nonces, CSRF tokens, UUIDs, cookie banners, nav/footer boilerplate, CSS class hashes and whitespace are stripped first, so a pricing or policy page that merely “refreshed” does not wake the agent.

It does **not** call a language model. Normalisation and diffs are deterministic.

### When an AI agent should use this

Use `geeky_goth_gamer/page-doc-semantic-diff` when:

- You monitor a pricing page, changelog, policy, contract or competitor site and need to know if anything *meaningful* changed.
- You store a canonical snapshot (SHA-256) and want to check a live URL against it.
- You must treat a price, SLA, numeric limit, or a negation (`not` / `no` / `never` / `unless`) as a major change.
- You have JSON/API documents and want exact path-level additions, removals and numeric deltas.

Don't use it for:

- Pixel/layout diffs or screenshots (it compares normalised text and structure, not visual design).
- Private, intranet or metadata URLs (they are rejected).
- Interpreting *why* a change happened; it reports what changed.

**Example input:**

```json
{
  "action": "diff",
  "mode": "semantic",
  "beforeText": "<!doctype html><html><body><nav>Home</nav><main><h1>Pricing</h1><p>Pro is $29/month.</p><p>Updated 2026-11-01T00:00:00Z</p></main><div class=\"cookie-banner\">Accept cookies</div></body></html>",
  "afterText": "<!doctype html><html><body><nav>Home | Blog</nav><main><h1>Pricing</h1><p>Pro is $39/month.</p><p>Updated 2026-11-24T12:00:00Z</p></main><div class=\"cookie-consent\">Accept all</div></body></html>"
}
```

**Output:** One dataset item with `changed`, `changeScore` (0–1), `significance` (`none` | `minor` | `moderate` | `major`), a short `summary`, heading-aware `sectionsAdded` / `sectionsRemoved` / `sectionsModified` (with clause diffs and `numericDeltas` such as `$29 -> $39 (+34.48%)`), optional `structuredChanges`, `keywordHits`, `volatileNoiseIgnored`, snapshots (`sha256`, counts, optional text) and a `tokenSavingsHint`. `changed` is `false` when only volatile noise or boilerplate differed.

**Cost:** $0.003 per inline diff or snapshot; $0.006 per public URL fetched (a two-URL diff charges twice). Invalid input is not billed. Apify also charges the standard $0.00005 Actor-start fee on ordinary runs.

**Call it from an agent:**

- Apify MCP server: add `https://mcp.apify.com/?tools=geeky_goth_gamer/page-doc-semantic-diff` to your MCP client; the tool is `geeky_goth_gamer--page-doc-semantic-diff`. Or use `call-actor` with `"actor": "geeky_goth_gamer/page-doc-semantic-diff"`.
- Standby HTTP: `POST https://geeky-goth-gamer--page-doc-semantic-diff.apify.actor/diff` (also `POST /snapshot`) with `Authorization: Bearer YOUR_TOKEN` and the input JSON. `GET /health` is a liveness check.
- Python: `ApifyClient(token).actor("geeky_goth_gamer/page-doc-semantic-diff").call(run_input=...)`, then read `client.dataset(run["defaultDatasetId"]).list_items().items`.
- HTTP run: `POST https://api.apify.com/v2/acts/geeky_goth_gamer~page-doc-semantic-diff/run-sync-get-dataset-items?token=YOUR_TOKEN` with the input JSON as the body.

### Why this exists

Raw HTML diffs explode on timestamps, cache-busters, cookie banners and chrome, so agents either wake up on every crawl or miss a real price change in the noise. This Actor loads both sides (SSRF-safe), strips boilerplate, normalises volatile tokens, then compares heading-aware sections (or JSON paths, or a strict whitespace-normalised diff) and elevates significance when prices, limits, negations or watched keywords change.

### Input

| Field | Default | Notes |
|---|---|---|
| `action` | `diff` | `diff` or `snapshot`. Standby routes set this for you. |
| `mode` | `semantic` | `semantic`, `structured` (JSON) or `strict`. JSON inputs in semantic mode use a structured path diff automatically. |
| `beforeText` / `afterText` | (one side) | Inline documents. Do not also pass the matching URL. Max 1,000,000 characters. |
| `beforeUrl` / `afterUrl` | (one side) | Public `http(s)` URLs. Mixed `beforeText` + `afterUrl` is supported. |
| `url` / `text` | (snapshot) | Single source for `action: snapshot`. |
| `beforeFormat` / `afterFormat` | `auto` | `html`, `markdown`, `text`, `json`. |
| `watchKeywords` | (empty) | Phrases that elevate significance to `major` when they appear in changed content. |
| `ignorePatterns` | (empty) | Custom regexes, length/count capped, nested quantifiers rejected (ReDoS). |
| `ignoreVolatile` | `true` | Strip ISO timestamps, relative times, UUIDs, hex nonces/hashes, cache-buster query params. |
| `includeSnapshots` | `true` | Include normalised snapshot text (capped). Hashes and counts are always returned. |
| `timeoutSeconds` | 30 | Download time limit. |
| `maxFileSizeMb` | 5 | Download size cap (max 20). |

### Output

The default dataset holds one envelope (`status`, `action`, `mode`, `changed`, `changeScore`, `significance`, `summary`, `billed`).

- **sectionsAdded / sectionsRemoved / sectionsModified** — `heading`, `path`, compact excerpts, `clauseDiffs`, `numericDeltas`.
- **structuredChanges** — `path`, `changeType`, `before`, `after`, `numericDelta` (JSON / structured mode).
- **keywordHits** — watched keywords found in changed content.
- **volatileNoiseIgnored** — counts by category (`timestamps`, `uuids`, `hexTokens`, `relativeTimes`, `boilerplateBlocks`, `customPatterns`, `cacheParams`).
- **beforeSnapshot / afterSnapshot** — `sha256`, `format`, `charCount`, `wordCount`, optional `text`.
- **tokenSavingsHint** — estimated tokens saved versus sending both raw inputs to a language model.

`significance` is `none` when `changed` is false; it is forced to `major` when a price/currency value, numeric limit/SLA, negation, or watched keyword changes.

### Standby / Server mode

When started through Apify's server interface (`APIFY_META_ORIGIN=STANDBY`), the Actor listens on `APIFY_CONTAINER_PORT` / `ACTOR_WEB_SERVER_PORT` (default 8080) and handles:

- `GET /health` — liveness
- `POST /diff` — compare two sources
- `POST /snapshot` — canonical baseline of one source
- Any request carrying the `x-apify-container-server-readiness-probe` header is answered immediately with HTTP 200 and body `ok`

Standby URL: `https://geeky-goth-gamer--page-doc-semantic-diff.apify.actor`

### Pricing

| Event | Price | When it is charged |
|---|---|---|
| `diff-inline` (primary) | **US$0.003** | One successful inline diff or snapshot. |
| `diff-url` | **US$0.006** | One successful URL-fetched document (a two-URL diff charges 2). |
| `apify-actor-start` | US$0.00005 (Apify default) | Once when a standard run starts. |

Failed input (the Actor refused the request) is not billed. Failed fetches are not billed. Your maximum cost per run is respected.

### Safety

URL fetches are SSRF-safe: only `http`/`https` on standard ports, every redirect hop is re-validated, and private, loopback, link-local, CGNAT and cloud-metadata addresses are blocked. Downloads and inline payloads are size- and time-capped. Custom `ignorePatterns` are length-capped and rejected when they look like nested-quantifier ReDoS bombs.

### Limitations

- Visual/CSS-only changes that do not affect extracted text are invisible to this Actor.
- A soft-worded policy change that never touches a number, negation or watched keyword may be classified `minor` or `moderate`.
- Very large tables may be summarised by excerpts; full normalised text is capped in the snapshot field.
- `ignorePatterns` is a regex allow-list with safety limits, not a general-purpose rewrite engine.

# Actor input Schema

## `action` (type: `string`):

"diff" (default) compares before and after. "snapshot" normalises a single url or text into a canonical snapshot and SHA-256 for agents to store as a baseline. Standby routes set this for you.

## `mode` (type: `string`):

"semantic" (default) strips nav/footer/cookie/script boilerplate, normalises volatile noise, and diffs heading-aware sections. "structured" does an exact JSON-path diff (additions, removals, type/value mutations, numeric deltas). "strict" is a whitespace-normalised exact diff with no boilerplate or volatile stripping.

## `beforeText` (type: `string`):

Optional. The earlier version as text/HTML/Markdown/JSON. Do not also pass beforeUrl. Max 1,000,000 characters.

## `afterText` (type: `string`):

Optional. The later version as text/HTML/Markdown/JSON. Do not also pass afterUrl. Max 1,000,000 characters.

## `beforeUrl` (type: `string`):

Optional. Public http(s) URL of the earlier version. Private, loopback and metadata addresses are rejected.

## `afterUrl` (type: `string`):

Optional. Public http(s) URL of the later version. Mix with beforeText to check a live page against a cached snapshot.

## `url` (type: `string`):

Optional, snapshot action. A single public URL to fetch and normalise.

## `text` (type: `string`):

Optional, snapshot action. Inline document to normalise into a baseline.

## `beforeFormat` (type: `string`):

"auto" (default) sniffs HTML, Markdown, JSON or text. Set this when sniffing would be wrong.

## `afterFormat` (type: `string`):

Same as beforeFormat, for the after side.

## `watchKeywords` (type: `array`):

Optional phrases. Matches in added, removed or modified content are returned as keywordHits and elevate significance to major.

## `ignorePatterns` (type: `array`):

Optional regular expressions stripped from both sides before the comparison. Count, length and nested-quantifier (ReDoS) checks are enforced.

## `ignoreVolatile` (type: `boolean`):

When true (default), ISO timestamps, relative times, UUIDs, hex nonces/hashes and cache-buster query parameters are stripped before comparison.

## `includeSnapshots` (type: `boolean`):

When true (default), the result includes normalised beforeSnapshot and afterSnapshot text (capped) plus sha256, wordCount and charCount. Hashes and counts are always returned.

## `timeoutSeconds` (type: `integer`):

Download time limit when a URL is set.

## `maxFileSizeMb` (type: `integer`):

Larger downloads are rejected. Default 5 MB, maximum 20 MB.

## Actor input object example

```json
{
  "action": "diff",
  "mode": "semantic",
  "beforeText": "<!doctype html><html><head><title>Plans</title></head><body><nav>Home</nav><main><h1>Pricing</h1><p>Pro is $29/month.</p><p>Updated 2026-11-01T00:00:00Z</p></main><div class=\"cookie-banner\">Accept cookies</div></body></html>",
  "afterText": "<!doctype html><html><head><title>Plans</title></head><body><nav>Home | Blog</nav><main><h1>Pricing</h1><p>Pro is $39/month.</p><p>Updated 2026-11-24T12:00:00Z</p></main><div class=\"cookie-consent\">Accept all</div></body></html>",
  "beforeFormat": "auto",
  "afterFormat": "auto",
  "ignoreVolatile": true,
  "includeSnapshots": true,
  "timeoutSeconds": 30,
  "maxFileSizeMb": 5
}
```

# 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 = {
    "action": "diff",
    "beforeText": "<!doctype html><html><head><title>Plans</title></head><body><nav>Home</nav><main><h1>Pricing</h1><p>Pro is $29/month.</p><p>Updated 2026-11-01T00:00:00Z</p></main><div class=\"cookie-banner\">Accept cookies</div></body></html>",
    "afterText": "<!doctype html><html><head><title>Plans</title></head><body><nav>Home | Blog</nav><main><h1>Pricing</h1><p>Pro is $39/month.</p><p>Updated 2026-11-24T12:00:00Z</p></main><div class=\"cookie-consent\">Accept all</div></body></html>"
};

// Run the Actor and wait for it to finish
const run = await client.actor("geeky_goth_gamer/page-doc-semantic-diff").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 = {
    "action": "diff",
    "beforeText": "<!doctype html><html><head><title>Plans</title></head><body><nav>Home</nav><main><h1>Pricing</h1><p>Pro is $29/month.</p><p>Updated 2026-11-01T00:00:00Z</p></main><div class=\"cookie-banner\">Accept cookies</div></body></html>",
    "afterText": "<!doctype html><html><head><title>Plans</title></head><body><nav>Home | Blog</nav><main><h1>Pricing</h1><p>Pro is $39/month.</p><p>Updated 2026-11-24T12:00:00Z</p></main><div class=\"cookie-consent\">Accept all</div></body></html>",
}

# Run the Actor and wait for it to finish
run = client.actor("geeky_goth_gamer/page-doc-semantic-diff").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 '{
  "action": "diff",
  "beforeText": "<!doctype html><html><head><title>Plans</title></head><body><nav>Home</nav><main><h1>Pricing</h1><p>Pro is $29/month.</p><p>Updated 2026-11-01T00:00:00Z</p></main><div class=\\"cookie-banner\\">Accept cookies</div></body></html>",
  "afterText": "<!doctype html><html><head><title>Plans</title></head><body><nav>Home | Blog</nav><main><h1>Pricing</h1><p>Pro is $39/month.</p><p>Updated 2026-11-24T12:00:00Z</p></main><div class=\\"cookie-consent\\">Accept all</div></body></html>"
}' |
apify call geeky_goth_gamer/page-doc-semantic-diff --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,geeky_goth_gamer/page-doc-semantic-diff"
        }
    }
}
```

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/XV8ZvXbD3UbuUp6gd/builds/fxJgxuqO42UwnyBcq/openapi.json
