# Structured Data Extractor — JSON-LD, Open Graph & Meta Tags (`nuhemugames/structured-data-extractor`) Actor

Extract every machine-readable block from web pages: JSON-LD (schema.org) with detected types, Open Graph, Twitter Card, standard meta tags, canonical URL, hreflang and favicons. One clean JSON item per URL. Fetches only the URLs you provide - no crawling. No credentials needed.

- **URL**: https://apify.com/nuhemugames/structured-data-extractor.md
- **Developed by:** [kuon](https://apify.com/nuhemugames) (community)
- **Categories:** SEO tools, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 results

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 Extractor — JSON-LD, Open Graph & Meta Tags

Extract every machine-readable block from any web page in one pass: **JSON-LD
(schema.org) with all detected types**, Open Graph, Twitter Card, standard
meta tags, canonical URL, hreflang alternates and favicons — one clean JSON
item per URL. **Fetches only the URLs you provide, never crawls.** No
credentials or API keys needed.

### What it does

Give it a list of page URLs. For each page you get one dataset item with:

- `jsonLd[]` — every `application/ld+json` block, parsed, in page order
  (broken blocks are counted in `jsonLdErrors`, never crash the run)
- `jsonLdTypes[]` — deduplicated schema.org `@type` values found anywhere in
  the JSON-LD, including inside `@graph` and nested entities
  (e.g. `["Article", "Person", "BreadcrumbList"]`)
- `openGraph` — `og:*` tags without the prefix; repeated keys (multiple
  `og:image`) become arrays
- `twitterCard` — `twitter:*` tags without the prefix
- `meta` — title, description, robots, author, generator, keywords, language, charset
- `canonical` — resolved to an absolute URL
- `hreflang[]` — language alternates as `{lang, url}` (absolute)
- `icons[]` — favicon / apple-touch-icon links with sizes
- `stats` — block and tag counts

Failed downloads (404s, non-HTML responses, oversized pages) produce an item
with `status: "failed"` and a clear `error`, so batch jobs always finish.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `urls` | array | — | Page URLs (only these are fetched; no crawling) |
| `timeoutSecs` | integer | `20` | Download timeout per page |
| `maxFileSizeMb` | integer | `5` | Larger pages are skipped with a failed item |

### Example output (abridged)

```json
{
    "url": "https://example.com/article",
    "status": "success",
    "pageTitle": "Fruit Report — the Quarterly Edition",
    "meta": {"description": "A quarterly report about fruit.", "language": "en-GB"},
    "canonical": "https://example.com/reports/fruit-quarterly",
    "jsonLd": [{"@context": "https://schema.org", "@type": "Article", "headline": "Fruit Report"}],
    "jsonLdTypes": ["Article", "Person"],
    "jsonLdErrors": 0,
    "openGraph": {"title": "Fruit Report", "type": "article", "image": ["https://example.com/img/a.jpg", "https://example.com/img/b.jpg"]},
    "twitterCard": {"card": "summary_large_image", "title": "Fruit Report (Twitter)"},
    "hreflang": [{"lang": "ja", "url": "https://example.com/ja/fruit"}],
    "icons": [{"rel": "icon", "href": "https://example.com/favicon.ico", "sizes": "32x32"}],
    "stats": {"jsonLdBlocks": 1, "ogTags": 4, "twitterTags": 2}
}
```

### Typical uses

- SEO audits at scale: which pages have schema markup, which types, where it's broken
- Verify social previews (Open Graph / Twitter Card) across a URL list before campaigns
- Harvest schema.org entities (Product, Article, Recipe, Event…) as clean JSON for pipelines
- Check canonical/hreflang consistency after site migrations

### Limitations

- Static HTML only: markup injected by client-side JavaScript is not seen
- Microdata (`itemscope`/`itemprop`) and RDFa are not parsed — JSON-LD is the
  dominant modern format and the one search engines recommend
- Fetches the exact URLs given; pair it with a sitemap extractor for URL discovery

### Development (local)

```bash
cd actors/structured-data-extractor
uv venv --python 3.13 .venv && uv pip install -p .venv/bin/python -r requirements.txt

.venv/bin/python tests/run_local_test.py           # end-to-end test (apify run equivalent), exit 0 = ALL PASS
../../node_modules/.bin/apify run                  # real apify CLI local run (input: storage/key_value_stores/default/INPUT.json)
```

Fixtures live in `tests/fixtures/` (full/broken-jsonld/minimal/not-html);
expected results in `tests/expected_output.json`. Publishing → `../../docs/publishing.md`.

# Actor input Schema

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

URLs of the pages to extract structured data from (one per line). Duplicates are removed. Only these exact URLs are fetched - no crawling.

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

Timeout for downloading each page.

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

Pages larger than this are skipped with a failed item.

## Actor input object example

```json
{
  "urls": [
    "https://apify.com",
    "https://github.blog"
  ],
  "timeoutSecs": 20,
  "maxFileSizeMb": 5
}
```

# Actor output Schema

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

All dataset items (one per URL): jsonLd, jsonLdTypes, openGraph, twitterCard, meta, canonical, hreflang, icons.

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

// Run the Actor and wait for it to finish
const run = await client.actor("nuhemugames/structured-data-extractor").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://apify.com",
        "https://github.blog",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("nuhemugames/structured-data-extractor").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://apify.com",
    "https://github.blog"
  ]
}' |
apify call nuhemugames/structured-data-extractor --silent --output-dataset

```

## MCP server setup

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

```

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/dnHHNZaIRkmYUtcVD/builds/ruQSb6U6AYhRNg2uX/openapi.json
