API:Embeddedin
![]() | This page is part of the MediaWiki Action API documentation. |
MediaWiki version: | ≥ 1.11 |
GET request to find all page(s) that embed a given page.
This module can be used as a generator .
API documentation
[edit]
Example
[edit]GET request
[edit]Find all pages that embed the English Wikipedia's w:Computer page.
Response
[edit]{
"batchcomplete": "",
"query": {
"embeddedin": [
{
"pageid": 14388072,
"ns": 100,
"title": "Portal:Computing"
},
{
"pageid": 45719527,
"ns": 2,
"title": "User:SoSivr/sandbox"
}
]
}
}
Sample code
[edit]Python
[edit]#!/usr/bin/python3
"""
get_embedded_lists.py
MediaWiki API Demos
Demo of `Embeddedin` module: Get all page(s) that
embed a given page
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"format": "json",
"list": "embeddedin",
"eititle": "Computer",
"eilimit": "20"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
PAGES = DATA["query"]["embeddedin"]
for p in PAGES:
print(p["title"])
PHP
[edit]<?php
/*
get_embedded_pages.php
MediaWiki API Demos
Demo of `Embeddedin` module: Get all page(s) that embed a given page
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"format" => "json",
"list" => "embeddedin",
"eititle" => "Computer",
"eilimit" => "20"
];
$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 );
foreach( $result["query"]["embeddedin"] as $k => $v ) {
echo( $v["title"] . "\n" );
}
JavaScript
[edit]/*
get_embedded_pages.js
MediaWiki API Demos
Demo of `Embeddedin` module: Get all page(s) that embed a given page
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
format: "json",
list: "embeddedin",
eititle: "Computer",
eilimit: "20"
};
url = url "?origin=*";
Object.keys(params).forEach(function(key){url = "&" key "=" params[key];});
fetch(url)
.then(function(response){return response.json();})
.then(function(response) {
var pages = response.query.embeddedin;
for (var p in pages) {
console.log(pages[p].title);
}
})
.catch(function(error){console.log(error);});
MediaWiki JS
[edit]/*
get_embedded_pages.js
MediaWiki API Demos
Demo of `Embeddedin` module: Get all page(s) that embed a given page
MIT License
*/
var params = {
action: 'query',
format: 'json',
list: 'embeddedin',
eititle: 'Computer',
eilimit: '20'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
var pages = data.query.embeddedin,
p;
for ( p in pages ) {
console.log( pages[ p ].title );
}
} );
Possible errors
[edit]Code | Info |
---|---|
missingparam | One of the parameters eititle, eipageid is required. |
eibadcontinue | Invalid continue param. You should pass the original value returned by the previous query. |
See also
[edit]- API:Transcludedin - Find all pages that transclude the given pages.
- API:Templates - Returns all pages transcluded on the given pages.
- API:Alltransclusions - Part of API:Alllinks module. This API gets a list all transclusions (pages embedded using
{{x}}
), including non-existing. - API:Parsing wikitext - Parse content of a page and obtain the output.