Search code examples
wikipediamediawiki-api

Is it possible to get supercategory pages ids?


It is possible to obtain ids of subcategories, with

cmprop=ids

parameter for list=categorymembers query.

But I cant find a way to obtain the same for supercategories list for prop=categorymembers query.

I tried with

clprop=ids

by analogy, but failed (this parameter was ignored).


Solution

  • This happens basically because in MediaWiki, the relation is between a page (the subcategory) and a category name (the supercategory). So, some page can have a supercategory that doesn't exist (doesn't have a pageid) and this is also how the relation is stored in the database.

    I think this is the reason why prop=categories doesn't show you article ids. You can work around that by using a generator that shows you the id for each page in the list of supercategories. Something like:

    http://en.wikipedia.org/w/api.php?action=query&generator=categories&prop=info&titles=Category%3AComputer%20programming&ginprop=