Hi,
I'm looking for a way to reproduce the autocomplete on wikidata search field in an external app (to tag resources with wikidata entities ids), but so far I couldn't find what could allow me to do this in the API doc. In a little experiment https://github.com/maxlath/wikidata-autocomplete, I tried to use the API action /wbsearchentities/, but it appear to be inefficient until I reach the full name... Is there already a way to query such an "autocomplete API" or any plans to implement one? Or even better, is there a way to easily re-use the wikidata search field widget? in a non-PHP project? :D
Any clue welcome :)
Best regards,
Max
Hi,
the autocomplete box is using the wbsearchentities api. You could try to copy the jquery.wikibase.entityselector.js from wikibase/lib/resources/jquery.wikibase it looks like it works independently from wikibase. It needs the jqueryui suggester.
best regards,
Christian
2014-04-28 18:40 GMT+02:00 Maxime Lathuilière groups@maxlath.eu:
Hi,
I'm looking for a way to reproduce the autocomplete on wikidata search field in an external app (to tag resources with wikidata entities ids), but so far I couldn't find what could allow me to do this in the API doc. In a little experiment https://github.com/maxlath/wikidata-autocomplete, I tried to use the API action *wbsearchentities*, but it appear to be inefficient until I reach the full name... Is there already a way to query such an "autocomplete API" or any plans to implement one? Or even better, is there a way to easily re-use the wikidata search field widget? in a non-PHP project? :D
Any clue welcome :)
Best regards,
Max
--
Maxime Lathuilière maxlath.eu @maxlath Zorglub27 https://www.wikidata.org/wiki/User:Zorglub27 Contributionshttps://www.wikidata.org/wiki/Special:Contributions/Zorglub27
Wikidata-l mailing list Wikidata-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-l
Hi Maxime,
After some quick reverse engineering of the site with the Chrome Developer Tools, here's the API it is using:
http://www.wikidata.org/w/api.php ?callback=[YOUR CALLBACK NAME] &action=wbsearchentities &format=json &language=en &type=item &continue=0 &_=[TIMESTAMP (as a cache buster)] &search=[YOUR QUERY]
If you don't need the callback, then the API is as follows (note the missing cache buster):
http://www.wikidata.org/w/api.php &action=wbsearchentities &format=json &language=en &type=item &continue=0 &search=[YOUR QUERY]
Hope this helps.
Best, Tom
Small correction:
If you don't need the callback, then the API is as follows (note the missing cache buster):
http://www.wikidata.org/w/api.php &action=wbsearchentities
?action=wbsearchentities (replace '&' with '?', copy and paste oversight, sorry).