# 🏷️ Structured Data Generator & Validator - Win Rich Results (`that_red_bird/structured-data-generator`) Actor

⚡ Detects the right schema.org type from page content, GENERATES clean JSON-LD, and VALIDATES existing markup against Google's rich-result requirements. ✅ 11 types, required-vs-recommended scoring, site-wide audit via sitemap.

- **URL**: https://apify.com/that\_red\_bird/structured-data-generator.md
- **Developed by:** [mohamed alaya](https://apify.com/that_red_bird) (community)
- **Categories:** SEO tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Structured Data Generator & Validator

Detect the right schema.org type for any page, generate clean **JSON-LD**, and check whatever
structured data the page already has against **Google's rich-result requirements** — the kind of
work an SEO agency bills for per page.

### What it does

**Detect** — scores every candidate type from real signals on the page: existing JSON-LD, microdata
`itemtype` attributes, Open Graph `og:type`, and content heuristics (price/add-to-cart language,
question-style headings, "Step N" headings, ingredients lists, breadcrumb navs, salary ranges, embedded
video, and more). If nothing on the page suggests a type, it reports **"no type detected"** rather
than guessing — a wrong schema type is worse than none.

**Generate** — builds a clean, parseable JSON-LD object for the detected (or forced) type, pulling
values from existing JSON-LD first, then microdata, then Open Graph/meta tags, then visible-DOM
heuristics (headings, lists, `<address>`, prices). Reports exactly which properties it filled and
which it could not find.

**Validate** — checks the page's existing markup (or the generated JSON-LD, if there is none) against
an embedded **REQUIRED vs RECOMMENDED** property list per type, modeled on Google's Search Central
guidelines. Missing a required property is an **error**; missing a recommended one is a **warning** —
they are never conflated. Each page gets a 0-100 rich-result-readiness score (required properties
weighted higher than recommended), and a site-wide audit reports the average.

### Supported types

Product, Article/BlogPosting, LocalBusiness, Organization, FAQPage, HowTo, Recipe, Event,
BreadcrumbList, JobPosting, VideoObject.

### Input

```json
{
  "url": "https://shop.example.com/products/widget",
  "mode": "both"
}
```

or, for a full-site audit:

```json
{ "siteUrl": "https://shop.example.com", "maxPages": 100, "mode": "validate" }
```

### Output

One `page` row per page (detected type, confidence, signals, generated JSON-LD, filled/missing
properties, errors, warnings, score) and one `result` summary row (site-wide average score, type
distribution, total errors/warnings). Files are also written to the dataset for direct inspection.

### Honest limits

The embedded REQUIRED/RECOMMENDED ruleset is a **snapshot** (see `RULESET_DATE` in the output) —
Google changes its structured-data guidelines periodically, and this actor's validation reflects the
ruleset as embedded at that date, not a live fetch of Google's current documentation. Content-signal
detection is heuristic: unusual page layouts (heavy client-side rendering, non-English question
phrasing, custom component names) can under- or over-score a type. Generated JSON-LD is a best-effort
draft meant to be reviewed before publishing, not a guaranteed-passing submission to Google's Rich
Results Test.

# Actor input Schema

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

A single page to analyse, e.g. https://shop.example.com/products/widget. Leave empty and set siteUrl instead for a multi-page audit.

## `siteUrl` (type: `string`):

A site to crawl via its sitemap and audit many pages at once. Used instead of, or in addition to, url.

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

generate = only produce JSON-LD · validate = only check existing/generated markup against Google's rules · both = do both.

## `overrideType` (type: `string`):

Skip auto-detection and force this schema.org type for every page. Leave as auto to let the actor infer the type from page content.

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

Upper bound on pages to audit when siteUrl is used.

## `useSitemap` (type: `boolean`):

Discover pages from the site's sitemap (including sitemap indexes) when siteUrl is set. Falls back to just auditing siteUrl itself if no sitemap is found.

## `includePatterns` (type: `array`):

Keep only sitemap URLs containing one of these substrings, e.g. /products/, /blog/.

## `excludePatterns` (type: `array`):

Drop sitemap URLs containing any of these, e.g. /tag/, ?page=.

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

How many pages to fetch and audit in parallel.

## `proxyConfiguration` (type: `object`):

Optional Apify proxy configuration.

## Actor input object example

```json
{
  "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
  "mode": "both",
  "overrideType": "auto",
  "maxPages": 20,
  "useSitemap": true,
  "concurrency": 5
}
```

# Actor output Schema

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

No description

## `downloadCsv` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `count` (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 = {
    "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
};

// Run the Actor and wait for it to finish
const run = await client.actor("that_red_bird/structured-data-generator").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 = { "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html" }

# Run the Actor and wait for it to finish
run = client.actor("that_red_bird/structured-data-generator").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 '{
  "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
}' |
apify call that_red_bird/structured-data-generator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,that_red_bird/structured-data-generator"
        }
    }
}

```

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/DVuGIDOGhaEGYBtSE/builds/fEfjiaiP8ZmHHgV5Z/openapi.json
