Which service is the fastest that can return when a QID is valid ?
OpenRefine is trying to improve its reconciling when folks already have lists of QID's and just want to ensure they are still valid and exist. https://github.com/OpenRefine/OpenRefine/issues/1596
-Thad
If you have the luxury of access to the replica servers (which is the case for the reconciliation service, right?), then I doubt any API is going to beat a raw SQL query:
$ sql wikidata 'SELECT page_title FROM page WHERE page_namespace = 0 AND page_title IN ("Q12345", "Q123456", "Q1234567")' +------------+ | page_title | +------------+ | Q12345 | | Q123456 | +------------+
This shows that Q1234567 doesn’t exist. (Someone with more SQL knowledge could probably turn that into a “yes/no” kind of reply, too.)
Cheers, Lucas
On 15.05.2018 17:49, Thad Guidry wrote:
Which service is the fastest that can return when a QID is valid ?
OpenRefine is trying to improve its reconciling when folks already have lists of QID's and just want to ensure they are still valid and exist. https://github.com/OpenRefine/OpenRefine/issues/1596
-Thad
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
You can do this via the API, e.g.:
https://www.wikidata.org/w/api.php?action=query&prop=&format=json&am...
Note that this uses QIDs directy as page titles. This works on wikidata, but may not work on all wikibase instances. It also does not work for PIDs: for these, you have to prefix the Property namespace, as in Property:P31.
A more wikibase way would be to use the wbgetentities API, as in https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q42%7CQ64&am...
However, this API fails when you proivde a non-existing ID, without providing any information about other IDs. So you can quickly check if all the IDs you have are ok, but you may need several calls to get a list of all the bad IDs.
That's rather annoying for your use case. Feel free to file a ticket on phabricator.wikimedia.org. Use the wikidata tag. Tahnks!
-- daniel
For a single QID does it make sense to use a HTTP HEAD request against the item page? I assume it would perform well on the client at least.
Cheers // Albin Larsson User:Abbe98
2018-05-15 20:05 GMT+02:00 Daniel Kinzler daniel.kinzler@wikimedia.de:
You can do this via the API, e.g.:
https://www.wikidata.org/w/api.php?action=query&prop=& format=json&titles=Q1|Qx|Q10000003|Q66666666666666&redirects=1
Note that this uses QIDs directy as page titles. This works on wikidata, but may not work on all wikibase instances. It also does not work for PIDs: for these, you have to prefix the Property namespace, as in Property:P31.
A more wikibase way would be to use the wbgetentities API, as in https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q42%7CQ64&am...
However, this API fails when you proivde a non-existing ID, without providing any information about other IDs. So you can quickly check if all the IDs you have are ok, but you may need several calls to get a list of all the bad IDs.
That's rather annoying for your use case. Feel free to file a ticket on phabricator.wikimedia.org. Use the wikidata tag. Tahnks!
-- daniel
Wikidata-tech mailing list Wikidata-tech@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikidata-tech
wikidata-tech@lists.wikimedia.org