The following documentation is the output of Special:ApiHelp/query+revisions, automatically generated by the pre-release version of MediaWiki that is running on this site (MediaWiki.org).
Which revision slots to return data for, when slot-related properties are included in rvprops. If omitted, data from the main slot will be returned in a backwards-compatible format.
Use action=compare instead. Revision ID to diff each revision to. Use prev, next and cur for the previous, next and current revision respectively.
rvdifftotext
Deprecated.
Use action=compare instead. Text to diff each revision to. Only diffs a limited number of revisions. Overrides rvdiffto. If rvsection is set, only that section will be diffed against this text.
rvdifftotextpst
Deprecated.
Use action=compare instead. Perform a pre-save transform on the text before diffing it. Only valid when used with rvdifftotext.
{"batchcomplete":true,"query":{"pages":[{"pageid":1423,"ns":0,"title":"Main Page","revisions":[{"user":"Bdk","timestamp":"2005-09-16T01:14:43Z","comment":"Reverted edit of 82.36.210.14, changed back to last version by Brion VIBBER"}]},{"pageid":55332,"ns":0,"title":"API","revisions":[{"user":"Mainframe98","timestamp":"2017-08-19T18:23:42Z","comment":"Reverted edits by [[Special:Contributions/Sankaran kumar|Sankaran kumar]] ([[User talk:Sankaran kumar|talk]]) to last revision by [[User:Shirayuki|Shirayuki]]"}]}]}}
#!/usr/bin/python3""" get_pages_revisions.py MediaWiki API Demos Demo of `Revisions` module: Get revision data with content for pages with titles [[API]] and [[Main Page]] MIT License"""importrequestsS=requests.Session()URL="https://www.mediawiki.org/w/api.php"PARAMS={"action":"query","prop":"revisions","titles":"API|Main Page","rvprop":"timestamp|user|comment|content","rvslots":"main","formatversion":"2","format":"json"}R=S.get(url=URL,params=PARAMS)DATA=R.json()PAGES=DATA["query"]["pages"]forpageinPAGES:print(page["revisions"])
<?php/* get_pages_revisions.php MediaWiki API Demos Demo of `Revisions` module: Get revision data with content for pages with titles [[API]] and [[Main Page]] MIT License*/$endPoint="https://www.mediawiki.org/w/api.php";$params=["action"=>"query","prop"=>"revisions","titles"=>"API|Main Page","rvprop"=>"timestamp|user|comment|content","rvslots"=>"main","formatversion"=>"2","format"=>"json"];$url=$endPoint."?".http_build_query($params);$ch=curl_init($url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);$output=curl_exec($ch);curl_close($ch);$result=json_decode($output,true);foreach($result["query"]["pages"]as$k=>$v){var_dump($v["revisions"]);}
/* get_pages_revisions.js MediaWiki API Demos Demo of `Revisions` module: Get revision data with content for pages with titles [[API]] and [[Main Page]] MIT License*/varurl="https://www.mediawiki.org/w/api.php";varparams={action:"query",prop:"revisions",titles:"API|Main Page",rvprop:"timestamp|user|comment|content",rvslots:"main",formatversion:"2",format:"json"};url=url+"?origin=*";Object.keys(params).forEach(function(key){url+="&"+key+"="+params[key];});fetch(url).then(function(response){returnresponse.json();}).then(function(response){varpages=response.query.pages;for(varpinpages){console.log(pages[p].revisions);}}).catch(function(error){console.log(error);});
/* get_pages_revisions.js MediaWiki API Demos Demo of `Revisions` module: Get revision data with content for pages with titles [[API]] and [[Main Page]] MIT License*/varparams={action:'query',prop:'revisions',titles:'API|Main Page',rvprop:'timestamp|user|comment|content',rvslots:'main',formatversion:'2',format:'json'},api=newmw.Api();api.get(params).done(function(data){varpages=data.query.pages,p;for(pinpages){console.log(pages[p].revisions);}});
Example 2: Get last five revisions of a page filtered by date and user[edit]
Request above is to obtain data for the last five revisions of the page API:Geosearch made after the 1st of July 2018, i.e. 2018-07-01 excluding changes made by the user SSethi (WMF)
#!/usr/bin/python3""" get_filtered_page_revisions.py MediaWiki API Demos Demo of `Revisions` module: Get data including content of last 5 revisions of the title [[API:Geosearch]] made after the 1st of July 2018 i.e 2018-07-01 excluding changes made by the user SSethi (WMF) MIT License"""importrequestsS=requests.Session()URL="https://www.mediawiki.org/w/api.php"PARAMS={"action":"query","prop":"revisions","titles":"API:Geosearch","rvlimit":"5","rvprop":"timestamp|user|comment|content","rvdir":"newer","rvstart":"2018-07-01T00:00:00Z","rvexcludeuser":"SSethi (WMF)","rvslots":"main","formatversion":"2","format":"json"}R=S.get(url=URL,params=PARAMS)DATA=R.json()PAGES=DATA["query"]["pages"]forpageinPAGES:print(page["revisions"])
<?php/* get_filtered_page_revisions.php MediaWiki API Demos Demo of `Revisions` module: Get data including content of last 5 revisions of the title [[API:Geosearch]] made after July 1st 2018 excluding changes made by the user SSethi (WMF) MIT License*/$endPoint="https://www.mediawiki.org/w/api.php";$params=["action"=>"query","prop"=>"revisions","titles"=>"API:Geosearch","rvlimit"=>"5","rvprop"=>"timestamp|user|comment|content","rvdir"=>"newer","rvstart"=>"2018-07-01T00:00:00Z","rvexcludeuser"=>"SSethi (WMF)","rvslots"=>"main","formatversion"=>"2","format"=>"json"];$url=$endPoint."?".http_build_query($params);$ch=curl_init($url);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);$output=curl_exec($ch);curl_close($ch);$result=json_decode($output,true);foreach($result["query"]["pages"]as$k=>$v){var_dump($v["revisions"]);}
/* get_filtered_page_revisions.js MediaWiki API Demos Demo of `Revisions` module: Get data including content of last 5 revisions of the title [[API:Geosearch]] made after July 1st 2018 excluding changes made by the user SSethi (WMF) MIT License*/varurl="https://www.mediawiki.org/w/api.php";varparams={action:"query",prop:"revisions",titles:"API:Geosearch",rvlimit:"5",rvprop:"timestamp|user|comment|content",rvdir:"newer",rvstart:"2018-07-01T00:00:00Z",rvexcludeuser:"SSethi (WMF)",rvslots:"main",formatversion:"2",format:"json"};url=url+"?origin=*";Object.keys(params).forEach(function(key){url+="&"+key+"="+params[key];});fetch(url).then(function(response){returnresponse.json();}).then(function(response){varpages=response.query.pages;for(varpinpages){console.log(pages[p].revisions);}}).catch(function(error){console.log(error);});
/* get_filtered_page_revisions.js MediaWiki API Demos Demo of `Revisions` module: Get data including content of last 5 revisions of the title [[API:Geosearch]] made after July 1st 2018 excluding changes made by the user SSethi (WMF) MIT License*/varparams={action:'query',prop:'revisions',titles:'API:Geosearch',rvlimit:'5',rvprop:'timestamp|user|comment|content',rvdir:'newer',rvstart:'2018-07-01T00:00:00Z',rvexcludeuser:'SSethi (WMF)',rvslots:'main',formatversion:'2',format:'json'},api=newmw.Api();api.get(params).done(function(data){varpages=data.query.pages,p;for(pinpages){console.log(pages[p].revisions);}});
Example 3: Get last revision of a page, following any redirects[edit]
rvdiffto must be set to "prev", "next", "cur" or a non-negative number.
rvnosuchrevid
There is no revision with ID ID
rvnosuchsection
There is no section section in rID
rvrevids
The revids= parameter may not be used with the list options (limit, startid, endid, dirNewer, start, end).
rvmultpages
titles, pageids or a generator was used to supply multiple pages, but the limit, startid, endid, dirNewer, user, excludeuser, start and end parameters may only be used on a single page.
rvaccessdenied
The current user is not allowed to read title
rvbadparams
start and startid cannot be used together
rvbadparams
end and endid cannot be used together
rvbadparams
user and excludeuser cannot be used together
invalidparammix
titles, pageids or a generator was used to supply multiple pages, but the rvlimit, rvstartid, rvendid, rvdir=newer, rvuser, rvexcludeuser, rvstart, and rvend parameters may only be used on a single page.