sparql-query-wikidata

Query live Wikidata facts via SPARQL using entity search and domain-specific property sets.

Updated May 12, 2026
One-click install
npx skills add https://github.com/angelo-v/pi-kit --skill sparql-query-wikidata-angelo-v
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sparql-query-wikidata
Source: https://github.com/angelo-v/pi-kit/tree/main/packages/linked-data/skills/sparql-query-wikidata
Command: npx skills add https://github.com/angelo-v/pi-kit --skill sparql-query-wikidata-angelo-v

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? AI models often hallucinate Wikidata entity IDs (Q-numbers) and property IDs (P-numbers) from training knowledge, producing wrong or empty query results. This Skill enforces a mandatory workflow that resolves every entity and property through live search before writing SPARQL, ensuring answers come from real Wikidata data rather than unreliable memorized knowledge. ## Core Features & Use Cases - Mandatory search-first workflow: Resolves entity names and property names to confirmed Q/P IDs with the wikidata_search tool before any SPARQL is written. - Domain-specific property sets: Ships reference files for cities, persons, organisations, creative works, and chemical compounds, each with the correct P31 types, recommended VALUES property lists, and known pitfalls. - Ready-made SPARQL patterns: Includes label lookup, substring search, class instance listing, multi-hop traversal, and qualifier-based full statement queries with auto-injected prefixes. - Use Case: Ask "When was Marie Curie born and what were her occupations?" and the Skill searches for her Q-number, loads the person domain file, and runs a query using P569 and P106 to return verified facts. ## Quick Start Ask the assistant to look up a real-world fact in Wikidata, for example: "Use Wikidata to find the population and country of Munich."

Frequently Asked Questions about sparql-query-wikidata

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I query Wikidata with SPARQL for facts about a person or city?▼

First resolve the entity name to its Q-number with the wikidata_search tool, then identify its type via P31, load the matching domain reference file, and write a SPARQL query using the recommended VALUES property set. Never guess Q or P numbers from memory.

How do I find the right Wikidata Q-number or property ID?▼

Use the wikidata_search tool with the entity or property label, for example wikidata_search(term="Marie Curie") returns Q7186 and wikidata_search(term="date of birth", type="property") returns P569. Searching first is mandatory because memorized IDs are unreliable.

Why does my Wikidata SPARQL query time out?▼

Wikidata enforces a 60-second query limit, so broad queries time out. Narrow them with specific wdt:P31 type values, always add LIMIT, and never use wdt:P131* path traversal to reach a parent region; use wdt:P17 for country instead.

How do I get labels in English instead of Q-numbers in results?▼

Use the wikibase:label service with bd:serviceParam wikibase:language "en" for fast label retrieval. If using rdfs:label directly, always add FILTER(LANG(?label) = "en") to avoid one row per language.

When should I use wdt: properties versus the p:/ps:/pq: statement model?▼

Use wdt:P<n> direct properties for simple current facts. Use the full p:/ps:/pq: statement model only when you need qualifiers such as start and end dates, ranks, or units, for example historical positions held or population with census year.