# Wikidata Entity Scraper — Labels, Claims & Sitelinks (`s7_studio/wikidata-scraper`) Actor

Scrape Wikidata entities by ID or search query via the official REST and Action APIs. Returns labels, descriptions, aliases, key claims (P-values), and sitelinks count. No proxy, no auth. Pay per entity.

- **URL**: https://apify.com/s7\_studio/wikidata-scraper.md
- **Developed by:** [S7 Studio](https://apify.com/s7_studio) (community)
- **Categories:** Education, MCP servers, AI
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.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/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

## Wikidata Entity Scraper — Labels, Claims & Sitelinks | from $0.50/1K

**Built for knowledge-graph builders, entity-resolution pipelines, and AI agents** that need structured Wikidata records by Q-ID or keyword. Official APIs only — no proxy, no auth, zero COGS.

Extract structured data from Wikidata entities via the official public APIs. No proxy, no authentication required.

***

### What you get

For each entity (fetched by Q-ID or discovered via search):

| Field | Description |
|---|---|
| `entity_id` | Wikidata Q-ID (e.g. `Q42`) |
| `label` | Human-readable name in requested language |
| `description` | Short description (e.g. "British science fiction writer") |
| `aliases` | Known alternative names |
| `instance_of` | What type of entity this is (Q-IDs from P31) |
| `key_claims` | Selected property values (dates, genders, occupations, nationalities…) |
| `sitelinks_count` | Number of Wikipedia editions this entity has an article on |
| `url` | Canonical Wikidata entity URL |
| `parse_confidence` | 0.0–1.0 quality score; 1.0 = all expected fields present |
| `warnings` | List of field-level quality warnings |

***

### Inputs

#### Basic

| Parameter | Type | Description | Default |
|---|---|---|---|
| `entityIds` | array | Wikidata Q-IDs to fetch directly | `["Q42", "Q937"]` |
| `searchQueries` | array | Full-text search queries | `[]` |
| `language` | string | Language code for labels/descriptions | `"en"` |
| `maxItems` | integer | Max total entities to return (0 = unlimited) | `50` |
| `maxSearchResults` | integer | Max results per search query (1–50) | `10` |

#### Advanced

| Parameter | Type | Description | Default |
|---|---|---|---|
| `claimProperties` | array | P-value property IDs to extract | `["P31","P21","P27","P569","P570","P19","P106"]` |
| `maxClaimsPerProperty` | integer | Max values per property (0 = all) | `5` |

**Default properties extracted:**

- `P31` — instance of (what kind of thing this is)
- `P21` — sex or gender
- `P27` — country of citizenship
- `P569` — date of birth
- `P570` — date of death
- `P19` — place of birth
- `P106` — occupation

Other useful properties: `P18` (image), `P856` (website), `P17` (country), `P131` (located in), `P625` (coordinates).

***

### Example

**Input:**

```json
{
  "entityIds": ["Q42", "Q7186"],
  "language": "en",
  "claimProperties": ["P31", "P569", "P570", "P106"]
}
```

**Output record for Q42:**

```json
{
  "entity_id": "Q42",
  "label": "Douglas Adams",
  "description": "British science fiction writer and humorist (1952–2001)",
  "aliases": ["Douglas Noel Adams"],
  "instance_of": ["Q5"],
  "key_claims": {
    "P31": ["Q5"],
    "P569": ["1952-03-11T00:00:00Z"],
    "P570": ["2001-05-11T00:00:00Z"],
    "P106": ["Q214917", "Q28389", "Q6625963"]
  },
  "sitelinks_count": 132,
  "url": "https://www.wikidata.org/wiki/Q42",
  "language": "en",
  "query": "Q42",
  "source": "entity_id",
  "scraped_at": "2026-05-31T10:00:00Z",
  "parse_confidence": 1.0,
  "warnings": []
}
```

***

### Notes on claim values

Claim values are decoded to human-readable strings:

- **wikibase-item** → Q-ID string (`"Q5"`, `"Q6581097"`)
- **time** → ISO date string (`"1952-03-11T00:00:00Z"`)
- **string / external-id** → raw string
- **quantity** → `"42 Q11573"` (amount + unit Q-ID)

To look up what a Q-ID means (e.g. `"Q5"` = human, `"Q145"` = United Kingdom), search it on [wikidata.org](https://www.wikidata.org).

***

### Pricing

Pay per entity: **from $0.50 / 1,000 entities** (PPE). Apify automatically charges the run owner. No monthly subscription. The first few seconds of each run are covered by Apify.

| Volume | Cost |
|--------|------|
| 100 entities | ~$0.05 |
| 1,000 entities | ~$0.50 |
| 10,000 entities | ~$5.00 |

***

### FAQ

**Do I need a proxy or API key?**
No. Wikidata is a fully public API — no credentials, no proxy required.

**What output formats are available?**
JSON (default), CSV, and Excel — downloadable from the Apify dataset UI or via the REST API.

**Can I schedule this to run automatically?**
Yes. Apify's scheduler runs this on any cron schedule and can push results via webhook to your pipeline automatically.

**What if a Q-ID doesn't exist or returns empty?**
The actor logs a warning and skips the entity — no crash. Missing Q-IDs appear in the `OUTPUT.failedDetails` summary at the end of the run.

***

### Why this actor

- **Official APIs only** — EntityData REST + Action API. No DOM scraping, no parsing fragility.
- **Zero cost** — Wikidata is public, no proxy or authentication needed.
- **Configurable properties** — extract exactly the P-values you need.
- **parse\_confidence field** — machine-detectable data quality in every row.
- **Multi-language** — labels and descriptions in any Wikidata language.

***

*Not affiliated with Wikimedia Foundation. Uses the official Wikidata public APIs.*

***

### Use with AI agents (MCP)

This actor is available as an MCP tool for Claude, GPT-4, and other AI agents that support the Model Context Protocol:

```
https://mcp.apify.com/?tools=bovi/wikidata-scraper
```

Feed any Q-ID or search term and get back structured entity data — ideal for knowledge-graph enrichment, entity disambiguation, and AI research pipelines.

***

### vs. competitors

| | **This actor** | Typical Wikidata scraper |
|---|---|---|
| Data source | Official Wikidata REST + Action APIs | HTML / DOM scraping |
| P-values (claims) | Configurable selection | Rarely exposed |
| `parse_confidence` | ✓ | No |
| Proxy needed | No | Often required |
| Price | from $0.50/1K | $2–5/1K |

### Integrations

Built for knowledge-graph builders and entity-resolution pipelines consuming structured Wikidata records by Q-ID or keyword — the JSON/dataset output drops into the tools you already run, no glue code:

- **n8n / Make / Zapier** — trigger a run or pipe every new dataset item into 500+ apps (Google Sheets, Airtable, Slack, HubSpot, your database) with no code: [n8n](https://docs.apify.com/platform/integrations/n8n), [Make](https://docs.apify.com/platform/integrations/make), [Zapier](https://docs.apify.com/platform/integrations/zapier).
- **Webhooks** — fire your own endpoint the moment a run finishes, to push results straight into your pipeline ([docs](https://docs.apify.com/platform/integrations/webhooks)).
- **MCP server** — expose this actor as a tool to Claude, Cursor, or any [MCP client](https://mcp.apify.com) so an AI agent can pull this data mid-conversation ([guide](https://blog.apify.com/how-to-use-mcp/)).
- **API & SDKs** — fetch the dataset as JSON, CSV, or Excel through the Apify REST API or the Python / JS SDKs.

See all [Apify integrations](https://apify.com/integrations).

# Actor input Schema

## `entityIds` (type: `array`):

Wikidata entity Q-IDs to fetch directly (e.g. "Q42", "Q937", "Q7186"). Accepts any valid Wikidata entity identifier.

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

Full-text search terms. Each query finds the top matching Wikidata entities. Combines with entityIds — both are processed.

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

Language code for labels, descriptions, and aliases. Use a valid BCP 47 language code: en (English), de (German), fr (French), es (Spanish), zh (Chinese), ja (Japanese), ru (Russian), etc. Default: en.

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

Maximum total entities to return across all IDs and search queries. 0 = no limit. Default 50.

## `maxSearchResults` (type: `integer`):

Maximum entities returned per search query. Range 1–50. Default 10.

## `claimProperties` (type: `array`):

Wikidata property IDs (P-values) to extract from entity claims. Common examples: P31 (instance of), P21 (sex/gender), P27 (country of citizenship), P569 (date of birth), P570 (date of death), P19 (place of birth), P106 (occupation), P18 (image). Leave empty for default set.

## `maxClaimsPerProperty` (type: `integer`):

Maximum claim values to extract per property (some entities have dozens of occupations, etc.). 0 = all. Default 5.

## Actor input object example

```json
{
  "entityIds": [
    "Q42",
    "Q937"
  ],
  "searchQueries": [],
  "language": "en",
  "maxItems": 50,
  "maxSearchResults": 10,
  "claimProperties": [
    "P31",
    "P21",
    "P27",
    "P569",
    "P570",
    "P19",
    "P106"
  ],
  "maxClaimsPerProperty": 5
}
```

# Actor output Schema

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

Dataset containing Wikidata Scraper records (entity\_id, label, description, aliases, instance\_of, key\_claims, sitelinks\_count, url, parse\_confidence, warnings).

# 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 = {
    "entityIds": [
        "Q42",
        "Q937"
    ],
    "searchQueries": [],
    "language": "en",
    "maxItems": 50,
    "maxSearchResults": 10,
    "claimProperties": [
        "P31",
        "P21",
        "P27",
        "P569",
        "P570",
        "P19",
        "P106"
    ],
    "maxClaimsPerProperty": 5
};

// Run the Actor and wait for it to finish
const run = await client.actor("s7_studio/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 = {
    "entityIds": [
        "Q42",
        "Q937",
    ],
    "searchQueries": [],
    "language": "en",
    "maxItems": 50,
    "maxSearchResults": 10,
    "claimProperties": [
        "P31",
        "P21",
        "P27",
        "P569",
        "P570",
        "P19",
        "P106",
    ],
    "maxClaimsPerProperty": 5,
}

# Run the Actor and wait for it to finish
run = client.actor("s7_studio/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 '{
  "entityIds": [
    "Q42",
    "Q937"
  ],
  "searchQueries": [],
  "language": "en",
  "maxItems": 50,
  "maxSearchResults": 10,
  "claimProperties": [
    "P31",
    "P21",
    "P27",
    "P569",
    "P570",
    "P19",
    "P106"
  ],
  "maxClaimsPerProperty": 5
}' |
apify call s7_studio/wikidata-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,s7_studio/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/Bs0P9oczKQiuc2ve2/builds/Fe466HxahCJ5YlZe1/openapi.json
