# URL → Structured Metadata (`microautomationlab/url-structured-metadata`) Actor

Extract structured metadata from any public web page URL, including title, description, canonical URL, robots, language, Open Graph fields, JSON-LD types, HTTP status, and final URL.

- **URL**: https://apify.com/microautomationlab/url-structured-metadata.md
- **Developed by:** [microautomation lab](https://apify.com/microautomationlab) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 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/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

## URL → Structured Metadata

Extract structured metadata from one public web page URL. Each successful run writes one record to the Default Dataset.

Actor: `microautomationlab/url-structured-metadata`

### What it extracts

| Field | Source or meaning |
| --- | --- |
| `url` | Original input URL. |
| `title` | Text of the HTML `<title>` element. |
| `description` | Content of `meta name="description"`. |
| `canonical` | `href` of a `link` element whose `rel` includes `canonical`. |
| `robots` | Content of `meta name="robots"`. |
| `language` | The `<html>` element's `lang` attribute. |
| `ogTitle` | Content of `meta property="og:title"`. |
| `ogDescription` | Content of `meta property="og:description"`. |
| `ogImage` | Content of `meta property="og:image"`. |
| `jsonLdTypes` | Unique `@type` strings from valid JSON-LD blocks. |
| `httpStatus` | HTTP status code of the final response. |
| `finalUrl` | Response URL after following HTTP redirects. |

Metadata strings are trimmed. Missing or empty metadata values are `null`; when no JSON-LD types are found, `jsonLdTypes` is `[]`.

For title, meta, and canonical elements, the first matching element is used. Relative references in `canonical` and `ogImage` are returned as found, without conversion to absolute URLs. Missing values are not inferred from other tags.

JSON-LD types are collected from objects, arrays, `@graph`, and nested objects, with duplicates removed in discovery order. Malformed JSON-LD blocks are skipped without discarding other metadata. This discovers type names; it does not validate structured data.

### Input

Provide one absolute HTTP or HTTPS URL in the required `url` field:

```json
{
  "url": "https://example.com/"
}
```

**1 run = 1 URL.** URL lists are not supported. URLs containing a username or password are rejected. Use a publicly accessible page that does not require authentication.

### Output

A successful run saves one record to the Default Dataset and prints the same record to standard output. The Actor output's `results` link points to the dataset items.

Example record from an existing local run for `https://example.com/` (page content can change):

```json
{
  "url": "https://example.com/",
  "title": "Example Domain",
  "description": null,
  "canonical": null,
  "robots": null,
  "language": "en",
  "ogTitle": null,
  "ogDescription": null,
  "ogImage": null,
  "jsonLdTypes": [],
  "httpStatus": 200,
  "finalUrl": "https://example.com/"
}
```

### Typical use cases

- Metadata inspection for a specific page.
- Open Graph metadata checks.
- Canonical and robots meta tag inspection.
- Structured data type discovery through JSON-LD `@type` values.
- Lightweight automation workflows that consume a single metadata record.

### Limitations

- One URL per run.
- Not a crawler; does not follow site links. HTTP redirects are followed.
- Does not perform SEO scoring or provide recommendations.
- Does not use AI or an LLM.
- Does not execute JavaScript. JavaScript-rendered metadata that is not present in the fetched HTML may not be available.
- Intended for publicly accessible HTTP/HTTPS pages.
- Accepts responses with `Content-Type: text/html` or `application/xhtml+xml` only.
- HTTP fetching has a 15-second timeout, including redirects and reading the response body.

### Error behavior

The following input and fetch errors end the run with exit code `1`. They occur before the dataset write, so no result or error record is saved to the Dataset for these failures.

| Error code | Condition |
| --- | --- |
| `INVALID_URL` | Missing or invalid input URL, a non-HTTP(S) URL, or a URL containing a username or password. |
| `HTTP_ERROR` | A non-2xx HTTP response, such as 404 or 500. |
| `NETWORK_ERROR` | Fetch failure, such as a DNS, connection, or TLS error. |
| `TIMEOUT` | The HTTP fetch exceeds 15 seconds, including redirects and body reading. |
| `NON_HTML` | The response Content-Type is missing or is neither HTML nor XHTML. |

These errors are printed to standard error as JSON. `HTTP_ERROR` and `NON_HTML` also include `httpStatus`. For example:

```json
{
  "error": {
    "code": "HTTP_ERROR",
    "message": "HTTP 404",
    "httpStatus": 404
  }
}
```

Missing metadata and malformed JSON-LD alone do not fail a run; the output rules above apply.

### Pricing

Pay per event:

- Result: **$0.50 / 1,000 results**.
- Actor start: **$0.00005**.

Platform usage costs are not charged to the user separately.

### Privacy / data handling

The Actor reads its input through the Apify SDK and requests the supplied URL, following HTTP redirects. It reads the response HTML to extract the fields listed above.

On success, the code sends the complete metadata record, including the input URL and final URL, to the Default Dataset and prints it to standard output. The listed input and fetch errors are printed to standard error. URLs, including any query strings, can therefore appear in the saved result and successful-run log output.

### Local development

Requires Node.js 22 or later and the Apify CLI.

```sh
npm install
npm test
npm run typecheck
npm run build
apify run --no-purge --input-file input.json
```

On Windows, use `npm.cmd` and `apify.cmd` if PowerShell's execution policy prevents running the `.ps1` commands. Local dataset records are stored in `storage/datasets/default/`. With `--no-purge`, successful runs append to the existing local dataset.

# Actor input Schema

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

取得するHTTPまたはHTTPSのURLを1件指定してください。

## Actor input object example

```json
{
  "url": "https://example.com/"
}
```

# Actor output Schema

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

Default Dataset containing one metadata record for the input URL after a successful run. Missing metadata is null; missing JSON-LD types are an empty array.

# 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://example.com/"
};

// Run the Actor and wait for it to finish
const run = await client.actor("microautomationlab/url-structured-metadata").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://example.com/" }

# Run the Actor and wait for it to finish
run = client.actor("microautomationlab/url-structured-metadata").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://example.com/"
}' |
apify call microautomationlab/url-structured-metadata --silent --output-dataset

```

## MCP server setup

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

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/yHTe9hZcztr7zgVF9/builds/GexPxjlOWT4Uq3WdN/openapi.json
