# Wikidata Scraper: Structured Entity Facts & Claims (`arman-bd/wikidata-entities-scraper`) Actor

Scrape Wikidata entities: labels, descriptions, aliases and every property claim with qualifiers, in any language. The structured knowledge graph behind Wikipedia.

- **URL**: https://apify.com/arman-bd/wikidata-entities-scraper.md
- **Developed by:** [Arman Hossain](https://apify.com/arman-bd) (community)
- **Categories:** Automation, AI, MCP servers
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.37 / 1,000 entity scrapeds

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/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

## Wikidata Scraper: Structured Entity Facts & Claims

![Wikidata Scraper: Labels, descriptions, aliases and every property claim with qualifiers, flattened from Wikidata's nested JSON into usable rows](https://api.apify.com/v2/key-value-stores/ZQOcNAOHrIgTacAmy/records/wikidata-entities-scraper.jpg)

**Wikidata Entities Scraper** pulls entities out of **Wikidata**, labels, descriptions, aliases and every property claim with its qualifiers, and flattens the deeply nested claim structures into rows you can actually use.

Wikidata is the machine-readable knowledge graph behind Wikipedia: 100M+ entities, CC0-licensed, with a public API built for programmatic access. This Actor reads that API directly: **no proxy setup, no browser, no credentials to manage.** Entities are fetched 50 at a time, and identifiers inside claims are resolved to human-readable labels for you.

**Agent skill: [SKILL.md](https://api.apify.com/v2/key-value-stores/t7YoTxpZEJOWvw4Ug/records/wikidata-entities-scraper.md)**

```
https://api.apify.com/v2/key-value-stores/t7YoTxpZEJOWvw4Ug/records/wikidata-entities-scraper.md
```

### What you get

| Output field | Meaning |
|---|---|
| `entityId` | Wikidata identifier, e.g. `Q42` |
| `label`, `description` | Preferred label and short description in your requested language |
| `aliases` | Alternative names in the same language |
| `instanceOf` | The `P31` values as `{ id, label }`, the entity's type, pulled out for convenience |
| `claims` | Every property, keyed by P-id, with its label, datatype and flattened values |
| `qualifiers` | Statement-level detail for the claims that carry qualifiers (start/end dates, roles, sources) |
| `sitelinks` | Map of every linked Wikimedia project → URL |
| `wikipediaUrl` | Direct Wikipedia link in your first requested language |
| `modified` | Last edit timestamp of the entity |
| `scrapedAt` | Run timestamp |

A `RUN_SUMMARY` record in the key-value store holds per-run counts, the filters used, and any entity that failed.

### Common use cases

- **Entity resolution.** Turn free-text names into stable Q-ids and canonical identifiers.
- **Knowledge graphs.** Extract typed facts (birth dates, coordinates, parent companies) as clean rows.
- **Record enrichment.** Attach VIAF, ISNI, GRID, IMDb, MusicBrainz and 6,000 other external IDs to your own data.
- **AI agents and RAG.** A fast, licence-clean fact layer that does not hallucinate.
- **Media and entertainment analysis.** Cast, crew, awards, franchises and release data, already structured.

### Quick start

Three entities, everything they have:

```json
{
 "entityIds": ["Q42", "Q64", "Q95"]
}
```

Resolve names, then keep only the facts you care about:

```json
{
 "searchTerms": ["Douglas Adams", "Ada Lovelace"],
 "properties": ["P31", "P569", "P570", "P106"],
 "languages": ["en"],
 "includeSitelinks": false
}
```

German labels, raw identifiers, minimal payload:

```json
{
 "entityIds": ["Q64"],
 "languages": ["de", "en"],
 "resolveLabels": false,
 "includeSitelinks": false
}
```

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `entityIds` | array | `[]` | Q-identifiers (`Q42`), full `wikidata.org/wiki/…` URLs or entity URIs. Anything that is not an identifier is treated as a search term. |
| `searchTerms` | array | `[]` | Names resolved to entities via `wbsearchentities` before fetching. |
| `properties` | array | `[]` | Keep only these P-properties. Empty = every claim on the entity. |
| `languages` | array | `["en"]` | Fallback chain for labels, descriptions and aliases, first language with a value wins. |
| `resolveLabels` | boolean | `true` | Resolve referenced P-ids and Q-ids to labels (`P31` → *instance of*, `Q5` → *human*). |
| `includeSitelinks` | boolean | `true` | Include the site → URL map. A popular entity carries 300+ sitelinks. |
| `resultsPerSearchTerm` | integer | `1` | Entities kept per search term. Raise it when names are ambiguous. |

Provide `entityIds`, `searchTerms`, or both, at least one entity must be resolvable or the run errors out immediately.

### Output example

```json
{
 "entityId": "Q42",
 "label": "Douglas Adams",
 "description": "British science fiction writer and humorist (1952-2001)",
 "aliases": ["Douglas Noël Adams", "Douglas N. Adams"],
 "instanceOf": [{ "id": "Q5", "label": "human" }],
 "claims": {
 "P31": { "label": "instance of", "datatype": "wikibase-item", "values": [{ "id": "Q5", "label": "human" }] },
 "P569": { "label": "date of birth", "datatype": "time", "values": [{ "time": "1952-03-11", "precision": "day", "calendar": "Gregorian", "raw": "+1952-03-11T00:00:00Z" }] },
 "P2048": { "label": "height", "datatype": "quantity", "values": [{ "amount": 1.96, "unit": { "id": "Q11573", "label": "metre" }, "lowerBound": null, "upperBound": null }] },
 "P1813": { "label": "short name", "datatype": "monolingualtext", "values": [{ "text": "Douglas Adams", "language": "en" }] },
 "P856": { "label": "official website", "datatype": "url", "values": ["https://douglasadams.com"] },
 "P18": { "label": "image", "datatype": "commonsMedia", "values": [{ "file": "Douglas adams portrait.jpg", "url": "https://commons.wikimedia.org/wiki/File:Douglas_adams_portrait.jpg" }] },
 "P214": { "label": "VIAF cluster ID", "datatype": "external-id", "values": ["113230702"] }
 },
 "qualifiers": {
 "P26": [{
 "value": { "id": "Q14623681", "label": "Jane Belson" },
 "rank": "normal",
 "qualifiers": {
 "P580": { "label": "start time", "values": [{ "time": "1991-11-25", "precision": "day", "calendar": "Gregorian" }] },
 "P582": { "label": "end time", "values": [{ "time": "2001-05-11", "precision": "day", "calendar": "Gregorian" }] }
 }
 }]
 },
 "sitelinks": { "enwiki": "https://en.wikipedia.org/wiki/Douglas_Adams", "dewiki": "https://de.wikipedia.org/wiki/Douglas_Adams" },
 "wikipediaUrl": "https://en.wikipedia.org/wiki/Douglas_Adams",
 "modified": "2026-08-03T13:13:51Z",
 "scrapedAt": "2026-08-06T11:40:00.000Z"
}
```

### How claims are flattened

Raw Wikidata claims are five levels deep and every datatype nests differently. Each one is unwrapped explicitly:

| Datatype | Flattened to |
|---|---|
| `wikibase-item`, `wikibase-property` | `{ id, label }` |
| `time` | `{ time, precision, calendar, raw }`, trimmed to the stated precision, so a year-precision date stays `"1952"` rather than pretending to be 1 January |
| `quantity` | `{ amount, unit: { id, label }, lowerBound, upperBound }`, `amount` is a real number, not `"+1.96"` |
| `globe-coordinate` | `{ latitude, longitude, altitude, precision, globe }` |
| `monolingualtext` | `{ text, language }` |
| `string`, `url`, `external-id`, `math`, `geo-shape` | plain string |
| `commonsMedia` | `{ file, url }`, the resolvable Commons URL, not just a file name |
| no value / unknown value | `{ "special": "novalue" }` / `{ "special": "somevalue" }` |

`claims` is the flat digest of every statement. `qualifiers` carries the statements that have qualifiers, with rank and the qualifier snaks flattened the same way, so nothing is lost, and the common case stays readable.

### API example

```bash
curl -X POST "https://api.apify.com/v2/acts/arman-bd~wikidata-entities-scraper/run-sync-get-dataset-items?token=YOUR_TOKEN" \
 -H "Content-Type: application/json" \
 -d '{
 "entityIds": ["Q42"],
 "properties": ["P31", "P569", "P106"]
 }'
```

### JavaScript example

```js
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'YOUR_TOKEN' });
const run = await client.actor('arman-bd/wikidata-entities-scraper').call({
 searchTerms: ['Douglas Adams', 'Ada Lovelace'],
 properties: ['P31', 'P569', 'P570'],
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
for (const e of items) {
 console.log(`${e.entityId} ${e.label}, born ${e.claims.P569?.values[0]?.time ?? 'unknown'}`);
}
```

### Limits and behaviour

- **Bad ids don't kill the run.** `wbgetentities` rejects an entire 50-id batch when one id does not exist. The Actor reads the offending id out of the error, drops it into `RUN_SUMMARY.failures` and retries the remaining 49. You never lose good entities to one typo.
- **Batched by design.** Entities are fetched 50 per request, and label lookups are batched and cached across the whole run.
- **`mul` labels are handled.** Wikidata has moved Latin-script labels and aliases to the shared `mul` language, so asking for `en` alone returns an *empty* label on a large share of entities. This Actor sends `languagefallback=1` and adds `mul` to the chain, which is why `Q42` still comes back as "Douglas Adams".
- **Transient errors are retried.** 429 and 5xx get four attempts with exponential backoff and jitter.
- **Descriptive user agent.** Wikimedia throttles generic clients within a handful of requests; every request identifies this Actor.
- **Public data only.** Wikidata is CC0. No authentication, no personal data, no access-control bypass.

### FAQ

**Do I need a proxy?** No. Proxy configuration is not required to run this Actor.

**Do I need an account on Wikidata?** No. You supply no credentials.

**What happens if an entity is unavailable?** It is recorded in `RUN_SUMMARY.failures` and the run continues. The Actor only errors out if nothing at all could be fetched.

**Can I schedule it?** Yes, it is designed for scheduled runs. Diff on `modified` to detect changed entities cheaply.

**How do I find a Q-id?** Put the name in `searchTerms` and let the Actor resolve it, or read it from the Wikipedia sidebar under *Wikidata item*.

**Why is a claim value `{ "special": "novalue" }`?** Wikidata distinguishes "we know there is no value" (`novalue`) from "we know there is one but not which" (`somevalue`). Both are preserved rather than silently becoming `null`.

**Can I get lexemes or properties?** Yes, `L` and `P` identifiers are accepted in `entityIds` alongside `Q` items.

**Can I integrate it with something else?** Yes, Apify API, client libraries, webhooks, scheduled runs, dataset exports (JSON/CSV/Excel) or MCP. Output is structured JSON.

# Actor input Schema

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

Wikidata identifiers such as 'Q42'. Full URLs (https://www.wikidata.org/wiki/Q42) and entity URIs are accepted. Anything that is not an identifier is treated as a search term.

## `searchTerms` (type: `array`):

Names to resolve to entities before fetching, e.g. 'Douglas Adams'. Each term is matched against labels and aliases in the first language you request.

## `properties` (type: `array`):

Keep only these P-properties in the output, e.g. 'P31' (instance of) or 'P569' (date of birth). Leave empty to return every claim on the entity.

## `languages` (type: `array`):

Language codes for labels, descriptions and aliases, most preferred first. They act as a fallback chain: the first language that has a value wins.

## `resolveLabels` (type: `boolean`):

Look up human-readable labels for every referenced property and item, so P31 → 'instance of' and Q5 → 'human'. Costs extra batched requests; turn off for raw identifiers only.

## `includeSitelinks` (type: `boolean`):

Include the full site → URL map of linked Wikimedia projects. A popular entity can carry 300+ sitelinks, so turn this off for a leaner dataset.

## `resultsPerSearchTerm` (type: `integer`):

How many entities to keep per search term. 1 takes the best match only; raise it when names are ambiguous.

## Actor input object example

```json
{
  "entityIds": [
    "Q42",
    "https://www.wikidata.org/wiki/Q95"
  ],
  "searchTerms": [
    "Douglas Adams",
    "Berlin"
  ],
  "properties": [
    "P31",
    "P569",
    "P625"
  ],
  "languages": [
    "en",
    "de"
  ],
  "resolveLabels": true,
  "includeSitelinks": true,
  "resultsPerSearchTerm": 1
}
```

# Actor output Schema

## `items` (type: `string`):

Every record the run produced.

## `runsummary` (type: `string`):

The RUN\_SUMMARY record from the run's key-value store.

# 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",
        "Q64"
    ],
    "languages": [
        "en"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("arman-bd/wikidata-entities-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",
        "Q64",
    ],
    "languages": ["en"],
}

# Run the Actor and wait for it to finish
run = client.actor("arman-bd/wikidata-entities-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",
    "Q64"
  ],
  "languages": [
    "en"
  ]
}' |
apify call arman-bd/wikidata-entities-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,arman-bd/wikidata-entities-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/jzMhU7OiegSS9pYtd/builds/nigDzv15DF3W0Sug0/openapi.json
