Skip to content

Instantly share code, notes, and snippets.

@ettorerizza
Created March 7, 2019 13:08
Show Gist options
  • Select an option

  • Save ettorerizza/cc3eb1cda5fa88c9bc938720bc18601a to your computer and use it in GitHub Desktop.

Select an option

Save ettorerizza/cc3eb1cda5fa88c9bc938720bc18601a to your computer and use it in GitHub Desktop.
Search the Wikidata API like in the website searchbar
import requests
api = "https://www.wikidata.org/w/api.php"
query = "some search"
params = {
'action': 'query',
'list': 'search',
'format': 'json',
'srsearch': query,
'srprop': 'titlesnippet|snippet',
'srlimit': 100
}
r = requests.get(api, params=params)
print(r.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment