# Wikidata Scraper — Search, Entities & SPARQL API (`logiover/wikidata-scraper`) Actor

Scrape Wikidata by keyword search, entity IDs, or SPARQL query. Extract QIDs, labels, descriptions, aliases, instanceOf, and claim values. No API key, no login required.

- **URL**: https://apify.com/logiover/wikidata-scraper.md
- **Developed by:** [Logiover](https://apify.com/logiover) (community)
- **Categories:** Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.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.
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 — Search, Entity Lookup & SPARQL API for Structured Knowledge Graph Data

Extract structured knowledge from Wikidata's 100+ million entities via keyword search, direct entity lookup, or powerful SPARQL queries — no API key, no login required.

### What does Wikidata Scraper do?

Wikidata Scraper connects directly to the official Wikidata APIs and SPARQL endpoint to extract structured knowledge graph data at scale. In **search mode**, it uses the `wbsearchentities` action to find entities matching a keyword and paginates automatically up to your result limit. In **entities mode**, it calls `wbgetentities` in batches of 50 to fetch full labels, descriptions, aliases, and flattened claim values for a list of QIDs. In **sparql mode** — the highest-volume option — it sends your raw SPARQL query to the Wikidata Query Service and returns every row from the result, with thousands of entities extractable in a single run. All three modes are fully keyless, using only the public official Wikidata APIs. Output rows include the QID, human-readable label, description, aliases, instanceOf type classification, a direct Wikidata URL, and all claim or SPARQL binding values as structured JSON.

### Who is it for?

- **Data scientists and researchers** who need Wikidata knowledge graph data in bulk for NLP, entity linking, or knowledge base construction.
- **Journalists and fact-checkers** who need structured factual data (population, birth dates, office holders) without manual Wikidata navigation.
- **Developers building knowledge-enriched apps** who want to enrich their databases with canonical entity metadata from Wikidata.
- **AI and machine learning engineers** building entity recognition, disambiguation, or recommendation systems that benefit from Wikidata's linked data.
- **Business analysts and market researchers** who need structured lists — all companies in a sector, all airports in a country, all politicians in a parliament — exportable to CSV or Google Sheets.

### Use cases

- Extract all capital cities of the world with their countries and populations using a single SPARQL query.
- Look up 500 company QIDs to get official names, founding dates, headquarters locations, and sector classifications.
- Search Wikidata for all entities matching "Nobel Prize" to build a dataset of laureates.
- Build a dataset of all chemical elements with their atomic numbers, symbols, and discovery dates via SPARQL.
- Pull structured data on thousands of books — author, publication year, genre, language — from the Wikidata knowledge graph.

### Why use Wikidata Scraper?

- **Fully keyless**: Uses only official public Wikidata APIs — no account, no API key, no OAuth setup required.
- **Three powerful modes**: Keyword search with auto-pagination, bulk entity detail fetching by QIDs, and full SPARQL for complex structured queries.
- **High volume**: SPARQL mode can return thousands of rows in a single run — countries, companies, scientists, artworks, chemicals, and more.
- **Rich structured output**: Every row includes QID, label, description, aliases, instanceOf, direct URL, and flattened claim or SPARQL binding values.
- **Multilingual**: Set any language code (en, de, fr, es, ja, zh, ar, ...) to get labels and descriptions in your target language.
- **Export anywhere**: Download results as JSON, CSV, or Excel from Apify, or push directly to Google Sheets, Slack, or any webhook.

### What data can you extract?

Wikidata Scraper returns one row per entity (or per SPARQL result row). Every row contains the fields below.

| Field | Type | Description |
|-------|------|-------------|
| `qid` | string | Wikidata entity ID (e.g. `Q64`) |
| `label` | string | Human-readable entity name in the requested language |
| `description` | string | Short descriptive phrase (e.g. "capital and largest city of Germany") |
| `aliases` | string | Comma-separated list of alternative names and spellings |
| `instanceOf` | string | Comma-separated P31 (instance of) values — entity type classification |
| `wikidataUrl` | string | Direct link to the Wikidata entity page |
| `claims` | string | All claim values flattened as a JSON object (entities mode) |
| `sparqlBindings` | string | All SPARQL result variable bindings as a JSON object (sparql mode) |
| `mode` | string | Which mode produced this row: `search`, `entities`, or `sparql` |

**Example output row (sparql mode — countries with capitals):**

```json
{
  "qid": "Q183",
  "label": "Germany",
  "description": "",
  "aliases": "",
  "instanceOf": "",
  "wikidataUrl": "https://www.wikidata.org/wiki/Q183",
  "claims": "",
  "sparqlBindings": "{\"item\":\"http://www.wikidata.org/entity/Q183\",\"itemLabel\":\"Germany\",\"population\":\"84607016\",\"capital\":\"http://www.wikidata.org/entity/Q64\",\"capitalLabel\":\"Berlin\"}",
  "mode": "sparql"
}
```

### How to use

#### Option A — SPARQL mode (bulk, structured queries)

This is the recommended mode for extracting large structured datasets. Write a SPARQL query targeting Wikidata's property graph.

> **Note on output fields in SPARQL mode:** In SPARQL mode, the `description`, `aliases`, `instanceOf`, and `claims` fields are intentionally empty — they are only populated in **entities mode** which calls `wbgetentities`. All query result data in SPARQL mode is carried in the `sparqlBindings` field as a JSON object containing every bound variable from your SELECT clause. Use `sparqlBindings` to access `?birthDate`, `?occupation`, `?award`, etc. from your query.

**Steps:**

1. Open the actor and set **Mode** to `sparql`.
2. Enter your SPARQL query in the **SPARQL Query** field.
3. Set **Max Results** to 0 (unlimited) or a cap.
4. Click **Run** — results appear in the dataset.

**Example input (all sovereign states with capital and population):**

```json
{
  "mode": "sparql",
  "sparql": "SELECT ?item ?itemLabel ?population ?capital ?capitalLabel WHERE {\n  ?item wdt:P31 wd:Q6256 .\n  OPTIONAL { ?item wdt:P1082 ?population . }\n  OPTIONAL { ?item wdt:P36 ?capital . }\n  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en'. }\n}\nLIMIT 500",
  "language": "en",
  "maxResults": 0
}
```

#### Option B — Entities mode (lookup by QID list)

Use this when you already know the Wikidata QIDs you want and need full structured detail.

**Steps:**

1. Set **Mode** to `entities`.
2. Add your QID list to **Entity IDs (QIDs)**.
3. Set the **Language** code.
4. Run — each entity is returned with all claims flattened.

**Example input:**

```json
{
  "mode": "entities",
  "qids": ["Q64", "Q90", "Q220", "Q84", "Q456"],
  "language": "en"
}
```

#### Option C — Search mode (find entities by keyword)

Use this to discover entities matching a search term, with automatic pagination.

**Example input:**

```json
{
  "mode": "search",
  "query": "Olympic Games",
  "language": "en",
  "maxResults": 200
}
```

### Input parameters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `mode` | string | `sparql` | Operation mode: `search`, `entities`, or `sparql` |
| `query` | string | — | Keyword for search mode |
| `qids` | string\[] | — | Array of QIDs for entities mode (e.g. `["Q1", "Q42"]`) |
| `sparql` | string | (countries example) | Raw SPARQL query for sparql mode |
| `language` | string | `en` | Language code for labels/descriptions |
| `maxResults` | integer | `500` | Max rows to return (0 = unlimited) |
| `proxyConfiguration` | object | off | Optional Apify proxy settings |

**Full input JSON example (SPARQL mode):**

```json
{
  "mode": "sparql",
  "sparql": "SELECT ?item ?itemLabel ?inception ?sitelinks WHERE {\n  ?item wdt:P31 wd:Q7278 .\n  OPTIONAL { ?item wdt:P571 ?inception . }\n  OPTIONAL { ?item wikibase:sitelinks ?sitelinks . }\n  SERVICE wikibase:label { bd:serviceParam wikibase:language 'en'. }\n}\nORDER BY DESC(?sitelinks)\nLIMIT 200",
  "language": "en",
  "maxResults": 0,
  "proxyConfiguration": { "useApifyProxy": false }
}
```

### Output example

One fully-populated row from entities mode:

```json
{
  "qid": "Q64",
  "label": "Berlin",
  "description": "capital and largest city of Germany",
  "aliases": "Berlin, DE",
  "instanceOf": "Q515, Q1549591, Q200250",
  "wikidataUrl": "https://www.wikidata.org/wiki/Q64",
  "claims": "{\"P31\":[\"Q515\",\"Q1549591\",\"Q200250\"],\"P17\":\"Q183\",\"P131\":\"Q183\",\"P1082\":\"3677472\",\"P36\":\"Q64\",\"P571\":\"+993-01-01T00:00:00Z\",\"P856\":\"http://www.berlin.de/\"}",
  "sparqlBindings": "",
  "mode": "entities"
}
```

### Tips for best results

- **Use SPARQL for bulk extraction** — a single SPARQL query can return thousands of rows far faster than looping individual entity lookups.
- **Use the Wikidata Query Service editor** (query.wikidata.org) to test your SPARQL before running the actor — it has autocomplete and instant feedback.
- **Add SERVICE wikibase:label** to your SPARQL to get human-readable labels for entity URIs automatically.
- **Use LIMIT in your SPARQL** to control volume at the query level — this is more efficient than the `maxResults` cap.
- **Batch your QIDs** — the entities mode automatically batches up to 50 QIDs per API call, so you can safely pass thousands.
- **Set language to match your audience** — Wikidata has labels in 300+ languages; use `de` for German, `fr` for French, `zh` for Chinese.
- **Extract specific properties** — use `wdt:P<N>` in SPARQL to filter by specific Wikidata properties (P31=instance of, P17=country, P1082=population).
- **Combine modes** — run sparql mode first to collect QIDs, then run entities mode on those QIDs to get full claim detail.
- **Use OPTIONAL in SPARQL** — many entities lack certain properties; wrapping in OPTIONAL prevents missing values from filtering out rows.
- **Schedule recurring runs** — Wikidata is updated continuously; schedule weekly runs to keep your dataset fresh.

### Integrations

Connect Wikidata Scraper to your existing tools:

- **Google Sheets**: Use Apify's native Google Sheets integration to push results directly to a spreadsheet — no code required.
- **Slack**: Send run notifications to a Slack channel via the Apify webhook integration when a scheduled run completes.
- **Zapier / Make**: Trigger downstream workflows in 1,000+ apps when the actor finishes — email alerts, CRM updates, database inserts.
- **Webhooks**: Configure an Apify webhook to POST the dataset URL to your own endpoint as soon as results are ready.
- **Schedule**: Use Apify's built-in scheduler to run the actor daily, weekly, or monthly to keep your knowledge graph data current.
- **REST API**: Call the actor programmatically from any language using the Apify API (see code examples below).

### API usage

**cURL:**

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/logiover~wikidata-scraper/runs?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "sparql",
    "sparql": "SELECT ?item ?itemLabel WHERE { ?item wdt:P31 wd:Q6256 . SERVICE wikibase:label { bd:serviceParam wikibase:language '"'"'en'"'"'. } } LIMIT 200",
    "language": "en"
  }'
```

**Node.js (Apify client):**

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

const client = new ApifyClient({ token: 'YOUR_TOKEN' });

const run = await client.actor('logiover/wikidata-scraper').call({
  mode: 'sparql',
  sparql: `SELECT ?item ?itemLabel ?population WHERE {
    ?item wdt:P31 wd:Q6256 .
    OPTIONAL { ?item wdt:P1082 ?population . }
    SERVICE wikibase:label { bd:serviceParam wikibase:language 'en'. }
  } LIMIT 300`,
  language: 'en',
});

const dataset = await client.dataset(run.defaultDatasetId).listItems();
console.log(dataset.items);
```

**Python:**

```python
from apify_client import ApifyClient

client = ApifyClient('YOUR_TOKEN')

run = client.actor('logiover/wikidata-scraper').call(run_input={
    'mode': 'entities',
    'qids': ['Q64', 'Q90', 'Q220'],
    'language': 'en',
})

for item in client.dataset(run['defaultDatasetId']).iterate_items():
    print(item['label'], item['description'])
```

### Use with AI agents (MCP)

Wikidata Scraper is available as an MCP (Model Context Protocol) tool, letting AI agents like Claude pull structured knowledge graph data on demand. An AI assistant can query "What are all Nobel Prize laureates in Physics since 2000?" and the agent will run a SPARQL query against Wikidata, returning a structured dataset the AI can then analyze, summarize, or cross-reference. This makes Wikidata Scraper ideal for AI pipelines that need grounded, factual structured data without hallucination risk.

**Example agent prompt:**

> "Use the Wikidata Scraper to get all UNESCO World Heritage Sites in Italy with their year of inscription and site type, then summarize by category."

### FAQ

#### Does Wikidata Scraper require an API key or login?

No. All three modes (search, entities, sparql) use the public Wikidata APIs and SPARQL endpoint, which are open to anonymous requests. You do not need a Wikimedia account, OAuth token, or any credentials.

#### How much data can I extract in one run?

In SPARQL mode, a single run can return tens of thousands of rows — the only limit is the SPARQL endpoint's 60-second query timeout and the LIMIT clause in your query. In entities mode, you can pass thousands of QIDs and the actor batches them automatically. In search mode, results are paginated until your `maxResults` cap or no more results exist.

#### What is SPARQL and do I need to know it?

SPARQL is the query language for Wikidata's knowledge graph. It's similar to SQL but designed for linked data. The default query in the actor's input is a working example — you can use it as a template. The Wikidata Query Service at query.wikidata.org has an interactive editor with autocomplete and documentation.

#### Why do some results have empty `label` or `description` fields?

Not all Wikidata entities have labels or descriptions in every language. If you set `language: 'de'` but an entity has no German label, the field will be empty. Switch to `language: 'en'` for the best coverage, or use SPARQL with `SERVICE wikibase:label` which falls back to the entity's ID if no label exists.

#### What are QIDs and where do I find them?

QIDs are Wikidata's internal entity identifiers — a Q followed by a number (e.g. Q64 = Berlin, Q42 = Douglas Adams). You can find QIDs by searching on wikidata.org, by running the actor in search mode, or by extracting them from SPARQL results.

#### Can I get results in languages other than English?

Yes. Set the `language` parameter to any BCP 47 language code: `de` (German), `fr` (French), `es` (Spanish), `ja` (Japanese), `zh` (Chinese), `ar` (Arabic), and hundreds more. In SPARQL mode, add `SERVICE wikibase:label { bd:serviceParam wikibase:language 'de'. }` to your query.

#### Can I export results to CSV or Excel?

Yes. In Apify's dataset view, click **Export** and choose CSV, Excel, XML, or JSON. Results can also be pushed directly to Google Sheets via the Apify integration.

#### How fast does the actor run?

SPARQL queries typically complete in under 30 seconds for queries returning up to 10,000 rows. Entity batch lookups process 50 QIDs per API call with a short delay between batches. Search mode paginates at 50 results per page.

#### Is it legal to scrape Wikidata?

Yes. Wikidata publishes its data under the Creative Commons CC0 license (public domain), meaning you can freely use, share, and build on it for any purpose including commercial use. The Wikidata Foundation actively encourages programmatic access via its APIs and explicitly provides the SPARQL endpoint for bulk data access.

#### How often is Wikidata updated?

Wikidata is updated continuously by thousands of volunteer editors and automated bots. Most high-traffic entities (countries, cities, people) are updated within hours of real-world changes. Schedule the actor weekly or monthly to keep your dataset current.

#### What Wikidata properties are most useful for business data?

Key properties: P31 (instance of/type), P17 (country), P1082 (population), P18 (image), P856 (website), P571 (inception date), P576 (dissolved date), P452 (industry), P127 (owned by), P749 (parent company), P169 (CEO), P112 (founder), P159 (headquarters location).

#### What happens if my SPARQL query times out?

The Wikidata SPARQL endpoint imposes a 60-second query timeout. If your query is too complex or returns too much data, add a `LIMIT` clause, narrow your filter conditions, or split it into multiple queries with `OFFSET` pagination.

### Is it legal?

Wikidata is a free, open knowledge base operated by the Wikimedia Foundation and licensed under the Creative Commons CC0 1.0 Universal license (public domain dedication). This means all Wikidata content is freely available for any use — personal, academic, or commercial — with no attribution required. The Wikidata Foundation provides official public APIs and the SPARQL endpoint specifically to enable programmatic bulk access. This actor respects Wikidata's rate limits by including appropriate request delays and sends a descriptive User-Agent header as recommended in Wikidata's API etiquette guidelines. All data extracted by this actor is publicly available information that Wikidata explicitly makes available to everyone.

### Related scrapers

- **[Wikipedia Scraper](https://apify.com/logiover)** — Extract full article text, infobox data, and links from Wikipedia pages.
- **[Google Knowledge Graph Scraper](https://apify.com/logiover)** — Scrape entity data from Google's Knowledge Graph API.
- **[OpenCorporates Scraper](https://apify.com/logiover)** — Extract company registration data from 140+ jurisdictions.
- **[B2B Lead Scraper](https://apify.com/logiover/b2b-lead-scraper)** — Generate company and contact leads by sector and country using OpenStreetMap data.

### 📝 Changelog

#### 2026-08-01

- Completed the August 2026 full health check: verified empty/programmatic default, Console UI default, and two source-informed alternative inputs on Apify.
- Confirmed successful live execution, non-empty structured output, dataset-field/type integrity, and logical sample quality within the 5-minute quality window.

# Actor input Schema

## `mode` (type: `string`):

Operation mode: 'sparql' (run a SPARQL query for bulk data — the default), 'search' (find entities by keyword), or 'entities' (fetch entity details by QID). Leave everything blank to run the default SPARQL query.

## `query` (type: `string`):

Keyword to search for entities (used in 'search' mode only). Free text.

## `qids` (type: `array`):

List of Wikidata entity IDs (e.g. \['Q1', 'Q42', 'Q64']) to fetch in 'entities' mode. Supports up to 50 per batch automatically.

## `sparql` (type: `string`):

Raw SPARQL query for the Wikidata Query Service. This is the high-volume mode — a single query can return thousands of rows. Leave EMPTY to run a sensible default query (notable award winners).

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

Language code for labels and descriptions. Defaults to English.

## `maxResults` (type: `integer`):

Maximum number of results to return. In 'search' mode paginates automatically. In 'sparql' mode also use LIMIT in your query. Set 0 for unlimited (bounded by the query's own LIMIT).

## `proxyConfiguration` (type: `object`):

Proxy settings. Wikidata is a clean public API accessible without a proxy; enabling Apify proxy adds reliability and the Actor falls back to a direct connection if a proxy request fails.

## Actor input object example

```json
{
  "mode": "sparql",
  "query": "Douglas Adams",
  "qids": [
    "Q42",
    "Q64",
    "Q1"
  ],
  "sparql": "SELECT ?person ?personLabel ?birthDate ?birthPlaceLabel ?deathDate ?occupationLabel ?awardLabel ?countryLabel WHERE {\n  VALUES ?award { wd:Q38104 wd:Q35637 wd:Q44585 wd:Q37922 wd:Q80061 wd:Q135444 }\n  ?person wdt:P166 ?award .\n  ?person wdt:P31 wd:Q5 .\n  OPTIONAL { ?person wdt:P569 ?birthDate . }\n  OPTIONAL { ?person wdt:P19 ?birthPlace . }\n  OPTIONAL { ?person wdt:P570 ?deathDate . }\n  OPTIONAL { ?person wdt:P106 ?occupation . }\n  OPTIONAL { ?person wdt:P27 ?country . }\n  SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\". }\n}\nORDER BY DESC(?birthDate)\nLIMIT 300",
  "language": "en",
  "maxResults": 300,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

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

All records extracted by this run. Open the Dataset tab to browse, filter, and export as CSV, JSON, or Excel.

# 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 = {
    "sparql": `SELECT ?person ?personLabel ?birthDate ?birthPlaceLabel ?deathDate ?occupationLabel ?awardLabel ?countryLabel WHERE {
  VALUES ?award { wd:Q38104 wd:Q35637 wd:Q44585 wd:Q37922 wd:Q80061 wd:Q135444 }
  ?person wdt:P166 ?award .
  ?person wdt:P31 wd:Q5 .
  OPTIONAL { ?person wdt:P569 ?birthDate . }
  OPTIONAL { ?person wdt:P19 ?birthPlace . }
  OPTIONAL { ?person wdt:P570 ?deathDate . }
  OPTIONAL { ?person wdt:P106 ?occupation . }
  OPTIONAL { ?person wdt:P27 ?country . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY DESC(?birthDate)
LIMIT 300`,
    "maxResults": 300,
    "proxyConfiguration": {
        "useApifyProxy": true
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("logiover/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 = {
    "sparql": """SELECT ?person ?personLabel ?birthDate ?birthPlaceLabel ?deathDate ?occupationLabel ?awardLabel ?countryLabel WHERE {
  VALUES ?award { wd:Q38104 wd:Q35637 wd:Q44585 wd:Q37922 wd:Q80061 wd:Q135444 }
  ?person wdt:P166 ?award .
  ?person wdt:P31 wd:Q5 .
  OPTIONAL { ?person wdt:P569 ?birthDate . }
  OPTIONAL { ?person wdt:P19 ?birthPlace . }
  OPTIONAL { ?person wdt:P570 ?deathDate . }
  OPTIONAL { ?person wdt:P106 ?occupation . }
  OPTIONAL { ?person wdt:P27 ?country . }
  SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\". }
}
ORDER BY DESC(?birthDate)
LIMIT 300""",
    "maxResults": 300,
    "proxyConfiguration": { "useApifyProxy": True },
}

# Run the Actor and wait for it to finish
run = client.actor("logiover/wikidata-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "sparql": "SELECT ?person ?personLabel ?birthDate ?birthPlaceLabel ?deathDate ?occupationLabel ?awardLabel ?countryLabel WHERE {\\n  VALUES ?award { wd:Q38104 wd:Q35637 wd:Q44585 wd:Q37922 wd:Q80061 wd:Q135444 }\\n  ?person wdt:P166 ?award .\\n  ?person wdt:P31 wd:Q5 .\\n  OPTIONAL { ?person wdt:P569 ?birthDate . }\\n  OPTIONAL { ?person wdt:P19 ?birthPlace . }\\n  OPTIONAL { ?person wdt:P570 ?deathDate . }\\n  OPTIONAL { ?person wdt:P106 ?occupation . }\\n  OPTIONAL { ?person wdt:P27 ?country . }\\n  SERVICE wikibase:label { bd:serviceParam wikibase:language \\"en\\". }\\n}\\nORDER BY DESC(?birthDate)\\nLIMIT 300",
  "maxResults": 300,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}' |
apify call logiover/wikidata-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=logiover/wikidata-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/KusdBpW4RiRYOItvX/builds/YtyFc3b15c1A2jKWD/openapi.json
