# Wikipedia & Wikidata Knowledge Scraper | 2Space (`2space/wikipedia-wikidata-scraper`) Actor

Fast Wikipedia and Wikidata scraper across 300+ languages. Scrapes full clean Markdown articles, summaries, Wikidata Q-IDs, structured entity properties, categories, and outbound references.

- **URL**: https://apify.com/2space/wikipedia-wikidata-scraper.md
- **Developed by:** [2Space Group](https://apify.com/2space) (community)
- **Categories:** AI, MCP servers, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.40 / 1,000 wikipedia articles scraped

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/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

## Wikipedia & Wikidata Knowledge Scraper | 2Space

> **Built by 2Space** · Pure-HTTP **Wikipedia scraper**, **Wikidata extractor**, **Wikipedia API** client, and **knowledge base dataset builder** engineered for AI agents, RAG pipelines, entity resolution, and MCP workflows.

[![Apify Actor](https://img.shields.io/badge/Apify-wikipedia--wikidata--scraper-00C853?style=flat-square)](https://apify.com/2space/wikipedia-wikidata-scraper)
[![MCP Ready](https://img.shields.io/badge/MCP-Ready-2563EB?style=flat-square)](https://mcp.apify.com?tools=2space/wikipedia-wikidata-scraper)
[![Zero Browser](https://img.shields.io/badge/Runtime-Pure%20HTTP%20%2B%20JSON-7C3AED?style=flat-square)](https://apify.com/2space/wikipedia-wikidata-scraper)

Whether you need a fast **Wikipedia scraper** for RAG and LLM grounding, a clean **Wikidata extractor** mapping encyclopedia articles to canonical Wikidata Q-IDs (`Q133436854`), or a structured **Wikipedia API** dataset for entity enrichment across any language edition, this Actor delivers validated, deduplicated records in seconds with zero headless browser overhead and zero external LLM API keys.

***

### Key Features & Why Choose This Scraper

- **Pure HTTP + Official MediaWiki & REST APIs:** Queries Wikipedia's official search API, REST v1 summary endpoint, and MediaWiki `action=query` endpoint over direct HTTP with a compliant `User-Agent`—no Puppeteer, no Playwright, and no proxy bloat.
- **Canonical Wikidata Q-ID Linking:** Every record automatically resolves its linked `wikidataId` (e.g., `Q133436854`) alongside `pageId`, `url`, `thumbnailUrl`, and clean topic `categories`.
- **Dual Input Modes (Search & Exact Titles):** Run keyword queries via `searchQueries`, fetch exact pages via `titles`, or combine both with automatic title and `pageId` deduplication.
- **Full Plain-Text Extracts + Lead Summaries:** Returns both a crisp lead `summary` and the complete plain-text `extractText` (toggleable via `includeFullExtract`) plus accurate `wordCount` and `lastModified` timestamps.
- **Multilingual Wikipedia Support:** Switch `language` to `en`, `de`, `fr`, `es`, `ja`, `simple`, or any Wikipedia language subdomain.
- **Instant Empty `{}` Input Support:** Works out of the box with zero configuration—an empty `{}` input defaults to `["Model Context Protocol", "Web scraping"]` (`en`, `maxItems: 6`, `maxCostUsd: 0.25`).
- **No Data, No Charge (Pay-Per-Event):** Uses the `wiki-article-scraped` event (`count: 1`), charged **only after** a validated article record is pushed to the dataset, with strict `maxItems` and `maxCostUsd` pre-charge spending guards.

***

### Common Use Cases

1. **RAG & LLM Knowledge Ingestion:** Build clean, plain-text Wikipedia corpora with `summary`, `extractText`, and `wordCount` ready for chunking, embeddings, and vector databases.
2. **Entity Resolution & Knowledge Graphs:** Enrich company, technology, and concept lists with canonical `wikidataId` Q-IDs, `pageId`s, and Wikipedia `categories`.
3. **AI Agent Tool Calling via MCP:** Give Claude, ChatGPT, Cursor, or Antigravity instant, deterministic encyclopedia and Wikidata lookup capabilities without browser latency.
4. **Multilingual Research & Dataset Creation:** Extract structured topic datasets across dozens of Wikipedia language editions in a single API call.

***

### Input Parameters

| Field | Type | Default | Description |
|---|---|---|---|
| `searchQueries` | `string[]` | `["Model Context Protocol", "Web scraping"]` | Wikipedia search queries. Leave empty when providing only `titles`. |
| `titles` | `string[]` | `[]` | Optional exact Wikipedia page titles to fetch directly. |
| `language` | `string` | `"en"` | Wikipedia language edition subdomain (`en`, `de`, `fr`, `es`, `ja`, etc.). |
| `includeFullExtract` | `boolean` | `true` | Fetch complete plain-text `extractText` alongside the REST `summary`. |
| `maxItems` | `integer` | `6` | Hard cap on deduplicated articles pushed and billed per run. |
| `maxCostUsd` | `number` | `0.25` | Pre-charge spending safety cap in USD for Pay-Per-Event billing. |

***

### Sample JSON Output

Each dataset item uses flat, strongly typed fields ready for JSON, CSV, SQL, vector stores, and MCP tool responses:

```json
{
  "pageId": 79706999,
  "title": "Model Context Protocol",
  "language": "en",
  "summary": "The Model Context Protocol (MCP) is an open standard, open-source framework introduced by Anthropic in November 2024 to standardize the way artificial intelligence (AI) systems like large language models (LLMs) integrate and share data with external tools, systems, and data sources.",
  "extractText": "The Model Context Protocol (MCP) is an open standard, open-source framework introduced by Anthropic in November 2024...\n\n== History ==\n...",
  "wikidataId": "Q133436854",
  "url": "https://en.wikipedia.org/wiki/Model_Context_Protocol",
  "thumbnailUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/Model_Context_Protocol_logo.svg/330px-Model_Context_Protocol_logo.svg.png",
  "categories": [
    "2024 software",
    "Anthropic",
    "Application layer protocols",
    "Generative AI",
    "Linux Foundation projects",
    "Open standards"
  ],
  "wordCount": 1320,
  "lastModified": "2026-11-23T20:16:26.000Z",
  "extractedAt": "2026-12-03T03:45:00.000Z"
}
```

A full execution summary is also persisted to the default Key-Value Store under `RUN_DIAGNOSTICS`, recording search counts, candidate deduplication totals, article success/failure counts, and budget-cap flags.

***

### 1-Prompt MCP Setup

Connect `2space/wikipedia-wikidata-scraper` directly to ChatGPT, Claude Desktop, Cursor, or Antigravity using the Apify MCP endpoint:

```text
https://mcp.apify.com?tools=2space/wikipedia-wikidata-scraper
```

Or configure `mcpServers` in your MCP client configuration:

```json
{
  "mcpServers": {
    "apify-wikipedia-wikidata": {
      "url": "https://mcp.apify.com?tools=2space/wikipedia-wikidata-scraper",
      "headers": {
        "Authorization": "Bearer YOUR_APIFY_TOKEN"
      }
    }
  }
}
```

Then prompt your AI assistant:

> *"Use 2space/wikipedia-wikidata-scraper to fetch the Wikipedia summaries, full extracts, categories, and Wikidata IDs for 'Retrieval-augmented generation' and 'Knowledge graph'."*

You can also invoke the synchronous Apify REST API directly from n8n, Make, Zapier, or any backend service:

```text
POST https://api.apify.com/v2/acts/2space~wikipedia-wikidata-scraper/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN
```

***

### Pricing & Reliability

- **Pay-Per-Event:** Billed via the single `wiki-article-scraped` event (`count: 1` per pushed article).
- **No Data, No Charge:** Missing or invalid pages are skipped before `Actor.pushData()` and never trigger `Actor.charge()`.
- **Hard Budget Safety:** Enforces both `maxItems` and `maxCostUsd` prior to pushing and charging, and exits immediately if Apify reports `eventChargeLimitReached`.

***

### Support

Questions or edge cases with specific Wikipedia language editions? Open an issue on the Actor's **Issues** tab in Apify Console (`https://apify.com/2space/wikipedia-wikidata-scraper/issues`) and include your input payload and `RUN_DIAGNOSTICS` output.

# Actor input Schema

## `searchQueries` (type: `array`):

Wikipedia search queries (e.g., 'Model Context Protocol', 'Web scraping', 'Large language model'). Leave empty when providing only exact page titles.

## `titles` (type: `array`):

Optional list of exact Wikipedia article titles to fetch directly (e.g., 'Artificial intelligence', 'Wikidata').

## `language` (type: `string`):

Two- or multi-letter Wikipedia subdomain language code (e.g., 'en', 'de', 'fr', 'es', 'ja', 'simple').

## `includeFullExtract` (type: `boolean`):

When enabled, fetches the complete plain-text article body in extractText in addition to the concise REST summary.

## `maxItems` (type: `integer`):

Hard cap on the maximum number of deduplicated articles to push and charge.

## `maxCostUsd` (type: `number`):

Pre-charge spending safety cap in USD for Pay-Per-Event billing.

## Actor input object example

```json
{
  "searchQueries": [
    "Model Context Protocol",
    "Web scraping"
  ],
  "titles": [],
  "language": "en",
  "includeFullExtract": true,
  "maxItems": 6,
  "maxCostUsd": 0.25
}
```

# Actor output Schema

## `overview` (type: `string`):

Dataset items containing extracted Wikipedia articles with Wikidata Q-IDs and flat scalar fields.

# 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 = {
    "searchQueries": [
        "Model Context Protocol",
        "Web scraping"
    ],
    "titles": [],
    "language": "en",
    "includeFullExtract": true,
    "maxItems": 6,
    "maxCostUsd": 0.25
};

// Run the Actor and wait for it to finish
const run = await client.actor("2space/wikipedia-wikidata-scraper").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 = {
    "searchQueries": [
        "Model Context Protocol",
        "Web scraping",
    ],
    "titles": [],
    "language": "en",
    "includeFullExtract": True,
    "maxItems": 6,
    "maxCostUsd": 0.25,
}

# Run the Actor and wait for it to finish
run = client.actor("2space/wikipedia-wikidata-scraper").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 '{
  "searchQueries": [
    "Model Context Protocol",
    "Web scraping"
  ],
  "titles": [],
  "language": "en",
  "includeFullExtract": true,
  "maxItems": 6,
  "maxCostUsd": 0.25
}' |
apify call 2space/wikipedia-wikidata-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,2space/wikipedia-wikidata-scraper"
        }
    }
}
```

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/FAlhV0p2G68ld63QG/builds/8cfQoPC9jerC7PiiE/openapi.json
