mediawiki-utilities / python-mwapi

Simple Python Wrapper around MediaWiki API
http://pythonhosted.org/mwapi
MIT License
31 stars 11 forks source link

differant result struckture, mwapi vs mw-api-sandbox, ? (solved) #36

Closed MvGulik closed 5 years ago

MvGulik commented 5 years ago

Never really spotted, or realized this before. (although there has been some nagging feeling about mwapi's result output from time to time)

When pulling some imageinfo data with the MW API-sandbox I got:

{ "query": { "pages": { "2601": { <imageinfo-datablock> }, ...  }  }  }

But when I use mwapi I get:

{ "query": { "pages": [ { <imageinfo-datablock> }, ...  ]  } }

The page-id and its containing dictionary are gone, replaced by a list containing the per-page imageinfo-datablock's

??? Should the output on both calls not be the same in structure ? Is there any additional reading material on this ?

Os: Linux, ... Python: 3.5.x MWapi: 0.5.1 (MediaWiki: 1.31.0)

(not checked against other mw-queries - yet) (not re-checked mwapi docs - yet)

lucaswerkmeister commented 5 years ago

The first output is the result of JSON format version 1, which is the default, whereas the second output is the result of JSON format version 2. You’re probably sending a formatversion=2 parameter with your mwapi request, but didn’t set it in the API sandbox (it’s under the format=json “tab”).

MvGulik commented 5 years ago

Darn, formatversion never entered my mind. :-/

Your right, I was using different formatversions on the different calls. Thanks.

(Closing)