API:Allrevisions
Appearance
Esta página es parte de la documentación de la API de acciones de MediaWiki. |
Versión de MediaWiki: | ≥ 1.27 |
Solicitud GET para listar todas las revisiones por un usuario o en un espacio de nombres.
API Documentación
Ejemplo
Solicitud GET
Obtenga una lista de todas las revisiones del usuario Place holder en la Wikipedia inglesa.
api.php? action=query& list=allrevisions& arvuser=Place%20holder& arvprop=ids|flags|timestamp [Prueba en ApiSandbox]
Respuesta
{
"batchcomplete": "",
"query": {
"allrevisions": [
{
"pageid": 36757881,
"revisions": [
{
"revid": 679803046,
"parentid": 656413943,
"timestamp": "2015-09-06T21:35:42Z"
},
{
"revid": 159361827,
"parentid": 0,
"timestamp": "2007-09-21T10:35:22Z"
}
],
"ns": 3,
"title": "User talk:Place holder"
}
...
]
}
}
Código de muestra
Python
#This file is auto-generated. See modules.json and autogenerator.py for details
#!/usr/bin/python3
"""
get_allrevisions.py
MediaWiki API Demos
Demo of `Allrevisions` module: get revision data of multiple pages and users
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"arvprop": "ids|flags|timestamp",
"arvuser": "Place holder",
"list": "allrevisions",
"format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
ALLREVISIONS = DATA["query"]["allrevisions"]
for rev in ALLREVISIONS:
print(rev)
PHP
<?php
//This file is autogenerated. See modules.json and autogenerator.py for details
/*
get_allrevisions.php
MediaWiki API Demos
Demo of `Allrevisions` module: get revision data of multiple pages and users
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"format" => "json",
"list" => "allrevisions",
"arvprop" => "ids|flags|timestamp",
"arvuser" => "Place holder"
];
$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"]["allrevisions"] as $k => $v ) {
foreach( $v["revisions"] as $k => $v ) {
var_dump( $v );
}
}
JavaScript
//This file is autogenerated. See modules.json and autogenerator.py for details
/*
get_allrevisions.js
MediaWiki API Demos
Demo of `Allrevisions` module: get revision data of multiple pages and users
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
format: "json",
list: "allrevisions",
arvprop: "ids|flags|timestamp",
arvuser: "Place holder"
};
url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
fetch(url)
.then(function(response){return response.json();})
.then(function(response) {
var revs = response.query.allrevisions;
for (var r in revs) {
console.log(revs[r]);
}
})
.catch(function(error){console.log(error);});
MediaWiki JS
// This file is autogenerated. See modules.json and autogenerator.py for details
/*
get_allrevisions.js
MediaWiki API Demos
Demo of `Allrevisions` module: get revision data of multiple pages and users
MIT License
*/
var params = {
action: 'query',
format: 'json',
list: 'allrevisions',
arvprop: 'ids|flags|timestamp',
arvuser: 'Place holder'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
var revs = data.query.allrevisions,
r;
for ( r in revs ) {
console.log( revs[ r ] );
}
} );
Avisos posibles
- Couldn't diff to r######: content is hidden.
- Thrown when the revision has been hidden (e.g., using RevisionDelete or Oversight).
- prop=parsetree solo es compatible con el contenido en wikitexto. title usa el modelo de contenido content model.
- Thrown when the
parsetree
property orgeneratexml
parameter is used and the content model (as returned by thecontent
property) is not set towikitext
- Thrown when the
- La expansión de plantillas solo es compatible con el contenido en wikitexto. title usa el modelo de contenido content model.
- Thrown when the
expandtemplates
parameter is used and the content model (as returned by thecontent
property) is not set towikitext
- Thrown when the
- El formato solicitado contentFormat no es compatible con el modelo de contenido model utilizado por name.
- Thrown when the content of either the current revision or one being diffed to is not supported (typically, not text).
Errores posibles
Code | Info |
---|---|
arvdiffto | arvdiffto debe fijarse a un número no negativo, prev, next or cur. |
arvnosuchrevid | No hay ninguna revisión con identificador ID. |
arvnosuchsection | No hay ninguna sección section en ID. |
Historial de parámetros
- v1.26: Obsoleto
arvgeneratexml
- v1.27: Introducido
arvdifftotextpst
- v1.30: Obsoleto
parsetree
,arvparse
,arvexpandtemplates
,arvdiffto
,arvdifftotext
,arvdifftotextpst
Vea también
- API:Revisions - obtener información de revisión de página(s)
- API:Revisiondelete - Elimina y recupera revisiones.