Jump to content

API:Embeddedin/pt: Difference between revisions

From mediawiki.org
Content deleted Content added
FuzzyBot (talk | contribs)
Updating to match new version of source page
FuzzyBot (talk | contribs)
Updating to match new version of source page
 
Line 78: Line 78:
== See also ==
== See also ==
</div>
</div>
* {{ll|API:Transcludedin}} - <span lang="en" dir="ltr" class="mw-content-ltr">Find all pages that transclude the given pages.</span>
* {{ll|API:Transcludedin}} <span lang="en" dir="ltr" class="mw-content-ltr">Find all pages that transclude the given pages.</span>
* {{ll|API:Templates}} - <span lang="en" dir="ltr" class="mw-content-ltr">Returns all pages transcluded on the given pages.</span>
* {{ll|API:Templates}} <span lang="en" dir="ltr" class="mw-content-ltr">Returns all pages transcluded on the given pages.</span>
* {{ll|API:Alltransclusions}} - <span lang="en" dir="ltr" class="mw-content-ltr">Part of {{ll|API:Alllinks}} module.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This API gets a list all transclusions (pages embedded using <code><nowiki>{{x}}</nowiki></code>), including non-existing.</span>
* {{ll|API:Alltransclusions}} <span lang="en" dir="ltr" class="mw-content-ltr">Part of {{ll|API:Alllinks}} module.</span> <span lang="en" dir="ltr" class="mw-content-ltr">This API gets a list all transclusions (pages embedded using <code><nowiki>{{x}}</nowiki></code>), including non-existing.</span>
* {{ll|API:Parsing_wikitext}} - <span lang="en" dir="ltr" class="mw-content-ltr">Parse content of a page and obtain the output.</span>
* {{ll|API:Parsing_wikitext}} <span lang="en" dir="ltr" class="mw-content-ltr">Parse content of a page and obtain the output.</span>

Latest revision as of 20:36, 27 October 2025

Versão MediaWiki:
1.11

GET request to find all page(s) that embed a given page.

This module can be used as a generator .

API documentation

list=embeddedin (ei)

(main | query | embeddedin)
  • This module requires read rights.
  • This module can be used as a generator.
  • Source: MediaWiki
  • License: GPL-2.0-or-later

Find all pages that embed (transclude) the given title.

Specific parameters:
Other general parameters are available.
eititle

Title to search. Cannot be used together with eipageid.

eipageid

Page ID to search. Cannot be used together with eititle.

Type: integer
eicontinue

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

einamespace

The namespace to enumerate.

Values (separate with | or alternative): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 90, 91, 92, 93, 100, 101, 102, 103, 104, 105, 106, 107, 710, 711, 828, 829, 1198, 1199, 1728, 1729, 2600, 5500, 5501
To specify all values, use *.
eidir

The direction in which to list.

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

How to filter for redirects.

One of the following values: all, nonredirects, redirects
Default: all
eilimit

How many total pages to return.

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

Exemplo

GET request

Find all pages that embed the English Wikipedia's w:Computer page.

Response

{
    "batchcomplete": "",
    "query": {
        "embeddedin": [
            {
                "pageid": 14388072,
                "ns": 100,
                "title": "Portal:Computing"
            },
            {
                "pageid": 45719527,
                "ns": 2,
                "title": "User:SoSivr/sandbox"
            }
        ]
    }
}

Sample code


Python

#!/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

<?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

/*
    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

/*
	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

Código Informação
missingparam Um dos parâmetros eititle, eipageid é obrigatório.
eibadcontinue Parâmetro de continuação inválido. Deve passar o valor original devolvido pela consulta anterior.

See also