Microproduct Data GuideIntermediate

Wikidata Query Service

CC0 structured knowledge-graph facts for building entity lookup, taxonomy, and reference-enrichment tools.

Report a Problem

At a Glance

Difficulty
Intermediate — some data preparation helps
Size
Tiny · ≤0.01 GB
Formats
JSON, CSV
Access
API
API Key
Not Required
Provider
Wikimedia Foundation
Updates
Continuous
Last Verified
Sep 27, 2026
Source Type
Community Source
  • Python Syntax Checked

From Source to Product Signal

Test a Product Idea in Four Steps

Wikidata SPARQL returns CC0 statements for entities and properties. Start with one class, one country, and a LIMIT. Send a descriptive User-Agent. Query results can be incomplete, contested, or delayed relative to the source that a statement cites.

1

Check the Setup

  • Python 3.10 or newer
  • A notebook environment such as Jupyter or Google Colab
  • An internet connection
2

Access the Data

  1. 1.Open the Query Service and read the CC0 licensing page.
  2. 2.Write a bounded SPARQL query with a LIMIT instead of selecting the whole graph.
  3. 3.Request JSON results with a descriptive User-Agent.
Open Official Source
3

Run the Python Example

Install the packages, then run the notebook cell.

python -m pip install pandas requests

import pandas as pd
import requests

query = """
SELECT ?item ?itemLabel WHERE {
  ?item wdt:P31 wd:Q515.
  ?item wdt:P17 wd:Q30.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
LIMIT 10
"""
response = requests.get(
    "https://query.wikidata.org/sparql",
    params={"query": query, "format": "json"},
    headers={
        "User-Agent": (
            "TrilemmaDataCatalogExample/1.0 "
            "(https://data.trilemma.foundation)"
        ),
        "Accept": "application/sparql-results+json",
    },
    timeout=30,
)
response.raise_for_status()
bindings = response.json()["results"]["bindings"]
cities = pd.json_normalize(bindings)
print(cities.head())
4

List a Handful of U.S. Cities from Wikidata

Test whether a bounded SPARQL query can seed a reference lookup table.

  1. 01Keep item IRI and English label for ten cities.
  2. 02Record missing labels instead of guessing names from other sources.
  3. 03Treat results as CC0 statements that still need a cited source before publication.

Dataset Details

Wikimedia Foundation is a community source. Last verified 2026-09-27. Temporal coverage: continuously updated Wikidata statements.

Geography

Formats

Provider

Wikimedia Foundation

Data Terms

Creative Commons CC0 1.0

Send Feedback