# Schema.org JSON-LD & Semantic Web Distiller for AI Agents (`scrapesmart/schemaorg-semantic-distiller`) Actor

Deterministic Schema.org JSON-LD, Microdata & OpenGraph distiller for AI agents. Extracts structured products, orgs, jobs, and articles with 95%+ token compression.

- **URL**: https://apify.com/scrapesmart/schemaorg-semantic-distiller.md
- **Developed by:** [Dysen K](https://apify.com/scrapesmart) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $8.00 / 1,000 webpage distilled into structured schema.org json-ld, microdata, opengraph & mcp briefs

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

## 🌐 Universal Schema.org JSON-LD & Semantic Web Distiller for AI Agents (MCP)

> **Deterministic 95%+ LLM token reduction engine. Distills Google-validated W3C Schema.org JSON-LD, HTML5 Microdata, and OpenGraph metadata from any webpage into structured facts and token-optimized MCP briefs (<400 tokens).**

[![Apify Actor](https://img.shields.io/badge/Apify-Actor-orange?logo=apify)](https://apify.com)
[![Standard](https://img.shields.io/badge/Standard-W3C%20Schema.org%20%7C%20JSON--LD%20%7C%20OpenGraph-blue)](#semantic-standards)
[![Token Reduction](https://img.shields.io/badge/Token%20Reduction-95%25%20to%2099%25-brightgreen)](#token-savings-breakdown)
[![MCP Ready](https://img.shields.io/badge/MCP-Ready%20\(<400%20tokens\)-purple)](#ai-agent-integration-cursor-claude-windsurf)
[![License](https://img.shields.io/badge/License-Apache%202.0-lightgrey)](LICENSE)

***

### ⚡ The Problem: Raw Web Scraping Destroys LLM Context

When AI agents (Claude 3.7 / 3.5 Sonnet, Cursor, OpenAI GPT-4o, Windsurf, Copilot, DeepSeek) need information from external websites, general scrapers dump **30,000 to 80,000 tokens of raw HTML, hydration scripts, marketing tracking pixels, and CSS styles** directly into the context window.

This leads to:

1. 💸 **Massive Cost Inflation**: Burning $0.15 to $0.50 per page in input tokens.
2. ⏳ **High Latency**: Ingesting 200KB of DOM trees slows agent response times by 5–15 seconds.
3. 📉 **Attention Drift & Hallucination**: LLMs lose needle-in-a-haystack focus when reading minified JavaScript bundles and SVG icons instead of facts.
4. 🛑 **Context Overflow**: Multi-page research tasks quickly hit context limits.

***

### 🚀 The Solution: 100% Deterministic Semantic Distillation

Over **60% of modern web pages** (e-commerce storefronts, SaaS homepages, tech documentation, blogs, job boards, real estate listings) already embed **Google-validated, machine-readable structured metadata** directly inside their initial HTML payload via:

- **W3C Schema.org JSON-LD** (`<script type="application/ld+json">`)
- **HTML5 Microdata** (`[itemscope]`, `[itemprop]`)
- **OpenGraph Tags** (`og:title`, `og:description`, `og:price:amount`, etc.)
- **Twitter Cards** (`twitter:card`, `twitter:title`, etc.)

**Schema.org Semantic Distiller** deterministically extracts and normalizes these semantic structures into pure, clean facts, cutting LLM token usage by **95% to 99%** with **zero LLM cost and zero hallucination risk**.

```
[ Raw Webpage HTML (45,000 Tokens) ]
                 │
                 ▼  Fast Deterministic Extraction (JSON-LD + Microdata + OpenGraph)
[ Canonical Normalized Entity + MCP Markdown Brief (180 Tokens) ]
                 │
                 ▼  99.6% Token Reduction Saved!
```

***

### 🌟 Key Architecture & Capabilities

#### 1. Robust JSON-LD Extraction & Graph Flattening

- Handles **nested `@graph` arrays** (common in WordPress, Yoast, Shopify, and modern enterprise schemas).
- Handles top-level arrays, embedded entity nodes (`mainEntity`, `offers`, `author`, `publisher`).
- Self-healing parser for malformed JSON-LD (strips CDATA blocks, decodes HTML entities like `&quot;`, cleans trailing commas).

#### 2. Microdata & OpenGraph Fallback

- If JSON-LD is absent or partial, automatically extracts HTML5 `[itemscope]` / `[itemprop]` Microdata attributes (`content`, `href`, `src`, `datetime`).
- Fallback to canonical OpenGraph (`og:*`) and Twitter Card metadata.

#### 3. Canonical Entity Normalization

Automatically normalizes complex schemas into standardized objects:

- **Product**: `name`, `brand`, `sku`, `gtin` (barcode), `price`, `currency`, `availability` (`InStock`/`OutOfStock`), `ratingValue`, `reviewCount`, `description`.
- **Organization**: `name`, `legalName`, `url`, `logo`, `sameAs` (social/GitHub links), `telephone`, `email`, `address`.
- **Software / SaaS**: `name`, `applicationCategory`, `operatingSystem`, `softwareVersion`, `pricing`, `ratingValue`, `description`.
- **Article / News**: `headline`, `author`, `datePublished`, `dateModified`, `publisher`, `description`.
- **Job Posting**: `title`, `hiringOrganization`, `jobLocation`, `employmentType`, `baseSalary`, `datePosted`.
- **Event**: `name`, `startDate`, `endDate`, `location`, `organizer`, `price`, `currency`.

#### 4. Real-Time Token Savings Metrics

Computes exact LLM token efficiency for every URL:

- `rawHtmlTokensEst`: Estimated tokens in raw HTML response (`ceil(chars / 4)`).
- `distilledBriefTokensEst`: Estimated tokens in distilled brief (`<400 tokens`).
- `tokensSaved`: Net context tokens saved.
- `compressionPercentage`: Context reduction percentage (typically **94%–99%**).

***

### 🤖 AI Agent Integration (Cursor, Claude, Windsurf, Cline)

#### Option 1: Direct Context Injection via `MCP_PROMPT`

This Actor saves a combined, zero-noise Markdown prompt in the Apify Key-Value Store under the key `MCP_PROMPT`. You can feed this directly into your system prompt:

```markdown
#### 🌐 [Linear App](https://linear.app)
- **Domain**: `linear.app` | **HTTP**: `200` | **Entities**: `Organization, SoftwareApplication`
- **Context Compression**: ⚡ **98.4% saved** (Raw: ~18,500 tokens → Distilled: ~210 tokens)

##### 💻 Software / SaaS: Linear App
- **Category**: `ProjectManagementApplication` | **OS**: `Web, macOS, iOS, Android` | **Pricing**: `0 USD`
- **Rating**: ⭐ **4.95/5.0** (1200 reviews)
- **Description**: The issue tracking tool you will actually enjoy using. Streamline projects, sprints, and tasks.

##### 🏢 Organization: Linear Orbit, Inc.
- **Location**: San Francisco, CA
- **Profiles**: [twitter.com/linear](https://twitter.com/linear) · [github.com/linear](https://github.com/linear)
```

#### Option 2: Model Context Protocol (MCP) Tool

Connect your AI Agent through the Apify MCP server. The agent passes target URLs and receives structured facts instantly:

```json
{
  "name": "distill_webpage_semantics",
  "arguments": {
    "urls": ["https://stripe.com", "https://linear.app"]
  }
}
```

***

### ⚙️ Input Parameters

| Parameter | Type | Default | Description |
|---|---|---|---|
| `urls` | `Array<string>` | `["https://stripe.com", ...]` | **Required.** List of web page URLs to fetch, parse, and semantically distill. |
| `includeRawJsonLd` | `boolean` | `true` | Include complete unflattened raw JSON-LD blocks in dataset items. |
| `includeMicrodata` | `boolean` | `true` | Extract HTML5 Microdata (`itemscope`/`itemprop`) as fallback. |
| `includeOpenGraph` | `boolean` | `true` | Extract OpenGraph (`og:*`) and Twitter Card metadata tags. |
| `concurrency` | `integer` | `5` | Concurrent fetch workers (range: 1 to 20). |
| `timeoutSecs` | `integer` | `15` | Per-request timeout in seconds (range: 3 to 60). |
| `customHeaders` | `object` | `{}` | Optional custom headers (e.g. `Cookie`, `Authorization`). |

***

### 📊 Dataset Output Schema

Each item pushed to the default dataset contains:

```json
{
  "url": "https://store.example.com/products/k8-keyboard",
  "httpStatus": 200,
  "title": "Ergonomic Mechanical Keyboard | Keychron",
  "description": "Wireless custom mechanical keyboard with hot-swappable switches.",
  "canonicalUrl": "https://store.example.com/products/k8-keyboard",
  "domain": "store.example.com",
  "detectedEntityTypes": ["Product", "Offer", "Organization", "AggregateRating"],
  "normalizedProduct": {
    "name": "Ergonomic Mechanical Keyboard",
    "brand": "Keychron",
    "sku": "K8-PRO-RGB",
    "gtin": "0850012345678",
    "price": 119.99,
    "currency": "USD",
    "availability": "InStock",
    "ratingValue": 4.8,
    "reviewCount": 320,
    "description": "Wireless custom mechanical keyboard with hot-swappable switches."
  },
  "normalizedOrganization": {
    "name": "Keychron",
    "url": "https://store.example.com",
    "sameAs": ["https://twitter.com/keychron", "https://instagram.com/keychron"]
  },
  "openGraph": {
    "title": "Ergonomic Mechanical Keyboard",
    "type": "product",
    "image": "https://store.example.com/images/k8.jpg"
  },
  "tokenSavingsStats": {
    "rawHtmlBytes": 142850,
    "rawHtmlTokensEst": 35712,
    "distilledBriefTokensEst": 245,
    "tokensSaved": 35467,
    "compressionPercentage": 99.3
  },
  "compressionPercentage": 99.3,
  "mcpMarkdownBrief": "### 🌐 [Ergonomic Mechanical Keyboard](https://store.example.com/products/k8-keyboard)...",
  "crawledAt": "2026-11-06T15:20:00.000Z"
}
```

***

### 💰 Pay-Per-Event (PPE) Pricing

This Actor utilizes transparent **Pay-Per-Event (PPE)** pricing:

- Charged **only per successfully distilled URL** (`url-semantically-distilled`).
- Failed or unreachable URLs are **never charged**.
- 100% deterministic execution with zero LLM API costs.

***

### 📜 License

Apache-2.0 License. Built with ❤️ for the AI Agent & Semantic Web developer community.

# Actor input Schema

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

List of URLs to fetch, extract Schema.org JSON-LD, Microdata, and OpenGraph metadata from, and distill for LLM consumption.

## `includeRawJsonLd` (type: `boolean`):

Include full, unflattened raw JSON-LD blocks in dataset items.

## `includeMicrodata` (type: `boolean`):

Extract HTML5 Microdata markup when available as structured fallback.

## `includeOpenGraph` (type: `boolean`):

Extract OpenGraph (og:\*) and Twitter Card metadata tags.

## `concurrency` (type: `integer`):

Maximum number of URLs to process concurrently.

## `timeoutSecs` (type: `integer`):

Maximum duration in seconds to wait for each webpage response.

## `customHeaders` (type: `object`):

Optional custom HTTP headers to pass when fetching target URLs.

## Actor input object example

```json
{
  "urls": [
    "https://stripe.com",
    "https://linear.app",
    "https://github.com"
  ],
  "includeRawJsonLd": true,
  "includeMicrodata": true,
  "includeOpenGraph": true,
  "concurrency": 5,
  "timeoutSecs": 15,
  "customHeaders": {}
}
```

# Actor output Schema

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

JSON/table dataset containing all enriched records and per-record mcpMarkdownBrief fields.

## `mcpPrompt` (type: `string`):

Token-optimized Markdown brief stored in the default Key-Value Store for direct LLM/MCP consumption.

# 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://stripe.com",
        "https://linear.app",
        "https://github.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapesmart/schemaorg-semantic-distiller").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://stripe.com",
        "https://linear.app",
        "https://github.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("scrapesmart/schemaorg-semantic-distiller").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://stripe.com",
    "https://linear.app",
    "https://github.com"
  ]
}' |
apify call scrapesmart/schemaorg-semantic-distiller --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scrapesmart/schemaorg-semantic-distiller"
        }
    }
}
```

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/IyerXq6vDm79RWAF5/builds/oM2E0RnXJnmzy0Nlq/openapi.json
