User:Liz Kariuki/Sandbox/API:Filearchive
This page is part of the MediaWiki Action API documentation. |
MediaWiki version: | ≥ 1.23 |
Enumerate all deleted files from filearchive table sequentially.
API documentation[edit]
list=filearchive (fa)
Enumerate all deleted files sequentially. Specific parameters: Other general parameters are available.
Example:
|
Example[edit]
GET request[edit]
Show a list of 3 deleted files arranged in descending order.
Response[edit]
{
"batchcomplete": "",
"continue": {
"facontinue": "~mountain_path~.png|20060610182425|24930",
"continue": "-||"
},
"query": {
"filearchive": [
{
"id": 423165,
"name": "Invivogenlogo.jpg",
"ns": 6,
"title": "File:Invivogenlogo.jpg",
"timestamp": "2007-03-30T23:20:54Z"
},
{
"id": 24929,
"name": "~universe~.png",
"ns": 6,
"title": "File:~universe~.png",
"timestamp": "2006-06-10T18:26:01Z"
},
{
"id": 24928,
"name": "~universe~.png",
"ns": 6,
"title": "File:~universe~.png",
"timestamp": "2006-06-10T18:21:40Z"
}
]
}
}
Sample code[edit]
Python[edit]
#!/usr/bin/python3
"""
filearchive.py
MediaWiki API Demos
Enumerate 3 deleted files from filearchive table in descending order.
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"falimit": "3",
"list": "filearchive",
"fadir": "descending",
"format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)
PHP[edit]
<?php
/*
filearchive.php
MediaWiki API Demos
Enumerate 3 deleted files from filearchive table in descending order.
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"falimit" => "3",
"list" => "filearchive",
"fadir" => "descending",
"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 );
var_dump( $result );
Javascript[edit]
/*
filearchive.js
MediaWiki API Demos
Enumerate 3 deleted files from filearchive table in descending order.
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
falimit: "3",
list: "filearchive",
fadir: "descending",
format: "json"
};
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 |
---|---|
permissiondenied | You don't have permission to view metadata of deleted files. |
Additional notes[edit]
- This module cannot be used as a Generator .
See also[edit]
- API:Filerevert - Revert a file to an older version