User:VanesaPerea/Sandbox/API:Deletedrevisions
This page is part of the MediaWiki Action API documentation. |
MediaWiki version: | ≥ 1.23 |
API documentation[edit]
list=deletedrevs (dr)
List deleted revisions. Operates in three modes:
Certain parameters only apply to some modes and are ignored in others. Specific parameters: Other general parameters are available.
Examples:
|
Example[edit]
GET request[edit]
Get a list of deleted revisions for Talk:Main Page.
Response[edit]
{
"warnings":
{"main":{"
*":"Unrecognized parameter: drv."}},
"batchcomplete":"",
"query":
{"pages":
{"-1":
{"ns":1,
"title":"Talk:Main Page",
"missing":"",
"deletedrevisions":
[
{
"revid":18588,
"parentid":0,
"user":"Bugambilia",
"timestamp":"2018-09-16T12:03:00Z",
"comment":"Created page with \"Hello everyone.\""},
{
"revid":16337,
"parentid":0,
"user":"31.31.98.23",
"anon":"",
"timestamp":"2017-09-25T22:17:24Z",
"comment":"\u0416\u0435\u043d\u0430 \u041a\u043e\u0437\u043b\u0435\u0432\u0438\u0447\u0430"},
{
"revid":15676,
"parentid":0,
"user":"107.178.41.5",
"anon":"",
"timestamp":"2017-07-21T18:37:00Z",
"comment":"Created page with \"<big><big><big>BBBBBBBBBBWWWWWWWWWWWWAAAAAAAAAAAHHHHHHHHHHHHH</big></big></big>\""},
{
"revid":15431,
"parentid":14827,
"user":"83.24.18.86",
"anon":"",
"timestamp":"2017-06-11T18:37:42Z",
"comment":""},
{
"revid":14827,
"parentid":0,
"user":"Xauroflaux",
"timestamp":"2017-04-09T01:43:39Z",
"comment":"Created blank page"},
{
"revid":14816,
"parentid":0,
"userhidden":"",
"user":"Butt cheeks",
"timestamp":"2017-04-08T19:58:54Z",
"commenthidden":"",
"comment":"Created page with \"Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt cheeks Butt ch...\""}]}}}}
Sample code[edit]
Python[edit]
"""
get_deleted_revs.py
MediaWiki Action API Code Samples
Demo of `Deleted Revisions:Get a list of deleted revision for Talk:Main Page` module
MIT license
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
'action':"query",
'format':"json",
'titles':"Talk:MainPage",
'prop':"deletedrevisions",
'drv':"prop"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)
PHP[edit]
<?php
/*
get_deleted_revs.php
MediaWiki API Demos
Demo of `Deleted revisions:Get a list of deleted revision for Talk:Main Page` module
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"format" => "json",
"titles" => "Talk:MainPage",
"prop" => "deletedrevisions",
"drv" => "prop"
];
$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 );
echo( $result );
Javascript[edit]
/*
get_deleted_revs.js
MediaWiki API Demos
Demo of `Deleted revisions:Get a list of deleted revision for Talk:Main Page` module
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
format: "json",
titles: "Talk:MainPage",
prop: "deletedrevisions",
drv: "prop"
};
url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
fetch(url)
.then(function(response){return response.json();})
.then(function(response) {
console.log(response);
})
.catch(function(error){console.log(error);});
Possible errors[edit]
Code | Info |
---|---|
drvdiffto | drvdiffto must be set to a non-negative number, "prev", "next" or "cur" |
drvnosuchrevid | There is no revision with ID ID |
drvnosuchsection | There is no section section in rID |
drvpermissiondenied | You don't have permission to view deleted revision information |
adrpermissiondenied | You don't have permission to view deleted revision content |
drvbadparams | user and excludeuser cannot be used together |
Parameter history[edit]
- v1.32: Deprecated
drvcontentformat
- v1.30: Deprecated
rvdifftotext
,rvdifftotextpst
,rvdiffto
,rvexpandtemplates
,rvparse
andrvprop=parsetree
Additional notes[edit]
- This module can be used as a generator.
- This module lists revisions that have been deleted from a page, as you would see in Special:Undelete. It should not be confused with revisions that have been hidden via the Revision Delete feature.