Jump to content
MediaWiki

API:文件档案

本頁使用了標題或全文手工轉換
From mediawiki.org
This page is a translated version of the page API:Filearchive and the translation is 100% complete.
本页是MediaWiki Action API帮助文档的一部分。
MediaWiki Action API
基础
认证
账号和用户
页面操作
搜索
开发员工具
教程
· ·
MediaWiki版本:
≥ 1.17

GET request依次枚举filearchive 表中所有已删除的文件。

API帮助文档

下列的文档是Special:ApiHelp/query+filearchive的输出,是由在本网站(MediaWiki.org)上面运行的MediaWiki的预发行版本所自动生成的。

list=filearchive (fa)

(main | query | filearchive)

Enumerate all deleted files sequentially.

Specific parameters:
Other general parameters are available.
fafrom

The image title to start enumerating from.

fato

The image title to stop enumerating at.

faprefix

Search for all image titles that begin with this value.

fadir

The direction in which to list.

One of the following values: ascending, descending
Default: ascending
fasha1

SHA1 hash of image. Overrides fasha1base36.

fasha1base36

SHA1 hash of image in base 36 (used in MediaWiki).

faprop

Which image information to get:

sha1
Adds SHA-1 hash for the image.
timestamp
Adds timestamp for the uploaded version.
user
Adds user who uploaded the image version.
size
Adds the size of the image in bytes and the height, width and page count (if applicable).
dimensions
Alias for size.
description
Adds description of the image version.
parseddescription
Parse the description of the version.
mime
Adds MIME of the image.
mediatype
Adds the media type of the image.
metadata
Lists Exif metadata for the version of the image.
bitdepth
Adds the bit depth of the version.
archivename
Adds the filename of the archive version for non-latest versions.
Values (separate with | or alternative): archivename, bitdepth, description, dimensions, mediatype, metadata, mime, parseddescription, sha1, size, timestamp, user
Default: timestamp
falimit

How many images to return in total.

Type: integer or max
The value must be between 1 and 500.
Default: 10
facontinue

When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.

Example:
Show a list of all deleted files.
api.php?action=query&list=filearchive [open in sandbox]

示例

GET请求

获取所有已删除文件的列表。

回应

{
"batchcomplete":"",
"continue":{
"facontinue":"0000007.jpg|20070128133944|288",
"continue":"-||"
},
"query":{
"filearchive":[
{
"id":1778,
"name":"!notedit.png",
"ns":6,
"title":"File:!notedit.png",
"timestamp":"2011年04月25日T13:17:47Z"
},
{
"id":6949,
"name":"\"Twilight_at_the_pond\"_by_A.A.Tutunov_(1976).jpg",
"ns":6,
"title":"File:\"Twilight at the pond\" by A.A.Tutunov (1976).jpg",
"timestamp":"2019年01月26日T11:48:52Z"
},
{
"id":5814,
"name":"---C--temp-Regelwerk.pdf",
"ns":6,
"title":"File:---C--temp-Regelwerk.pdf",
"timestamp":"2017年03月09日T10:09:24Z"
},
...
]
}
}

示例代码

Python

#!/usr/bin/python3
"""
 file_archive.py
 MediaWiki API Demos
 Demo of `Filearchive` module: Get a list of all deleted files.
 MIT License
"""
importrequests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
 "action": "query",
 "list": "filearchive",
 "format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)

PHP

<?php
/*
 file_archive.php
 MediaWiki API Demos
 Demo of `Filearchive` module: Get a list of all deleted files.
 MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
 "action" => "query",
 "list" => "filearchive",
 "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

/*
 file_archive.js
 MediaWiki API Demos
 Demo of `Filearchive` module: Get a list of all deleted files.
 MIT License
*/
varurl="https://en.wikipedia.org/w/api.php";
varparams={
action:"query",
list:"filearchive",
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){console.log(response);})
.catch(function(error){console.log(error);});

MediaWiki JS

/*
	file_archive.js
	MediaWiki API Demos
	Demo of `Filearchive` module: Get a list of all deleted files.
	MIT License
*/
varparams={
action:'query',
list:'filearchive',
format:'json'
},
api=newmw.Api();
api.get(params).done(function(data){
console.log(data);
});

可能的错误

代码 信息
cantview-deleted-description 您无权查看已删除文件的描述。
cantview-deleted-metadata 您无权查看已删除文件的元数据。
invalidsha1hash 提供的SHA1哈希无效。
invalidsha1base36hash 提供的SHA1Base36哈希无效。

参数历史

  • v1.20: 啟用facontinue, mediatype, archivename
  • v1.18: 啟用fato, fasha1, fasha1base36, parseddescription

AltStyle によって変換されたページ (->オリジナル) /