Wikidata and Wikidata API - bounswe/bounswe2024group6 GitHub Wiki

Definition

Wikidata is a free, collaborative, multilingual, secondary knowledge base, collecting structured data to provide support for Wikipedia, Wikimedia Commons, the other wikis of the Wikimedia movement, and to anyone in the world.

Being much stronger than its simple definition, Wikidata API gives access to all the data in Wikipedia and Wikimedia by simple queries.

Example GET Request

Modify the url parameter "search" as you wish.

curl 'https://www.wikidata.org/w/api.php?action=wbsearchentities&search=rabbits&format=json&language=en&uselang=en&type=item&limit=20'

Paste the response to this Online JSON Parser

Even though it can be tuned, below are the most useful url parameters.

  • search : The text to search for
  • type : Type of entity to search for - item (default), property etc.
  • limit : Number of entities to fetch
  • continue : Offset to search from (useful for paginating the response)

You can give it a try by just copying and modifying what you would like to search and examine the response.

SPARQL

It also has an API called Sparql.

In very simple terms, one writes a query which is similar to an SQL query, specify some constraints and receives the results accordingly. Using Wikidata Query Service, it is also possible to visualize the result in a location-based manner on the map.

Resources to delve deeper into Sparql:

Note that you can find code versions of your Sparql queries in several programming languages like Python, Java, Javascript and so forth by clicking </>Code button in Wikidata Query Service after making a successful query.