---
name: wikidata-query-service-ingestion
description: "How to get Wikimedia Wikidata Query Service data into a pandas DataFrame and Parquet: access, the request, the format, limits, quirks and terms."
---

# Query Wikidata SPARQL into pandas and Parquet

Source entry: https://signal-lab-jet.vercel.app/datasets/wikidata-query-service
Provider: https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service
Checked against the provider's documentation: 2026-11-02

## Access
- No account or key. Send a descriptive User-Agent and use the public SPARQL endpoint.
- JSON is selected with format=json or the application/sparql-results+json Accept header.

## Request
```bash
curl --get 'https://query.wikidata.org/sparql' -H 'User-Agent: SignalLabCheck/1.0 (https://signal-lab-jet.vercel.app)' --data-urlencode 'query=SELECT ?item ?itemLabel WHERE { VALUES ?item { wd:Q16 wd:Q30 wd:Q145 } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } }' --data 'format=json'
```

## Format
SPARQL Results JSON with head.vars and results.bindings. Each binding describes a value's type, value and optional language or datatype.

## Load into pandas and Parquet
Needs Python 3 with requests, pandas and pyarrow.
```python
"""Three Wikidata entities from WDQS -> pandas -> Parquet."""
import requests
import pandas as pd

URL = "https://query.wikidata.org/sparql"
QUERY = """
SELECT ?item ?itemLabel WHERE {
  VALUES ?item { wd:Q16 wd:Q30 wd:Q145 }
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
"""
headers = {"User-Agent": "SignalLabCheck/1.0 (https://signal-lab-jet.vercel.app)"}
r = requests.get(URL, params={"query": QUERY, "format": "json"}, headers=headers, timeout=60)
r.raise_for_status()
bindings = r.json()["results"]["bindings"]
df = pd.DataFrame([{k: v.get("value") for k, v in row.items()} for row in bindings])
df.to_parquet("wikidata_query_sample.parquet", index=False)
print(len(df), "entities; labels:", ", ".join(sorted(df["itemLabel"])))
```
Run by us on 2026-11-02 (python 3.13.5 | pandas 3.1.0 | pyarrow 26.0.0 | requests 2.34.2). Result: 3 entities; labels: Canada, United Kingdom, United States

## Limits
- Query timeout: 60 seconds.
- Processing allowance: 60 seconds per 60 seconds for one user-agent-and-IP client.
- Error allowance: 30 erroneous queries per minute; clients exceeding limits are throttled.

## Quirks
- Flatten each SPARQL binding's nested value object before constructing a table.
- The query-service dataset does not exactly match the RDF dump, and asynchronous updates introduce lag.
- The main and scholarly graphs are split across separate public endpoints; choose the graph that matches the topic.

## Terms and attribution
- Wikidata structured data in the main data namespaces is dedicated under CC0 1.0.
- Text outside the structured-data namespaces is available under CC BY-SA and may have additional terms.
- Follow Wikimedia's User-Agent, robot and API etiquette policies when automating requests.
- Terms page: https://www.wikidata.org/wiki/Wikidata:Copyright

## Sources
- https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service: "Run, test, download the data as XML, JSON, CSV, or TSV."
- https://www.mediawiki.org/wiki/Wikidata_Query_Service/Implementation: "Query timeout of 60 seconds"
- https://www.mediawiki.org/wiki/Wikidata_Query_Service/Implementation: "One client (user agent + IP) is allowed 60 seconds of processing time each 60 seconds"
- https://www.wikidata.org/wiki/Wikidata:Copyright: "Creative Commons CC0 License"

## Help improve this skill
Missing a source, or see something to improve? Call the MCP tool suggest_source or feedback (or POST /api/suggest or /api/feedback). Reviewed ideas: https://signal-lab-jet.vercel.app/agent-suggestions

Information for educational purposes only. Free tiers, limits and licenses belong to the providers and may change; check the provider's own terms before using the data.
