API:Fileusage/ja: Difference between revisions
Appearance
Content deleted Content added
Created page with "情報" |
Updating to match new version of source page |
||
| (12 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<languages/> |
<languages /> |
||
{{API}} |
{{API}} |
||
{{MW 1.24|and after}} |
|||
{{API-head |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
|version=1.24 |
|||
'''GET request''' to find all pages that use the given files. |
|||
|prefix=fu |
|||
</div> |
|||
|rrights=None |
|||
|postonly=No |
|||
|description=Find all pages that use the given files. |
|||
|generator=yes |
|||
|query=yes |
|||
}} |
|||
Find all pages that use the given files. This module can be used as a [[API:Query#Generators|generator]]. |
|||
<span id="API_documentation"></span> |
|||
== パラメーター == |
|||
== APIの説明文書 == |
|||
*{{ApiParam|fuprop|description=Which properties to get.|default=<code>pageid{{!}}title{{!}}redirect</code>}} |
|||
{{Api help|query+fileusage|frame=yes}} |
|||
**{{ApiParam|pageid|description=Get the page id of each page.}} |
|||
**{{ApiParam|title|description=Get the title of each page.}} |
|||
**{{ApiParam|redirect|description=Flag whether the page is a redirect.}} |
|||
*{{ApiParam|funamespace|description=Only include pages in these namespaces.}} |
|||
*{{ApiParam|fushow|description=Show only items that meet these criteria.}} |
|||
**{{ApiParam|redirect|description=Only show redirects.}} |
|||
**{{ApiParam|!redirect|description=Only show non-redirects.}} |
|||
*{{ApiParam|fulimit|description=The number of results to return.|maxallowed=500|default=10}} |
|||
*{{ApiParam|fucontinue|description=When more results are available, use this to continue.}} |
|||
<span id="Example"></span> |
|||
== 例 == |
== 例 == |
||
<span id="GET_request"></span> |
|||
=== GET リクエスト === |
|||
{{ApiEx |
{{ApiEx |
||
| desc=Get a list of pages using |
| desc=<span lang="en" dir="ltr" class="mw-content-ltr">Get a list of pages using a given file.</span> |
||
| p1=action=query |
| p1=action=query |
||
| p2=titles=File:Example.jpg |
| p2=titles=File:Example.jpg |
||
| p3=prop=fileusage |
| p3=prop=fileusage |
||
| p4=format=json |
|||
| result=<source lang="javascript">{ |
|||
}} |
|||
<span id="Response"></span> |
|||
=== レスポンス === |
|||
<div style="width:60%;"> |
|||
<syntaxhighlight lang="json"> |
|||
{ |
|||
"continue": { |
|||
"fucontinue": "4635245", |
|||
"continue": "||" |
|||
}, |
|||
"query": { |
"query": { |
||
"pages": { |
"pages": { |
||
| Line 38: | Line 39: | ||
"title": "File:Example.jpg", |
"title": "File:Example.jpg", |
||
"fileusage": [ |
"fileusage": [ |
||
{ |
|||
"pageid": 57741, |
|||
"ns": 1, |
|||
"title": "Talk:Ebola virus" |
|||
}, |
|||
{ |
|||
"pageid": 85076, |
|||
"ns": 1, |
|||
"title": "Talk:Case sensitivity" |
|||
}, |
|||
{ |
|||
"pageid": 165974, |
|||
"ns": 1, |
|||
"title": "Talk:Asia" |
|||
}, |
|||
{ |
|||
"pageid": 243414, |
|||
"ns": 5, |
|||
"title": "Wikipedia talk:Alternative text for images" |
|||
}, |
|||
{ |
|||
"pageid": 256889, |
|||
"ns": 4, |
|||
"title": "Wikipedia:Manual of Style/Images" |
|||
}, |
|||
{ |
|||
"pageid": 428971, |
|||
"ns": 3, |
|||
"title": "User talk:Centrx" |
|||
}, |
|||
{ |
{ |
||
"pageid": 447341, |
"pageid": 447341, |
||
| Line 79: | Line 50: | ||
}, |
}, |
||
{ |
{ |
||
"pageid": |
"pageid": 554270, |
||
"ns": |
"ns": 13, |
||
"title": " |
"title": "Help talk:Pictures" |
||
}, |
}, |
||
... |
|||
"pageid": 728041, |
|||
"ns": 10, |
|||
"title": "Template:Infobox video game" |
|||
} |
|||
] |
] |
||
} |
} |
||
} |
} |
||
} |
} |
||
} |
|||
}</source>}} |
|||
</syntaxhighlight> |
|||
</div> |
|||
<span id="Sample_code"></span> |
|||
=== サンプル コード === |
|||
{{:{{translatable}}/Sample code 1}} |
|||
<span id="Possible_errors"></span> |
|||
== 起こりうるエラー == |
== 起こりうるエラー == |
||
{| class="wikitable |
{| class="wikitable" |
||
|+ |
|||
! コード !! 情報 |
|||
!コード |
|||
!情報 |
|||
|- |
|- |
||
| |
|fushow |
||
|Incorrect parameter - mutually exclusive values may not be supplied. |
|||
|} |
|} |
||
<span id="Additional_notes"></span> |
|||
{{Api help|query+fileusage}} |
|||
== 追加的な注記 == |
|||
<div lang="en" dir="ltr" class="mw-content-ltr"> |
|||
* This module can be used as a [[Special:MyLanguage/API:Query#Generators|generator]]. |
|||
</div> |
|||
<span id="See_also"></span> |
|||
[[Category:MediaWiki API{{#translation:}}]] |
|||
== 関連項目 == |
|||
* {{ll|API:Globalusage}} - <span lang="en" dir="ltr" class="mw-content-ltr">List all file usages on wikis other than the one where the file is stored.</span> |
|||
* {{ll|API:Allfileusages}} - <span lang="en" dir="ltr" class="mw-content-ltr">List all file usages, including non-existing.</span> |
|||
Latest revision as of 21:25, 3 September 2024
| このページは MediaWiki 操作 API の説明文書の一部です。 |
| MediaWiki バージョン: | ≧ 1.24 |
GET request to find all pages that use the given files.
APIの説明文書
例
GET リクエスト
Get a list of pages using a given file.
レスポンス
{
"continue": {
"fucontinue": "4635245",
"continue": "||"
},
"query": {
"pages": {
"586539": {
"pageid": 586539,
"ns": 6,
"title": "File:Example.jpg",
"fileusage": [
{
"pageid": 447341,
"ns": 5,
"title": "Wikipedia talk:Extended image syntax"
},
{
"pageid": 499974,
"ns": 4,
"title": "Wikipedia:Tutorial/Formatting"
},
{
"pageid": 554270,
"ns": 13,
"title": "Help talk:Pictures"
},
...
]
}
}
}
}
サンプル コード
Python
#!/usr/bin/python3
"""
get_file_usage.py
MediaWiki API Demos
Demo of `Fileusage` module: Get a list of pages using a given file.
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"titles": "File:Example.jpg",
"prop": "fileusage",
"format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)
PHP
<?php
/*
get_file_usage.php
MediaWiki API Demos
Demo of `Fileusage` module: Get a list of pages using a given file.
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"titles" => "File:Example.jpg",
"prop" => "fileusage",
"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
/*
get_file_usage.js
MediaWiki API Demos
Demo of `Fileusage` module: Get a list of pages using a given file.
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
titles: "File:Example.jpg",
prop: "fileusage",
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);});
MediaWiki JS
/*
get_file_usage.js
MediaWiki API Demos
Demo of `Fileusage` module: Get a list of pages using a given file.
MIT License
*/
var params = {
action: 'query',
titles: 'File:Example.jpg',
prop: 'fileusage',
format: 'json'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
console.log( data );
} );
起こりうるエラー
| コード | 情報 |
|---|---|
| fushow | Incorrect parameter - mutually exclusive values may not be supplied. |
追加的な注記
- This module can be used as a generator.
関連項目
- API:Globalusage - List all file usages on wikis other than the one where the file is stored.
- API:allfileusages - List all file usages, including non-existing.