Topic on Project:Support desk

Fetch Only Images from API

2
Abhishek1491 (talkcontribs)

I am using API below

https://commons.wikimedia.org/w/api.php?action=query&generator=search&gsrnamespace=0%7C6&gsrsearch=Cocina+La+Ley&gsrlimit=10&prop=imageinfo&format=xml&gsroffset=0

If you browse through some pages you will notice pdf files.

I tried using filetype:bitmap parameter but in case of these API calls the order of images is not the same

Without bitmap parameter - https://commons.wikimedia.org/w/api.php?action=query&generator=search&gsrnamespace=0%7C6&gsrsearch=chase+%26+status&gsrlimit=10&prop=imageinfo&format=xml&gsroffset=0

With bitmap parameter - https://commons.wikimedia.org/w/api.php?action=query&generator=search&gsrnamespace=0%7C6&gsrsearch=chase+%26+status+filetype:bitmap&gsrlimit=10&prop=imageinfo&format=xml&gsroffset=0


As you can see in both API calls order of results is not same.

I want to fetch only png and jpg files from API and also maintain the order of relevance. If not in this API kindly let me know if there is similar API.


Thanks in advance

Ciencia Al Poder (talkcontribs)

It may not be possible to do that in the api at all... In that case, the best you can do is to filter the file type on client-slide

Reply to "Fetch Only Images from API"