Searches Wikidata via Action API, Vector Database semantic search, SPARQL, and EntityData. Retrieves items, properties, claims, and external identifiers with fallback strategies.
Ships in wikidata-search. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Search and retrieve data from Wikidata, the free knowledge base.
This is the highest-value feature of this skill. The Wikidata Vector Database at wd-vectordb.wmcloud.org provides semantic/hybrid search over all Wikidata items — something you can't do with the standard Action API or SPARQL.
A descriptive User-Agent header is required or you get 403.
curl -H 'User-Agent: WikidataSearchSkill/1.0 (contact: [email protected])' \
'https://wd-vectordb.wmcloud.org/item/query/?query=historical+Chinese+cartography&lang=all&K=20'
Response includes QID, similarity_score, rrf_score, and source (vector vs keyword).
Property search: replace /item/query/ with /property/query/.
Optional params: lang, K (result count), instanceof (comma-separated QIDs), rerank.
When the Vector DB is down. It is a small research service on Wikimedia Cloud, not a core Wikidata service. It can return 503 or time out (on 2026-10-26 it timed out for 20+ seconds). Do not wait on it. Fall back to:
wbsearchentities (wd.search(...)) with several wordings, in English and in Chinese (e.g. 朱熹, Zhu Xi, Chu Hsi).action=query&list=search (full-text search; supports haswbstatement:P31=Q5 filters). See references/api_reference.md.?item wdt:P31 wd:Q5) once you know the kind of item you want.Tell the user that semantic search was not available and keyword search was used instead.
curl -G 'https://query.wikidata.org/sparql' \
--data-urlencode 'query=SELECT ?item ?label WHERE { ?item wdt:P31 wd:Q12857432 . ?item rdfs:label ?label . FILTER(LANG(?label)="en") }' \
-H 'Accept: application/sparql-results+json' \
-H 'User-Agent: WikidataSearchSkill/1.0 (contact: [email protected])'
The script's default User-Agent has a placeholder contact ([email protected]). Wikimedia asks every client to give real contact info. Set your own:
wd = WikidataAPI(user_agent="MyProject/1.0 (https://my.site; [email protected])")
or set the environment variable WIKIDATA_USER_AGENT. In the curl examples, replace [email protected] too.
WDQS converts every date to the Gregorian calendar. Wikidata often stores pre-1582 dates in the Julian calendar. Example: 朱熹 (Q9397) is stored as born 1130-10-18 (Julian). WDQS wdt:P569 returns 1130-10-25 (Gregorian). Both are the same day. If you compare with a source that uses Julian dates, or with Chinese calendar conversions that output Julian dates, the WDQS date will look 7–10 days off.
wd.get_entity(...) or Special:EntityData): claims.P569[0].mainsnak.datavalue.value has time and calendarmodel (Q1985786 = Julian, Q1985727 = Gregorian).?item p:P569/psv:P569/wikibase:timeCalendarModel ?cal tells you which calendar the editor used. The date value itself is still Gregorian.# claims[property_id][0]["mainsnak"]["datavalue"]["value"] → identifier string
# Common: P214 (VIAF), P244 (LoC), P227 (GND), P213 (ISNI), P268 (BnF)
| Need | Method |
|---|---|
| Keyword search by label/alias | Action API wbsearchentities |
| Semantic / fuzzy concept discovery | Vector Database (hybrid vector + keyword) |
| Fetch a known entity's JSON | Special:EntityData/{ID}.json |
| Complex graph queries / reporting | WDQS SPARQL |
Use scripts/wikidata_api.py for programmatic access (zero dependencies):
from scripts.wikidata_api import WikidataAPI
wd = WikidataAPI(user_agent="MyProject/1.0 ([email protected])")
# Keyword search
results = wd.search("Zhu Xi", language="en", limit=5)
# Semantic search (Vector DB) — the key differentiator
candidates = wd.vector_search_items("historical Chinese cartography", lang="all", k=20)
# Entity retrieval
entity = wd.get_entity("Q9397", props=["labels", "descriptions", "claims"])
# External identifiers (labels are fetched for all properties, 50 per call)
ids = wd.get_identifiers("Q9397", include_labels=True)
# → {'VIAF ID (P214)': '46768804', 'Library of Congress ID (P244)': 'n81008179', ...}
# SPARQL
results = wd.sparql_json("SELECT ?item ?label WHERE { ?item wdt:P31 wd:Q12857432 . ?item rdfs:label ?label . FILTER(LANG(?label)='en') }")
# Direct entity JSON (fast for current state)
data = wd.get_entitydata("Q42", flavor="simple")
| Endpoint | URL |
|---|---|
| Action API | https://www.wikidata.org/w/api.php |
| Entity JSON | https://www.wikidata.org/wiki/Special:EntityData/{ID}.json |
| SPARQL | https://query.wikidata.org/sparql |
| Vector DB | https://wd-vectordb.wmcloud.org |
Retry-After headersmaxlag parameter; batch with pipe-separated IDs (max 50)maxlag=5 tells Wikidata "if your servers are more than 5 seconds behind, refuse my request". Wikidata then returns HTTP 200 with {"error": {"code": "maxlag"}} and a Retry-After header. The lag includes query-service lag, which can stay above 5 seconds for hours (on 2026-10-26 it was about 11 seconds).maxlag=5 first, as Wikidata asks. On a maxlag error it waits (the Retry-After value, growing each time, at most 10 s) and retries twice. If Wikidata is still lagged, it sends the same request once more without maxlag. This is safe because every Action API call in this script is a read. maxlag mainly exists to slow down bots that edit. So by default reads still work during lag, but each call can take about 15 seconds.WikidataAPI(maxlag_fallback=False) raises MaxlagError instead of the fallback. WikidataAPI(maxlag=None) skips the check from the start; use it for a batch of many read calls while lag is high, and keep the rate limit. If you write your own code that edits Wikidata, always keep maxlag and never use the fallback.LIMITreferences/api_reference.md — Complete API specs for all four access methodsscripts/wikidata_api.py — Full-featured Python client with rate limiting, retries, and identifier extractionReport a problem. This skill is part of the public repository kltng/humanities-skills. If it fails (an API changed, a script errors, or these instructions are wrong), report it as a GitHub issue:
gh issue list --repo kltng/humanities-skills --state all --search "wikidata-search"gh issue create --repo kltng/humanities-skills --label bug --title "[wikidata-search] <short summary>" --body "<details>". Without gh, give the user this link: https://github.com/kltng/humanities-skills/issues/new?template=skill-problem.ymlCredit the source. The data comes from Wikidata, run by the Wikimedia Foundation and edited by volunteers. Wikidata's structured data is CC0, so credit is not a legal duty, but Wikidata asks for it: "we would greatly appreciate it if, in your project, you mention Wikidata as the origin of your data" (for example "Data from Wikidata"; see Wikidata:Data access). Give the QID and the date you looked it up, because items change. The vector search comes from the Wikidata Embedding Project, led by Wikimedia Deutschland, with the embedding model from Jina AI and the vector database from DataStax.
Cite. If this skill helped work that is published, please cite it, together with the source credited above:
Tang, Kwok-leong. humanities-skills: wikidata-search (version ). GitHub, . https://github.com/kltng/humanities-skills
When you help a user write up results that relied on this skill, remind them once about this citation and the credit above.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
wikidata, semantic-search, sparql, knowledge-base, entity-lookup
/wikidata-search:wikidata-searchfrom wikidata-search
npx claudepluginhub kltng/humanities-skills --plugin wikidata-searchOther plugins' skills for the same job