API talk:Imageinfo

From MediaWiki.org
Jump to: navigation, search

Documentation on results format???[edit]

Is there any documentation on how to interpret the results of this query? The deeply nested JSON that results is rather opaque. More generally, the query side of the API seems well-documented, but there seems to be very little description of what comes back. Am I missing something? Thanks. Johndburger (talk) 01:46, 24 August 2015 (UTC)

No, unfortunately, you're not missing anything. Because many of the queries are fairly obvious when it comes to results, there's been no particular pressure to document things. When it comes to the larger structures like this or API:Siteinfo, it can be problematic. I've started to add results when I have time, but haven't documented ImageInfo yet. I've done a lot of work on it for a bot that I'm (very slowly) working on, so if you have any questions, I'll be happy to help if I can. By and large, only the metadata-related stuff has really deep nesting, and as much of it doesn't come directly from MediaWiki, its structure is pretty arbitrary. I believe MW tries to standardize the extmetadata output into a single, unnested collection, but the other two contain more info, as I recall. Anything else you need to know? Robin Hood  (talk) 02:12, 24 August 2015 (UTC)
Oops, just saw this. I'm just curious about some of the nesting. For instance, in the last example on this page, why is "pages" a dictionary with a single key, usually (but not always) -1? Thanks for your reply. Johndburger (talk) 03:27, 17 September 2015 (UTC)
"Pages" is generally a dictionary with the page id being the key, and the various page data as the value. For pages that don't exist, or where there's some other problem with them that they don't have an id, they're assigned a sequential negative number to act as a unique id. In this case, I believe the file actually comes from Commons, so doesn't really exist on WP, even though it might look that way when you use the regular UI. Robin Hood  (talk) 03:42, 17 September 2015 (UTC)
Ah, so in general there might be multiple pages, and then multiple versions. That explains a lot of the nesting, thanks! Johndburger (talk) 00:12, 18 September 2015 (UTC)


Does the timestamp info shows the last update/revision of the imagefile or of the wiki text? If the info is related to changes of wikitext, is it possible to gain information of last revision of image itself? This would be important for third party use (to update image cache on demand). --Arch2all (talk) 08:56, 31 October 2015 (UTC)

The timestamp from this module gives you the last image revision. The last revision of the page would be from the Revisions module. See, for example, the following:
Robin Hood  (talk) 01:55, 1 November 2015 (UTC)
Thanks for the helpful answer! --Arch2all (talk) 15:35, 1 November 2015 (UTC)


Hi! I use MediaWiki 1.20.2 and face the problem. Query which contains property "imageinfo" (for example action=query&titles=File:MyFile&prop=imageinfo) always returns the next error message:

<?xml version="1.0"?>
 <error code="internal_api_error_MWException" info="Exception Caught: Internal error in ApiResult::setElement: Bad parameter" xml:space="preserve" />

Could you please help me to fix this issue? Źmicier Dzikański (talk) 23:47, 16 April 2016 (UTC)