# Website Structured Data Extraction Api (`first_watch/website-structured-data-extraction-api`) Actor

- **URL**: https://apify.com/first\_watch/website-structured-data-extraction-api.md
- **Developed by:** [Jordan Nabbe](https://apify.com/first_watch) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 result returneds

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 Structured Data Extraction API

Extracts and validates structured markup that already exists in HTML **you supply**: JSON-LD, Microdata, RDFa, Open Graph and Twitter Card. It never fetches URLs, runs no browser, executes no scripts and uses no AI, so results are deterministic and every value keeps its source format and location.

### Input

Provide exactly one of: `html`, `text` (treated as HTML), `records` (objects with `html` or `content`, optional `id`), `json` (a record object, or an object with a `records` array), `csv` (header row with an `html` or `content` column, optional `id`), or `base64Documents` (objects with `contentBase64` UTF-8 HTML, optional `id`).

Options: `vocabularies` (array of `jsonld`, `microdata`, `rdfa`, `opengraph`, `twitter`, no duplicates; default all five; unsupported values are rejected by the Actor code), `validationLevel` (`none`, `basic`, `recommended`; default `basic`), `includeRaw` (default true), `deduplicate` (default true), `maxDocumentBytes` (default 2097152, range 1024 to 10485760).

### Output

One dataset row per document with `documentId` (your id or `document-N`), `status` (`ok`, `partial`, `failed`), `entities` (format, type, data, optional raw, source path and UTF-16 start offset), `metadata` (sorted Open Graph and Twitter maps), `warnings`, `duplicates`, `coverage` and `stats`. The `OUTPUT` record holds counts plus the rows (capped at 1000 rows, with `rowsTruncated` set when capped; the dataset always has all rows). `stats.processingMs` is always 0 so output stays reproducible.

### Pricing

Intended pay-per-event model: `document_extracted` at $0.0005 when `validationLevel` is `none`, otherwise `document_validated` at $0.001, one event per non-failed document, with the first 1,000 documents free per customer. Events are only charged when running on the Apify platform, and the prices must be configured in the Apify Console; this repository does not set them. Compute cost estimates are unbenchmarked.

### Limits

Max 10,000 documents and 100 MB total input per run; 1,000 entities per document; 100 keys per object; microdata/RDFa nesting depth 8; JSON-LD depth 32, 20,000 nodes and 1 MB per block; 200,000 elements and nesting 512 per document. Documents are processed sequentially. Validation uses bundled rules for a few common schema.org types only, with no registry lookups. Microdata `itemref` and full RDFa processing (prefix expansion, chaining) are not supported.

### Failure behaviour

The run fails (non-zero exit, nothing stored) on invalid input: zero or multiple modes, unknown keys, out-of-range values, unsupported vocabularies, malformed CSV, unsupported record shapes, or exceeded run limits. Per-document problems (invalid base64, non-UTF-8 bytes, oversized or too complex documents) produce a `failed` row and the batch continues. Malformed JSON-LD gives a `partial` row with machine-readable warnings while other markup is still extracted. Submitted content is never logged; you are responsible for having permission to process it and for the retention of your Apify storages.

# Actor input Schema

## `html` (type: `string`):

One inline HTML document.

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

Inline text interpreted as HTML.

## `records` (type: `array`):

Objects with an html (or content) string and optional id. Maximum 10000.

## `json` (type: `object`):

A record object with html/content, or an object with a records array.

## `csv` (type: `string`):

Inline CSV with a header row and an html or content column (optional id column). Maximum 10000 rows.

## `base64Documents` (type: `array`):

Objects with contentBase64 (UTF-8 HTML) and optional id. Maximum 10000.

## `vocabularies` (type: `array`):

Markup formats to extract: any of jsonld, microdata, rdfa, opengraph, twitter (no duplicates).

## `validationLevel` (type: `string`):

none, basic (type/context checks) or recommended (adds bundled property rules).

## `includeRaw` (type: `boolean`):

Include raw source representation of each entity.

## `deduplicate` (type: `boolean`):

Report duplicate entities within each document.

## `maxDocumentBytes` (type: `integer`):

Documents larger than this fail individually.

## Actor input object example

```json
{
  "html": "<html><head><meta property=\"og:title\" content=\"Widget\"><meta name=\"twitter:card\" content=\"summary\"><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"Product\",\"name\":\"Widget\"}</script></head></html>",
  "vocabularies": [
    "jsonld",
    "opengraph",
    "twitter"
  ],
  "validationLevel": "basic",
  "includeRaw": true,
  "deduplicate": true,
  "maxDocumentBytes": 2097152
}
```

# Actor output Schema

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

Every result row stored in the default dataset.

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

Summary written to the OUTPUT 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 = {
    "html": "<html><head><meta property=\"og:title\" content=\"Widget\"><meta name=\"twitter:card\" content=\"summary\"><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"Product\",\"name\":\"Widget\"}</script></head></html>",
    "vocabularies": [
        "jsonld",
        "opengraph",
        "twitter"
    ],
    "validationLevel": "basic"
};

// Run the Actor and wait for it to finish
const run = await client.actor("first_watch/website-structured-data-extraction-api").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 = {
    "html": "<html><head><meta property=\"og:title\" content=\"Widget\"><meta name=\"twitter:card\" content=\"summary\"><script type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"Product\",\"name\":\"Widget\"}</script></head></html>",
    "vocabularies": [
        "jsonld",
        "opengraph",
        "twitter",
    ],
    "validationLevel": "basic",
}

# Run the Actor and wait for it to finish
run = client.actor("first_watch/website-structured-data-extraction-api").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 '{
  "html": "<html><head><meta property=\\"og:title\\" content=\\"Widget\\"><meta name=\\"twitter:card\\" content=\\"summary\\"><script type=\\"application/ld+json\\">{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Product\\",\\"name\\":\\"Widget\\"}</script></head></html>",
  "vocabularies": [
    "jsonld",
    "opengraph",
    "twitter"
  ],
  "validationLevel": "basic"
}' |
apify call first_watch/website-structured-data-extraction-api --silent --output-dataset

```

## MCP server setup

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

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/TKcBwGijer2d0LpCT/builds/vfGgALU7CEpTyzQHg/openapi.json
