<Technical_13> Could you please review my idea http://pastebin.com/sHce6E7T and possibly add it to https://phabricator.wikimedia.org/diffusion/MW/change/master/resources/src/mediawiki/api/category.js
<Technical_13> So, If I'm on Category:Pages_starting_with_A and I want to see if one of the members in that category is also in Category:Pages_ending_with_Z --- this will do it.
<Krinkle> Technical_13: So you'll call this method once for every member?
It sounds like you want a method to check that a category contains a certain page. (Or rather, that a page is in a certain category).
However for your given use case, what you really want is intersection. Making a query for every page separately isn't a very efficient way to do that. There is probably a better API for this, not sure which one though.
So, If I'm on Category:Pages_starting_with_A and I want to see if one of the members in that category is also in Category:Pages_ending_with_Z
Using the API directly, you'd use something like action=query&generator=categorymembers&gcmtitle=Category:Pages_starting_with_A&gcmlimit=max&prop=categories&clcategories=Category:Pages_ending_with_Z&cllimit=max
Breaking that down,
- generator=categorymembers tells it that you're wanting to query pages in a category.
- gcmtitle=Category:Pages_starting_with_A names the category.
- gcmlimit=max tells it to give you 500 or 5000 pages at a time, instead of only 10.
- prop=categories tells it you want to get the list of categories for each page being queried.
- clcategories=Category:Pages_ending_with_Z tells it you don't care about all categories those pages might be in, just Category:Pages_ending_with_Z
- cllimit=max tells it to give you 500 or 5000 categories at a time, instead of only 10.
Then you'd look through the results to see which of the pages are in Category:Pages_ending_with_Z.
To do intersection even more efficiently, there might be some CirrusSearch magic you can do with list=search, or you could see if PetScan has an API.