API:Transcludedin: Difference between revisions
Appearance
Content deleted Content added
Redirected page to API:Properties#transcludedin / ti |
Use API documentation frame from the template |
||
| (11 intermediate revisions by 6 users not shown) | |||
| Line 1: | Line 1: | ||
<languages/> |
|||
#REDIRECT [[API:Properties#transcludedin / ti]] |
|||
{{API}} |
|||
{{MW 1.24|and after}} |
|||
<translate> |
|||
<!--T:1--> |
|||
'''GET request''' to find all pages that transclude the given pages. |
|||
== API documentation == <!--T:2--> |
|||
</translate> |
|||
{{Api help|query+transcludedin|frame=yes}} |
|||
<translate> |
|||
== Example == <!--T:3--> |
|||
=== GET request === <!--T:4--> |
|||
</translate> |
|||
{{ApiEx |
|||
| desc=<translate><!--T:5--> Get a list of pages which transclude a given page.</translate> |
|||
| p1=action=query |
|||
| p2=titles=Main%20Page |
|||
| p3=prop=transcludedin |
|||
| p4=format=json |
|||
}} |
|||
<translate> |
|||
=== Response === <!--T:6--> |
|||
</translate> |
|||
<div style="width:60%;"> |
|||
<syntaxhighlight lang="json"> |
|||
{ |
|||
"continue": { |
|||
"ticontinue": "20832294", |
|||
"continue": "||" |
|||
}, |
|||
"query": { |
|||
"pages": { |
|||
"15580374": { |
|||
"pageid": 15580374, |
|||
"ns": 0, |
|||
"title": "Main Page", |
|||
"transcludedin": [ |
|||
{ |
|||
"pageid": 1923146, |
|||
"ns": 2, |
|||
"title": "User:Eloquence/Tour 01" |
|||
}, |
|||
{ |
|||
"pageid": 5069777, |
|||
"ns": 2, |
|||
"title": "User:The Captain Returns" |
|||
}, |
|||
{ |
|||
"pageid": 7023260, |
|||
"ns": 2, |
|||
"title": "User:Sal's Wrecking Company" |
|||
}, |
|||
... |
|||
] |
|||
} |
|||
} |
|||
} |
|||
} |
|||
</syntaxhighlight> |
|||
</div> |
|||
<translate> |
|||
=== Sample code === <!--T:7--> |
|||
</translate> |
|||
{{:{{translatable}}/Sample code 1}} |
|||
<translate> |
|||
== Possible errors == <!--T:8--> |
|||
</translate> |
|||
{| class="wikitable" |
|||
|+ |
|||
!<translate><!--T:9--> Code</translate> |
|||
!<translate><!--T:10--> Info</translate> |
|||
|- |
|||
|show |
|||
|{{int|apierror-show}} |
|||
|} |
|||
<translate> |
|||
== Additional notes == <!--T:12--> |
|||
</translate> |
|||
* <translate><!--T:13--> This module can be used as a [[<tvar name=1>Special:MyLanguage/API:Query#Generators</tvar>|generator]].</translate> |
|||
<translate> |
|||
== See also == <!--T:14--> |
|||
</translate> |
|||
* {{ll|API:Templates}} - <translate><!--T:15--> Returns all pages transcluded on the given pages.</translate> |
|||
Latest revision as of 17:39, 29 August 2024
| This page is part of the MediaWiki Action API documentation. |
| MediaWiki version: | ≥ 1.24 |
GET request to find all pages that transclude the given pages.
API documentation
[edit | edit source]Example
[edit | edit source]GET request
[edit | edit source]Get a list of pages which transclude a given page.
Response
[edit | edit source]{
"continue": {
"ticontinue": "20832294",
"continue": "||"
},
"query": {
"pages": {
"15580374": {
"pageid": 15580374,
"ns": 0,
"title": "Main Page",
"transcludedin": [
{
"pageid": 1923146,
"ns": 2,
"title": "User:Eloquence/Tour 01"
},
{
"pageid": 5069777,
"ns": 2,
"title": "User:The Captain Returns"
},
{
"pageid": 7023260,
"ns": 2,
"title": "User:Sal's Wrecking Company"
},
...
]
}
}
}
}
Sample code
[edit | edit source]Python
[edit | edit source]#!/usr/bin/python3
"""
get_transcluded_in.py
MediaWiki API Demos
Demo of `Transcludedin` module: Get a list of pages which transclude a given page
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"titles": "Main Page",
"prop": "transcludedin",
"format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA)
PHP
[edit | edit source]<?php
/*
get_transcluded_in.php
MediaWiki API Demos
Demo of `Transcludedin` module: Get a list of pages which transclude a given page
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"titles" => "Main Page",
"prop" => "transcludedin",
"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 | edit source]/*
get_transcluded_in.js
MediaWiki API Demos
Demo of `Transcludedin` module: Get a list of pages which transclude a given page
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
titles: "Main Page",
prop: "transcludedin",
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
[edit | edit source]/*
get_transcluded_in.js
MediaWiki API Demos
Demo of `Transcludedin` module: Get a list of pages which transclude a given page
MIT License
*/
var params = {
action: 'query',
titles: 'Main Page',
prop: 'transcludedin',
format: 'json'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
console.log( data );
} );
Possible errors
[edit | edit source]| Code | Info |
|---|---|
| show | Incorrect parameter - mutually exclusive values may not be supplied. |
Additional notes
[edit | edit source]- This module can be used as a generator.
See also
[edit | edit source]- API:Templates - Returns all pages transcluded on the given pages.