Get the Wikibase identifier of files resulting from a Wikimedia Commons search

74 Views Asked by At

I want to fetch the Wikibase identifier (an integer with a M prefix) of all files resulting from a Wikimedia Commons search.

Example: Searching for aburasoba azabujuban, the query should return (potentially among other results) M80618155, because it is the Wikibase identifier of Tantanmen.jpeg whose caption contains these two keywords.

Problem: The API call in the documentation does not return the Wikibase identifier, instead it only returns the title/URL/etc of each file.

Question: How can I modify this API call to retrieve the Wikibase identifiers? If possible without making another request for each result.

https://commons.wikimedia.org/w/api.php?action=query&format=json&formatversion=2&generator=search&gsrwhat=text&gsrnamespace=6&prop=imageinfo&iiprop=url|extmetadata&iiurlwidth=640&iiextmetadatafilter=DateTime|Categories|GPSLatitude|GPSLongitude|ImageDescription|DateTimeOriginal|Artist|LicenseShortName|LicenseUrl&gsrsearch=aburasoba%20Azabujuban&gsrlimit=10

1

There are 1 best solutions below

0
On

(Thanks to Multichill)

Your query returns the page id, prepend M to that and you have it:

enter image description here