API needs function to only return number of backlinks to an article.
Closed, DeclinedPublic

Description

I asked my question on http://www.mediawiki.org/wiki/API_talk:Main_page#.22What_links_here.22_API_request and http://en.wikipedia.org/wiki/Wikipedia:Village_pump_%28technical%29#API_help_question

I have found that "api.php?action=query&list=backlinks&blnamespace=0&bltitle=" + wgPageName; will tell me if there are any articles that link to the page, but how can I get the full count (if greater than 500)? I don't care "what" articles link there, just how many. I'm trying to write myself a little JavaScript which in part will expand the "What links here" link in my p-tb to include an count of pages that link to a specific NS (or two or three) and a total count of pages that link to that article. I intend to use such a script to save me some time when I'm tagging articles for improvement on enwiki to quickly know if the article is an "orphan" or not. Thank you.

The response I got was: "You cant, that information is not stored in the database, the only way to do that is to retrieve the lists in chunks of 500 until you dont have any more."

I'm requesting this functionality be added to the api.


Version: unspecified
Severity: enhancement

bzimport added a project: MediaWiki-API.Via ConduitNov 22 2014, 1:33 AM
bzimport added a subscriber: Unknown Object (MLST).
bzimport set Reference to bz47173.
Technical13 created this task.Via LegacyApr 12 2013, 5:15 PM
Technical13 added a comment.Via ConduitApr 12 2013, 5:22 PM

My reasoning for requesting this is that on some of the pages listed http://en.wikipedia.org/wiki/Special:MostLinkedPages would require 9,000+ API requests to populate the list (also, because that special page has the counts readily available, I'm assuming it IS in the database someplace).

Betacommand added a comment.Via ConduitApr 12 2013, 5:29 PM

Its not in the database, those special pages are a real pain to update. I would tend to close this as {{WONTFIX}} due to the limited benefit, and need for high resources to create and maintain this feature. JobQueue and other components would make having this counter consistent unfeasible

Technical13 added a comment.Via ConduitApr 12 2013, 5:39 PM

(In reply to comment #2)

Its not in the database, those special pages are a real pain to update. I
would tend to close this as {{WONTFIX}} due to the limited benefit, and need for
high resources to create and maintain this feature. JobQueue and other
components would make having this counter consistent unfeasible

Yes, I realize that it those pages with multi-millions of links to are edge cases, but wouldn't having thousands of API requests be more resource intensive?

Anomie added a comment.Via ConduitApr 12 2013, 6:07 PM

COUNT queries can be expensive, and there is no interesting use case.

The use case you proposed on en:WP:VPT, showing a count in the "what links here" link to determine if something is orphaned, would work equally well if you did just the one backlinks query and displayed ">500" or "501+" or the like if it would need continuation (and really, you could probably limit it to even less for that particular use case).

Add Comment