Jump to content

User:Alan Ang (WMDE)/How to: Wikidata/Not so Basics

From Meta, a Wikimedia project coordination wiki
Wikidata stamp SVG1.1
Wikidata stamp SVG1.1

Not-so Basics[edit]

After having a basic understanding of Wikidata, including how to create new items or make edits to existing items on Wikidata, you may wish to explore more about Wikidata. For example, how to access the data on Wikidata for your projects, or how to connect your catalog/ database with Wikidata.

Accessing Wikidata's Data[edit]

There are more than 10m items on Wikidata. If you would like to reuse Wikidata's data for your project, you have come to the right subsection. :)

Firstly, it makes sense to take a look at the Data Access page on Wikidata. On this page, you are presented with an overview of how to access Wikidata's data, and when to use which method. The different ways are:

  • search (Elasticsearch)
    • Use when:
      • You’re searching for a specific text string
      • You know the name of entities you’re looking for, not the exact entities themselves
      • You can filter your search based on some simple relations within the data
  • Linked Data Interface (URI)
    • Use when:
      • You want data on a smallish set of entities, especially RDF data
      • You already know the IDs of the entities you are interested in
      • You want each whole entity
  • Wikidata Query Service. This is Wikidata's own SPARQL endpoint. We will take a look at how to make queries on Wikidata's data using SPARQL in the following subsection.
    • Use when:
      • You don’t know the specific entities you’re interested in, but you know their characteristics
  • Linked Data Fragments (LDF) endpoint
    • Use when:
      • You’re looking for a list of entities based on triple patterns
      • Your result set is likely to be larger
      • You’re okay with doing computation of result sets on your side instead of the server
  • Wikibase REST API
  • MediaWiki Action API
    • Use when:
      • You need to edit Wikidata
      • You need JSON data of a batch of entities (up to 50 entities per request)
  • Recent Changes Stream
    • Use when:
      • You need to react to changes in real time
      • You want to keep up with everything happening on Wikidata (for example, to keep your own query service up to date)
  • Dumps
    • Use when:
      • You need data on a significant proportion of entities
      • You want to set up your own query service

If you are technically savvy, see also:

Querying Wikidata[edit]

With more than 10m items on Wikidata, it makes sense to be able to query the items and harness the results in whatever projects you may have. Wikidata uses SPARQL to query the data and here are some user friendly ways to help you get started on your SPARQL journey.

SPARQL is a language to formulate questions (queries) for knowledge databases. With the right database, a SPARQL query could answer questions like “what is the most popular tonality in music?” or “which character was portrayed by the most actors?” or “what’s the distribution of blood types?” or “which authors’ works entered the public domain this year?”.

Tools on Wikidata[edit]