Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active April 12, 2019 20:59
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edsu/dd92a2964e95782ce675 to your computer and use it in GitHub Desktop.
Save edsu/dd92a2964e95782ce675 to your computer and use it in GitHub Desktop.
Here's an example of the API call that WikiData's search box uses for suggesting entities. The suggestion is based on the text "ch" in the search URL query parameter.
curl --silent 'https://www.wikidata.org/w/api.php?action=wbsearchentities&search=ch&format=json&language=en&type=item&continue=0' | python -m json.tool
{
"search": [
{
"aliases": [
"encyclopaedia",
"encyclop\u00e6dia"
],
"description": "type of reference work",
"id": "Q5292",
"label": "encyclopedia",
"url": "//www.wikidata.org/wiki/Q5292"
},
{
"aliases": [
"Encyclopaedia Brittanica",
"Encyclopedia Britannica"
],
"description": "general knowledge English-language encyclopaedia, first published in Scotland in 1768",
"id": "Q455",
"label": "Encyclop\u00e6dia Britannica",
"url": "//www.wikidata.org/wiki/Q455"
},
{
"description": "Wikipedia disambiguation page",
"id": "Q1340122",
"label": "Encyclopaedia",
"url": "//www.wikidata.org/wiki/Q1340122"
},
{
"aliases": [
"Encyclop\u00e9die, ou dictionnaire raisonn\u00e9 des sciences, des arts et des m\u00e9tiers"
],
"description": "general encyclopedia published in France between 1751 and 1772",
"id": "Q447",
"label": "Encyclop\u00e9die",
"url": "//www.wikidata.org/wiki/Q447"
},
{
"description": "a letter, usually treating some aspect of Catholic doctrine, sent by the Pope and addressed to the Catholic bishops",
"id": "Q221409",
"label": "encyclical",
"url": "//www.wikidata.org/wiki/Q221409"
},
{
"description": "free, online collaborative encyclopedia intended to document all of the 1.9 million living species known to science",
"id": "Q82486",
"label": "Encyclopedia of Life",
"url": "//www.wikidata.org/wiki/Q82486"
},
{
"id": "Q938726",
"label": "Encyclopaedia Metallum",
"url": "//www.wikidata.org/wiki/Q938726"
}
],
"search-continue": 7,
"searchinfo": {
"search": "encyc"
},
"success": 1
}
@alessandrobenedetti
Copy link

Hey mate,
what about the API request when we click search ?
The full text search in the knowledge base ?
I am struggling to do that in a programmatic way!

Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment