Wikidata Scraper — Search, Entities & SPARQL API
Pricing
from $1.50 / 1,000 results
Wikidata Scraper — Search, Entities & SPARQL API
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.
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):
{"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, andclaimsfields are intentionally empty — they are only populated in entities mode which callswbgetentities. All query result data in SPARQL mode is carried in thesparqlBindingsfield as a JSON object containing every bound variable from your SELECT clause. UsesparqlBindingsto access?birthDate,?occupation,?award, etc. from your query.
Steps:
- Open the actor and set Mode to
sparql. - Enter your SPARQL query in the SPARQL Query field.
- Set Max Results to 0 (unlimited) or a cap.
- Click Run — results appear in the dataset.
Example input (all sovereign states with capital and population):
{"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:
- Set Mode to
entities. - Add your QID list to Entity IDs (QIDs).
- Set the Language code.
- Run — each entity is returned with all claims flattened.
Example input:
{"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:
{"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):
{"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:
{"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
maxResultscap. - 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
defor German,frfor French,zhfor 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:
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):
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:
from apify_client import ApifyClientclient = 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 — Extract full article text, infobox data, and links from Wikipedia pages.
- Google Knowledge Graph Scraper — Scrape entity data from Google's Knowledge Graph API.
- OpenCorporates Scraper — Extract company registration data from 140+ jurisdictions.
- B2B Lead Scraper — Generate company and contact leads by sector and country using OpenStreetMap data.