Search code examples
wikipedia-apimediawiki-api

MediaWiki API query for images for multiple titles


When I ask the MediaWiki API to provide images for each title, it just returns images for the first specified title. For example, the query:

http://en.wikipedia.org/w/api.php?format=jsonfm&action=query&titles=Id%20Software|Doom%203|Wolfenstein%203D|Quake%20II|John%20D.%20Carmack|John%20Romero|Doom%20(video%20game)|Quake%20(video%20game)|Commander%20Keen|Rage%20(video%20game)&prop=info|images

returns info for each page but images only for the first. Why?


Solution

  • Because it is just the first page of results, notice the query-continue at the bottom. To get the second page, you would need to repeat your query with the query-continue added (e.g. something like &imcontinue=15526|Doom_ingame_1.png).

    But a better solution would be to change the size of the page by adding &imlimit=max. In this case, this means all results fit into one page, but that won't be the case always.

    It might be better if you used some sort of library (depending on what language are you using), which could handle paging for you automatically.