API:विलोम कड़ियाँ

This page is a translated version of the page API:Backlinks and the translation is 100% complete.
मीडियाविकि संस्करण:
1.9

किसी विशिष्ट पृष्ठ की तरफ़ इशारा करने वाले कड़ियों वाले सभी पृष्ठों को सूचीबद्ध करने के लिए GET अनुरोध

API प्रलेख


(main | query | backlinks)
  • 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 link to the given page.

Specific parameters:
Other general parameters are available.
bltitle

Title to search. Cannot be used together with blpageid.

blpageid

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

Type: integer
blcontinue

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

blnamespace

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, 486, 487, 710, 711, 828, 829, 1198, 1199, 2600, 5500, 5501
To specify all values, use *.
bldir

The direction in which to list.

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

How to filter for redirects. If set to nonredirects when blredirect is enabled, this is only applied to the second level.

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

How many total pages to return. If blredirect is enabled, the limit applies to each level separately (which means up to 2 * bllimit results may be returned).

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

If linking page is a redirect, find all pages that link to that redirect as well. Maximum limit is halved.

Type: boolean (details)

उदाहरण

GET अनुरोध

Philosophy पृष्ठ के विलोम कड़ियों की सूची बनाएँ।


जवाब

{
    "batchcomplete": "",
    "continue": {
        "blcontinue": "1|987",
        "continue": "-||"
    },
    "query": {
        "backlinks": [
            {
                "pageid": 12,
                "ns": 0,
                "title": "Anarchism"
            },
            {
                "pageid": 128,
                "ns": 1,
                "title": "Talk:Atlas Shrugged"
            },
            {
                "pageid": 336,
                "ns": 0,
                "title": "Altruism"
            },
            ...
        ]
    }
}

उदाहरण कोड

Python

#!/usr/bin/python3

"""
    get_backlinks.py

    MediaWiki API Demos
    Demo of `Backlinks` module: Get request to list pages which link to a certain page.

    MIT License
"""

import requests

S = requests.Session()

URL = "https://en.wikipedia.org/w/api.php"

PARAMS = {
    "action": "query",
    "format": "json",
    "list": "backlinks",
    "bltitle": "philosophy"
}

R = S.get(url=URL, params=PARAMS)
DATA = R.json()

BACKLINKS = DATA["query"]["backlinks"]

for b in BACKLINKS:
    print(b["title"])

PHP

<?php
/*
    get_backlinks.php

    MediaWiki API Demos
    Demo of `Backlinks` module: Get request to list pages which link to a certain page.

    MIT License
*/

$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
    "action" => "query",
    "format" => "json",
    "list" => "backlinks",
    "bltitle" => "philosophy"
];

$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"]["backlinks"] as $k => $v ) {
    echo( $v["title"] . "\n" );
}

JavaScript

/*
    get_backlinks.js

    MediaWiki API Demos
    Demo of `Backlinks` module: Get request to list pages which link to a certain page.

    MIT License
*/

var url = "https://en.wikipedia.org/w/api.php"; 

var params = {
    action: "query",
    format: "json",
    list: "backlinks",
    bltitle: "philosophy"
};

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 backlinks = response.query.backlinks;
        for (var b in backlinks) {
            console.log(backlinks[b].title);
        }
    })
    .catch(function(error){console.log(error);});

MediaWiki JS

/*
	get_backlinks.js

	MediaWiki API Demos
	Demo of `Backlinks` module: Get request to list pages which link to a certain page.

	MIT License
*/

var params = {
		action: 'query',
		format: 'json',
		list: 'backlinks',
		bltitle: 'philosophy'
	},
	api = new mw.Api();

api.get( params ).done( function ( data ) {
	var backlinks = data.query.backlinks,
		b;
	for ( b in backlinks ) {
		console.log( backlinks[ b ].title );
	}
} );

अनुप्रेषण

ऊपर के उदाहरण में Philosophy पृष्ठ के सिर्फ सीधे कड़ियों को सूचीबद्ध किया गया है। जब blredirect सेट किया जाता है, जवाब में वे पृष्ठ भी होंगे जिन पर bltitle के वैल्यू के लिए अनुप्रेषणों के विलोम कड़ियाँ हैं।

इन अनुप्रेषित विलोम कड़ियों को जवाब के पदानुक्रम में एक अलग समूह माना जाता है, जो अनुप्रेषण से एक पद नीचे है।

bllimit में सेट की गई सीमा जवाब के हर पद पर अलग-अलग तरीके से लागू होता है, तो bllimit=25 25 सीधे विलोम कड़ियाँ, और हर अनुप्रेषण में अधिकतम 25 विलोम कड़ियाँ लौटाएगा।

साथ ही, जवाब में अनुप्रेषण के होने पर blcontinue का इस्तेमाल करने से और भी द्वितीय-पद विलोम कड़ियाँ लौटाए जाएँगे, और जब किसी अनुप्रेषण के विलोम कड़ियाँ पूरी तरह से लौटा दिए जाते हैं, तब आखिर में अधिक सीधे विलोम कड़ियाँ दिखाए जाएँगे।

संभव त्रुटियाँ

कोड जानकारी
blbadcontinue Invalid continue param. You should pass the original value returned by the previous query.

ये भी देखें

  • API:Linkshere - किसी पृष्ठ की तरफ़ इशारा करने वाले कड़ियों वाले सभी पृष्ठों को प्राप्त करता है। ध्यान रखें कि API:Backlinks एक list मोडल है जबकि API:Linkshere एक prop मोडल है। इन दोनों मोडलों के कार्यों के बीच अंतर देखने के लिए API:गुणधर्म और API:Lists के अपने-अपने पृष्ठ देखें।
  • API:Transcludedin - एक prop मोडल उन सभी पृष्ठों को ढूँढ़ता है जो निर्धारित पृष्ठों को ट्रांसक्लूड (यानी वहाँ से जानकारी को एम्बेड) करते हैं।
  • API:Embeddedin - एक list मोडल जो ट्रांसक्लूशन के ज़रिए विलोम कड़ियों को सूचीबद्ध करता है, Special:Whatlinkshere की तरह।
  • API:Imageusage - निर्धारित चित्र या चित्रों का इस्तेमाल करने वाले सभी पृष्ठ प्राप्त करता है।
  • API:Fileusage - निर्धारित फ़ाइल या फ़ाइलों का इस्तेमाल करने वाले सभी पृष्ठ प्राप्त करता है।