wikipedia-apiwikimedia-commons

Get all images in a specific category in wikimedia


I am looking for an efficient way to get the all images in a specific category in wikimedia commons.

Example : https://commons.wikimedia.org/wiki/Commons:Quality_images

The following image is in the category above: https://commons.wikimedia.org/wiki/File:Gull_portrait_ca_usa.jpg

How can i get the links of all the images in that category ?

Ultimately i will use the image urls to query the api to get direct links for the original images.

https://en.wikipedia.org/w/api.php?action=query&titles=File:Gull_portrait_ca_usa.jpg&prop=imageinfo&iiprop=url&format=json

The images will be used in an ML dataset


Solution

  • Commons:Quality images is not a category, it's a page in the project namespace.

    If you want all the images contained in that page you can use the images API:

    https://commons.wikimedia.org/w/api.php?action=query&prop=images&titles=Commons:Quality%20images&imlimit=500&format=json&utf8