Page MenuHomePhabricator

API: Add parameter clcategory to prop=categories
Closed, ResolvedPublic

Description

Sometimes you simply want to know whether some pages are in a given category or not. For these use cases, currently you have to query prop=categories, which will give you all categories for each page. Even worse, if you have more than one category per page in average, you will probably hit the (cl)limit for the query, and have to do a (perhaps sub-)query-continue, which will again give you lots of stuff that you actually don't need.

So an option like clcategory=Category:Foo would be nice, which will return at most one category per page and so one wouldn't have to care about hitting the limit.


Version: 1.14.x
Severity: enhancement
URL: http://en.wikipedia.org/w/api.php?action=query&titles=List_of_Wii_games&gpllimit=20&generator=links&prop=categories&cllimit=20

Details

Reference
bz16844

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:27 PM
bzimport set Reference to bz16844.

matthew.britton wrote:

Yeah, it's a rather odd construct but this would be of use; I can think of a few applications for it. Even more so if clcategory can be a pipe-delimited list of categories such that only those are returned.

This is probably doable database-wise, although I'm not sure which type of request the DB likes best: one title with multiple cats or one category with multiple titles. In the latter case, this feature would be better off as a cmtitles parameter to list=categorymembers. Also, I'm afraid that combining multiple titles with multiple categories may not be doable.

I'll look into this again when I can, but I'll probably be busy for the next two weeks.

matthew.britton wrote:

(In reply to comment #2)

Also, I'm afraid that combining multiple titles with multiple
categories may not be doable.

I suspected that might be the case :) -- don't worry about it.

Added in r45733. Multiple pages and multiple cats turned out to be no problem; you can even combine them.