API:Alllinks/hi
![]() | यह पृष्ठ मीडियाविकि प्रतिक्रिया API प्रलेख का हिस्सा है। |
मीडियाविकि संस्करण: | ≥ 1.11 |
शीर्षक के क्रम पर किसी नामस्थान की तरफ़ इशारा करने वाले सभी कड़ियों को सूचीबद्ध करने के लिए GET अनुरोध।
इस मोडल का इस्तेमाल {{$1|सृष्टिकार}}
के रूप में किया जा सकता है।
API प्रलेख
![]() | The following documentation is the output of Special: |
list=alllinks (al)
- This module requires read rights.
- This module can be used as a generator.
- Source: MediaWiki
- License: GPL-2.0-or-later
Enumerate all links that point to a given namespace.
- alcontinue
When more results are available, use this to continue. More detailed information on how to continue queries can be found on mediawiki.org.
- alfrom
The title of the link to start enumerating from.
- alto
The title of the link to stop enumerating at.
- alprefix
Search for all linked titles that begin with this value.
- alunique
Only show distinct linked titles. Cannot be used with alprop=ids. When used as a generator, yields target pages instead of source pages.
- Type: boolean (details)
- alprop
Which pieces of information to include:
- ids
- Adds the page ID of the linking page (cannot be used with alunique).
- title
- Adds the title of the link.
- Values (separate with | or alternative): ids, title
- Default: title
- alnamespace
The namespace to enumerate.
- One of the following values: -1, -2, 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, 2600, 5500, 5501
- Default: 0
- allimit
How many total items to return.
- Type: integer or max
- The value must be between 1 and 500.
- Default: 10
- aldir
The direction in which to list.
- One of the following values: ascending, descending
- Default: ascending
- List linked titles, including missing ones, with page IDs they are from, starting at B.
- api.php?action=query&list=alllinks&alfrom=B&alprop=ids|title [open in sandbox]
- List unique linked titles.
- api.php?action=query&list=alllinks&alunique=&alfrom=B [open in sandbox]
- Gets all linked titles, marking the missing ones.
- api.php?action=query&generator=alllinks&galunique=&galfrom=B [open in sandbox]
- Gets pages containing the links.
- api.php?action=query&generator=alllinks&galfrom=B [open in sandbox]
उदाहरण
अगर किसी पृष्ठ पर एक ही नामस्थान की तरफ़ इशारा करने वाले कई कड़ियाँ ही, डिफ़ॉल्ट से यह मोडल अंजाम को कई बार लौटाएगा।
जवाब में अंजाम को दोहराने से रोकने के लिए इस उदाहरण में alunique=1
का इस्तेमाल किया गया है।
GET अनुरोध
जवाब
{
"batchcomplete": "",
"continue": {
"alcontinue": "!!!!Hashtagging",
"continue": "-||"
},
"query": {
"alllinks": [
{
"ns": 0,
"title": "!"
},
{
"ns": 0,
"title": "!!"
},
{
"ns": 0,
"title": "!!!"
},
...
}
उदाहरण कोड
Python
#!/usr/bin/python3
"""
get_alllinks.py
MediaWiki API Demos
Demo of `Alllinks` module: List links pointing to the given namespace.
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"format": "json",
"list": "alllinks",
"alnamespace": "0",
"alunique": "1"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
LINKS = DATA["query"]["alllinks"]
for l in LINKS:
print(l["title"])
PHP
<?php
/*
get_alllinks.php
MediaWiki API Demos
Demo of `Alllinks` module: List links pointing to the given namespace.
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"format" => "json",
"list" => "alllinks",
"alnamespace" => "0",
"alunique" => "1"
];
$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"]["alllinks"] as $k => $v ) {
echo( $v["title"] . "\n" );
}
JavaScript
/*
get_alllinks.js
MediaWiki API Demos
Demo of `Alllinks` module: List links pointing to the given namespace.
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
format: "json",
list: "alllinks",
alnamespace: "0",
alunique: "1"
};
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 links = response.query.alllinks;
for (var l in links) {
console.log(links[l].title);
}
})
.catch(function(error){console.log(error);});
MediaWiki JS
/*
get_alllinks.js
MediaWiki API Demos
Demo of `Alllinks` module: List links pointing to the given namespace.
MIT License
*/
var params = {
action: 'query',
format: 'json',
list: 'alllinks',
alnamespace: '0',
alunique: '1'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
var links = data.query.alllinks,
l;
for ( l in links ) {
console.log( links[ l ].title );
}
} );
संभव त्रुटियाँ
कोड | जानकारी |
---|---|
badcontinue | Invalid continue param. You should pass the original value returned by the previous query. |
invalidparammix | The alprop=ids parameter cannot be used with alunique. ऐसा तब होता है जब आप alprop=ids और alunique का एक साथ इस्तेमाल करते हैं। |
अतिरिक्त टिप्पणियाँ
- प्रतिक्रिया API में कड़ियों वाले दूसरे मोडलों की तरह यह मोडल नामस्थान की तरफ़ इशारा करने वाले कड़ियों के पृष्ठों के शीर्षक लौटाता है, उन पृष्ठों के सटीक URI नहीं।
- इस मोडल का इस्तेमाल सृष्टिकार के रूप में किया जा सकता है।
- अगर पुराने संस्करणों सदस्य इस मोडल का सृष्टिकार के रूप में इस्तेमाल करने की कोशिश करता था, एक त्रुटि दिखाई जाती थी, और
alunique
को true पर सेट किया गया था। इसे v1.24 में बदल दिया गया, जिससे अबalunique
के true होने के बावजूद इसका इस्तेमाल सृष्टिकार के रूप में किया जा सकता है।
ये भी देखें
- API:विलोम कड़ियाँ - निर्धारित पृष्ठ की कड़ियों को सूचीबद्ध करता है।
- API:Linkshere - API:विलोम कड़ियाँ की तरह, किसी पृष्ठ के कड़ियों को प्राप्त करता है। ध्यान रखें कि API:विलोम कड़ियाँ एक
list
मोडल है जबकि API:Linkshere एकprop
मोडल है। इन दोनों मोडलों के कार्यों के बीच अंतर देखने के लिए API:गुणधर्म और API:Lists के अपने-अपने पृष्ठ देखें। - API:Links - निर्धारित पृष्ठ या पृष्ठों पर कड़ियों को प्राप्त करता है।