API:Duplicatefiles
This page is part of the MediaWiki Action API documentation. |
GET request to get a list of duplicates of the given file.
MediaWiki version: | ≥ 1.14 |
API documentation
Example
GET request
List duplicates of two images.
api.php? action=query& titles=Image:1995.jpg|Image:Welcome.gif& prop=duplicatefiles [try in ApiSandbox]
Response
{
"batchcomplete": "",
"query": {
"normalized": [
{
"from": "Image:1995.jpg",
"to": "File:1995.jpg"
},
{
"from": "Image:Welcome.gif",
"to": "File:Welcome.gif"
}
]
...
}
}
}
}
Sample code
Python
#!/usr/bin/python3
"""
duplicate_files.py
MediaWiki API Demos
Demo of `Duplicatefiles` module: List duplicates of the given files.
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"titles": "Image:1995.jpg|Image:Welcome.gif",
"prop": "duplicatefiles",
"format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)
PHP
<?php
/*
duplicate_files.php
MediaWiki API Demos
Demo of `Duplicatefiles` module: List duplicates of the given files.
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"titles" => "Image:1995.jpg|Image:Welcome.gif",
"prop" => "duplicatefiles",
"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 );
echo( $output );
JavaScript
/*
duplicate_files.js
MediaWiki API Demos
Demo of `Duplicatefiles` module: List duplicates of the given files.
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
titles: "Image:1995.jpg|Image:Welcome.gif",
prop: "duplicatefiles",
format: "json"
};
request.get({ url: url, qs: params }, function(error, res, body) {
if (error) {
return;
}
console.log(body);
});
MediaWiki JS
/*
duplicate_files.js
MediaWiki API Demos
Demo of `Duplicatefiles` module: List duplicates of the given files.
MIT License
*/
var params = {
action: "query",
titles: "Image:1995.jpg|Image:Welcome.gif",
prop: "duplicatefiles",
format: "json"
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
console.log( data );
} );
Parameter history
- v1.20: Introduced
dfdir
,dflocalonly
See also
- API:Fileinfo - to supersede this
prop
in future versions of the MediaWiki Action API. - API:Stashimageinfo - retrieves information about stashed images.
- API:Images - retrieves all images embedded on a page.
- API:Info - retrieves basic information about a list of pages.
- API:Imageusage - finds all pages that use the given image or images.
- API:Imageinfo - retrieves information about an image file or files.