API:Backlinks
| This page is part of the MediaWiki API documentation. |
Quick overview:
- Quick start guide
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Search suggestions
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
- Asserting
| MediaWiki version: | 1.9 |
Lists pages that link to a given page, similar to Special:Whatlinkshere. Ordered by linking page title.
Contents
Parameters[edit | edit source]
bltitle: List pages linking to this title. The title does not need to exist.blnamespace: Only list pages in these namespacesblfilterredir: How to filter redirects (Default:all)all: List all pages regardless of their redirect flagredirects: Only list redirectsnonredirects: Don't list redirects
bllimit: Maximum amount of pages to list. Maximum limit is halved ifblredirectis set. No more than 500 (5000 for bots) allowed. (Default: 10)blredirect: If set, pages linking tobltitlethrough a redirect will also be listed. See below for more detailed information.blcontinue: Used to continue a previous request
Example[edit | edit source]
Find all pages that redirect to en:Main Page.
| Result |
|---|
<?xml version="1.0"?> <api> <query> <backlinks> <bl pageid="217224" ns="0" title="Mainpage" redirect="" /> <bl pageid="217225" ns="0" title="Main page" redirect="" /> <bl pageid="485697" ns="0" title="Main Page/" redirect="" /> <bl pageid="668228" ns="0" title="Hauptseite" redirect="" /> <bl pageid="1201247" ns="4" title="Wikipedia:Main Page/CSS" redirect="" /> </backlinks> </query> <query-continue> <backlinks blcontinue="0|Main_Page|1249010" /> </query-continue> </api> |
Other links[edit | edit source]
Links through redirects[edit | edit source]
| MediaWiki version: | 1.12 |
When the blredirect parameter is set, this module behaves slightly differently. bllimit applies to both levels separately: if e.g. bllimit=10, at most 10 first-level pages (pages that link to bltitle) and 10 second-level pages (pages that link to bltitle through a redirect) will be listed. Continuing queries also works differently, as displayed in the following example.
Get a list of pages linking to Albert Einstein (note: the initial query includes a "blcontinue" parameter for purposes of illustration)
| Result |
|---|
<?xml version="1.0"?> <api> <query> <backlinks> <bl pageid="8756" ns="0" title="Daniel Dennett" /> <bl pageid="9247" ns="0" title="Epistemology" /> <bl pageid="9251" ns="0" title="Engineering" /> <bl pageid="9292" ns="0" title="Einstein" redirect=""> <redirlinks> <bl pageid="736" ns="0" title="Albert Einstein" /> <bl pageid="2792" ns="0" title="Anthropic principle" /> <bl pageid="5381" ns="1" title="Talk:Creationism/Archive 1" /> <bl pageid="5863" ns="0" title="Copenhagen interpretation" /> <bl pageid="6943" ns="0" title="Cathode ray" /> <bl pageid="8625" ns="0" title="Differential geometry" /> <bl pageid="9417" ns="0" title="Euclidean geometry" /> <bl pageid="9735" ns="0" title="Electromagnetic field" /> <bl pageid="10890" ns="0" title="Fundamental interaction" /> <bl pageid="10902" ns="0" title="Force" /> </redirlinks> </bl> <bl pageid="9417" ns="0" title="Euclidean geometry" /> <bl pageid="9426" ns="0" title="Electromagnetic radiation" /> <bl pageid="9476" ns="0" title="Electron" /> <bl pageid="9479" ns="0" title="Einsteinium" /> <bl pageid="9508" ns="0" title="Encyclopædia Britannica" /> <bl pageid="9532" ns="0" title="Electromagnetism" /> </backlinks> </query> <query-continue> <backlinks blcontinue="0|Albert_Einstein|9292|11439" /> </query-continue> </api> |
When continuing this request, we see that there are more pages linking to Einstein, and that some of the other first-level pages are listed again. If we continue this query again, the same first-level pages will be listed in the next response, as well. To progress beyond Energy, we have to query-continue again and again until we've had all links to Einstein (or increase bllimit, of course). Continuing the previous request:
| Result |
|---|
<?xml version="1.0"?> <api> <query> <backlinks> <bl pageid="9292" ns="0" title="Einstein" redirect=""> <redirlinks> <bl pageid="11439" ns="0" title="Faster-than-light" /> <bl pageid="12433" ns="1" title="Talk:Genius" /> <bl pageid="12511" ns="0" title="Gerald Schroeder" /> <bl pageid="13509" ns="0" title="H. P. Lovecraft" /> <bl pageid="13758" ns="0" title="History of physics" /> <bl pageid="14220" ns="0" title="History of mathematics" /> <bl pageid="14909" ns="0" title="Inertia" /> <bl pageid="15942" ns="0" title="John von Neumann" /> <bl pageid="17453" ns="0" title="Kevin Warwick" /> <bl pageid="17556" ns="0" title="Laser" /> </redirlinks> </bl> <bl pageid="9417" ns="0" title="Euclidean geometry" /> <bl pageid="9426" ns="0" title="Electromagnetic radiation" /> <bl pageid="9476" ns="0" title="Electron" /> <bl pageid="9479" ns="0" title="Einsteinium" /> <bl pageid="9508" ns="0" title="Encyclopædia Britannica" /> <bl pageid="9532" ns="0" title="Electromagnetism" /> <bl pageid="9603" ns="0" title="Ernest Rutherford" /> <bl pageid="9604" ns="0" title="Many-worlds interpretation" /> <bl pageid="9649" ns="0" title="Energy" /> </backlinks> </query> <query-continue> <backlinks blcontinue="0|Albert_Einstein|9292|18895" /> </query-continue> </api> |
Links through transclusions[edit | edit source]
If you need to list pages as they appear in "What links here" on the MediaWiki sites with pages transcluding the desired page, you might want to try API:Embeddedin list.
Links through image usage[edit | edit source]
If you need to list pages as they appear in "What links here" on the MediaWiki sites with pages displaying the desired file, you might want to try API:Imageusage list. This also works on non-existent files.
Error Codes[edit | edit source]
| Code | Info |
|---|---|
| blbadcontinue | Invalid continue param. You should pass the original value returned by the previous query. |