Wikidata API

Open Data / OAuth Advanced HTTPS
Varies by plan (check documentation)

Overview

Wikidata is a free, collaboratively edited knowledge base maintained by the Wikimedia Foundation that stores structured data behind Wikipedia and other Wikimedia projects. You can query its billions of facts using the SPARQL query language or the simpler Action API—read-only queries do not require authentication. It is the go-to source for structured, multilingual, open knowledge about people, places, events, and concepts.

💡

Beginner Tip

Start with the Wikidata Query Service (https://query.wikidata.org) to interactively build and test SPARQL queries before integrating them into your app—it provides autocomplete and instant results without any setup.

Available Data

Wikidata data via REST API
JSON-formatted response data
Requires OAuth authentication

Example Response

JSON Response
{
  "status": "success",
  "data": {
    "result": "Data from Wikidata",
    "description": "Collaboratively edited knowledge base operated by the Wikimedia Foundation",
    "timestamp": "2025-01-15T10:00:00Z"
  }
}

Field Reference

entities Map of entity IDs (e.g., Q42) to their full data objects.
entities[id].labels Human-readable names for the entity in multiple languages, keyed by language code.
entities[id].descriptions Short descriptions of the entity in multiple languages.
entities[id].claims Structured statements about the entity, organized by property ID (P-numbers).
entities[id].sitelinks Links to corresponding pages on Wikimedia sites like Wikipedia, keyed by wiki name.

Implementation Example

const url = "https://www.wikidata.org/w/";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "Authorization": "Bearer YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

SPARQL query timeout Query is too broad and scans too many triples, exceeding the 60-second limit.
Add LIMIT clauses (e.g., LIMIT 100) and use more specific filters on entity types or properties to narrow the search.
Unexpected entity structure in response Wikidata entities use numeric property IDs (P31, P279) rather than readable names.
Use the SPARQL endpoint with SERVICE wikibase:label to resolve labels automatically, or look up property IDs on wikidata.org.
403 or rate limiting on write operations Attempting to edit without OAuth authentication or exceeding anonymous request limits.
Register an OAuth app on Wikimedia, complete the auth flow, and include the access token for any write or high-volume read requests.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 5/20
🔒 Security 15/15
🛠 Developer XP 3/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth OAuth
HTTPS REQUIRED
CORS UNKNOWN
Category Open Data
Difficulty Advanced
Verified: 2026-04-04

Similar APIs

View All →