# Wikipedia structured data with chunks (`apily/wikipedia-structured-data-with-chunks`) Actor

Extract structured data from any Wikipedia page: full text, infobox,tables, images, references, categories, links, Wikidata QID, and revision metadata. Async, cached, and ready for bulk pipelines.

- **URL**: https://apify.com/apily/wikipedia-structured-data-with-chunks.md
- **Developed by:** [Mohit Soni](https://apify.com/apily) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $5.00 / 1,000 item extracteds

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?

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

## Wikipedia Structured Data Extractor

Bulk-scrape Wikipedia pages into clean JSON. For each title you provide, the Actor pushes one dataset item containing:

- `title`, `qid` (Wikidata QID), `type` (entity type), `revId`, `wikitext`
- `content` — page summary + extract
- `links.internal_links` (with resolved QIDs and entity types) and `links.external_links`
- `tables` — parsed rows/headers of every table on the page
- `images` — thumbnails + full metadata
- `references` — bibliography / citation blocks
- `categories` — category list
- `infobox` — parsed key/value pairs from the right-side infobox
- `chunks` — content split into chunks suitable for RAG / embeddings
- `metadata` and `extraction_metadata`

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `pageTitles` | array of strings | — (required) | English-Wikipedia page titles. |
| `maxConcurrentRequests` | int | 10 | 1–25. |
| `requestTimeoutSeconds` | int | 30 | Per HTTP request. |
| `maxRetries` | int | 5 | Retries on 429 / 5xx with exponential backoff. |
| `enableCaching` | bool | true | In-container cache for the duration of the run. |
| `logLevel` | enum | INFO | DEBUG / INFO / WARNING / ERROR. |
| `userAgentContact` | string | actor-owner@example.com | Wikimedia requires a real contact. Only sent in the HTTP `User-Agent` header. |

Example:

```json
{
  "pageTitles": ["Albert Einstein", "Marie Curie", "Alan Turing"],
  "maxConcurrentRequests": 10,
  "enableCaching": true
}
```

### Output

One JSON object per input title is pushed to the default dataset. Failed pages are still written, but with `{"title": ..., "error": ..., "error_type": ...}` instead of the full payload — so you can see failures in the same table.

Export as JSON, CSV, Excel, or feed via the Apify API.

### Notes

- The Actor talks only to `en.wikipedia.org` and `www.wikidata.org`. No credentials required.
- Please set `userAgentContact` to a valid contact string per the [Wikimedia User-Agent policy](https://meta.wikimedia.org/wiki/User-Agent_policy). Runs with the default placeholder may be rate-limited by Wikimedia.
- Table extraction returns lists of rows/headers (no pandas dependency in the image).

# Actor input Schema

## `pageTitles` (type: `array`):

One Wikipedia page title per line (English Wikipedia). Example: 'Albert Einstein', 'Marie Curie'.

## `maxConcurrentRequests` (type: `integer`):

Concurrent in-flight HTTP requests to Wikipedia/Wikidata. Increase for speed, decrease if you hit rate limits.

## `requestTimeoutSeconds` (type: `integer`):

Per-request HTTP timeout.

## `maxRetries` (type: `integer`):

Retries on 429/5xx responses using exponential backoff.

## `enableCaching` (type: `boolean`):

Cache Wikipedia/Wikidata responses to disk within a single Actor run. Speeds up bulk runs with overlapping links.

## `logLevel` (type: `string`):

Verbosity of Actor logs.

## `userAgentContact` (type: `string`):

Wikimedia's User-Agent policy requires a real contact string. Emails are only sent to Wikimedia in the HTTP header (never stored by Apify).

## Actor input object example

```json
{
  "pageTitles": [
    "Albert Einstein"
  ],
  "maxConcurrentRequests": 10,
  "requestTimeoutSeconds": 30,
  "maxRetries": 5,
  "enableCaching": true,
  "logLevel": "INFO",
  "userAgentContact": "actor-owner@example.com"
}
```

# Actor output Schema

## `datasetItems` (type: `string`):

Structured records for every requested Wikipedia title.

# 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 = {
    "pageTitles": [
        "Albert Einstein"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("apily/wikipedia-structured-data-with-chunks").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 = { "pageTitles": ["Albert Einstein"] }

# Run the Actor and wait for it to finish
run = client.actor("apily/wikipedia-structured-data-with-chunks").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 '{
  "pageTitles": [
    "Albert Einstein"
  ]
}' |
apify call apily/wikipedia-structured-data-with-chunks --silent --output-dataset

```

## MCP server setup

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

```

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/l44Cy6NZaiy9Z7kfX/builds/sPeZzMza3890sQSao/openapi.json
