4

I'm using wbsearchentities (wikidata api) in a python request and I'm wondering why returned results are not the same that those seen on Wikidata. For example, the following command in Python:

url = "https://www.wikidata.org/w/api.php?action=wbsearchentities&search=%s&format=json&limit=50&formatversion=2&language=en" % ('New York Landmarks Preservation Commission')
r = requests.post(url,headers={"User-Agent" : "Magic Browser"})

returns nothing but the same search in the search box of Wikidata returns 2 results (one is the good one: New York City Landmarks Preservation Commission.

Ideally, I would like to have all these results returned from my python request.

Patrick
  • 2,577
  • 6
  • 30
  • 53
  • What are you expecting to see? – Padraic Cunningham May 11 '16 at 22:36
  • Same results as those returned when you enter 'New York Landmarks Preservation Commission' in the Wikidata search box, in this case: New York City Landmark (Q19825927) and New York City Landmarks Preservation Commission (Q967276). – Patrick May 12 '16 at 17:47

1 Answers1

3

The search box in the top right of Wikidata uses the wbsearchentities API module to provide the auto suggestion dropdown search.

If you press enter after entering your search instead of clicking on one of the suggestions you will end up on the Special:Search page.

As you can see they API result returns no results but the special page does.

That is due to these searches working in entirely different ways.

  • The Special:Search page is a MediaWiki concept that Wikibase provides data to.
  • The wbsearchentities API module provided by Wikibase itself.
Addshore
  • 568
  • 3
  • 16
  • So there is no way to get the special:search results with an API? – Patrick May 16 '16 at 14:24
  • 2
    See action=query&list=search https://www.wikidata.org/w/api.php?action=query&list=search&srsearch=New%20York%20Landmarks%20Preservation%20Commission – Addshore May 19 '16 at 09:30