# Wikidata Entity Scraper - Q-IDs, Labels & Claims API (`ninhothedev/wikidata-scraper`) Actor

$0.5/1K 🔥 Fast Wikidata scraper! Entities — labels, descriptions, aliases & claims in any language. No key. JSON, CSV, Excel or API in seconds. Search or list Q-IDs & pull thousands for knowledge graphs & AI enrichment ⚡

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

## Pricing

from $0.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.

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 Entity Scraper 🌐

**Scrape Wikidata at scale** — search the world's largest free knowledge graph or fetch structured entity data (labels, descriptions, aliases, "instance of" types and claim counts) for any Q-ID. Clean JSON output, no API key, ready for AI training pipelines, data enrichment and research.

Wikidata is the structured-data backbone behind Wikipedia, Google's Knowledge Graph, Siri, Alexa and thousands of apps. This actor turns it into a simple, paginated, machine-readable feed.

***

### ✨ What it does

Two modes, one actor:

| Mode | Input | Output |
|------|-------|--------|
| **search** | A text query (e.g. `albert einstein`) | Matching entities: `id`, `label`, `description`, `url` |
| **entities** | A list of Q-IDs (e.g. `["Q42","Q64"]`) | Full records: `label`, `description`, `aliases`, `instance_of` (P31), `claim_count`, `url` |

Every item is timestamped (`scraped_at`) and links straight to `wikidata.org`.

***

### 🚀 Example input

Search mode:

```json
{
  "mode": "search",
  "query": "albert einstein",
  "language": "en",
  "maxItems": 50
}
```

Entities mode:

```json
{
  "mode": "entities",
  "entityIds": ["Q42", "Q64", "Q937"],
  "language": "en",
  "maxItems": 100
}
```

### 📦 Example output

Search result:

```json
{
  "id": "Q937",
  "label": "Albert Einstein",
  "description": "German-born theoretical physicist (1879–1955)",
  "url": "http://www.wikidata.org/entity/Q937",
  "scraped_at": "2026-07-03T00:00:00Z"
}
```

Entity result:

```json
{
  "id": "Q42",
  "label": "Douglas Adams",
  "description": "English writer and humorist (1952–2001)",
  "aliases": ["Douglas Noel Adams", "Douglas Noël Adams"],
  "instance_of": ["Q5"],
  "claim_count": 305,
  "url": "https://www.wikidata.org/wiki/Q42",
  "scraped_at": "2026-07-03T00:00:00Z"
}
```

***

### 🎯 Use cases

- **Knowledge graphs** — build or enrich your own graph with canonical entity IDs, types and relationships.
- **AI / LLM training** — harvest clean, licensed, structured facts for grounding, RAG and fine-tuning datasets.
- **Data enrichment** — resolve messy names to stable Q-IDs, then attach descriptions, aliases and categories.
- **Research & journalism** — pull structured facts about people, places, organisations and works at scale.

***

### 💸 Pricing & cost

This actor is lightweight and runs on **512 MB**. Wikidata's API is free, so your only cost is compute.

- **~$1 per 1,000 items** (search results or entities) as a rough guide.
- Fetching entities is batched **50 per request**, keeping runs fast and cheap.
- No proxies required — the Wikidata API is datacenter-friendly.

Actual cost depends on `maxItems` and the Apify plan you run on.

***

### ⚙️ Input reference

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `mode` | select | `search` | `search` or `entities` |
| `query` | string | `albert einstein` | Text query (search mode) |
| `language` | string | `en` | Language code for labels/descriptions/aliases |
| `entityIds` | array | – | List of Q-IDs (entities mode) |
| `maxItems` | integer | `100` | Max items to return (1–500) |

***

### 🆚 How it compares

- **vs. raw SPARQL / Query Service** — no query language to learn, no timeouts on big result sets, and output lands directly in an Apify dataset you can export to JSON/CSV/Excel.
- **vs. writing your own client** — pagination, batching, retries, curl\_cffi impersonation and schema-validated output are handled for you.
- **vs. generic scrapers** — purpose-built for Wikidata's entity model (Q-IDs, P31, claims), not brittle HTML parsing.

***

### 🔗 Related actors

- [Wikipedia Scraper](https://apify.com/ninhothedev/wikipedia-scraper)
- [Dictionary Scraper](https://apify.com/ninhothedev/dictionary-scraper)
- [Geocoding Scraper](https://apify.com/ninhothedev/geocoding-scraper)
- [MusicBrainz Scraper](https://apify.com/ninhothedev/musicbrainz-scraper)

***

### 🛟 Support

Questions, feature requests or a bug? Open an issue on the actor page and we'll respond quickly. Custom fields, extra properties or bulk plans are available on request.

***

**Keywords:** wikidata scraper, knowledge graph api, wikidata entities, q-id lookup, structured data, entity extraction, ai training data, semantic web, wikibase, linked data

# Actor input Schema

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

Choose 'search' to find entities by a text query, or 'entities' to fetch full details (labels, descriptions, aliases, instance-of, claim counts) for a list of known Q-IDs.

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

Text to search Wikidata for (only used in 'search' mode). Example: 'albert einstein'.

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

Wikidata language code for labels, descriptions and aliases (e.g. 'en', 'de', 'fr', 'es').

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

List of Wikidata Q-IDs to fetch (only used in 'entities' mode). Example: \["Q42", "Q64"].

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

Maximum number of result items to return (1-500). Applies to search results and to the number of entities fetched.

## Actor input object example

```json
{
  "mode": "search",
  "query": "albert einstein",
  "language": "en",
  "entityIds": [
    "Q42",
    "Q64"
  ],
  "maxItems": 100
}
```

# 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 = {
    "query": "albert einstein",
    "entityIds": [
        "Q42",
        "Q64"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ninhothedev/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 = {
    "query": "albert einstein",
    "entityIds": [
        "Q42",
        "Q64",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("ninhothedev/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 '{
  "query": "albert einstein",
  "entityIds": [
    "Q42",
    "Q64"
  ]
}' |
apify call ninhothedev/wikidata-scraper --silent --output-dataset

```

## MCP server setup

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