I'm trying to work out how to get a list of all categories a page is in, including the sizes of those categories.
If I do this:
http://en.wikipedia.org/w/api.php?action=query&prop=categories&cllim...
I get all the categories, but no info about their size. But if I do this:
http://en.wikipedia.org/w/api.php?action=query&generator=categories&...
I get all the size info, but only the first 10 categories.
It looks like the answer is to use the continue option (cicontinue?) but I don't understand how to do that. Sorry if this is a dumb question - can someone clarify. Thanks! Andrew
On Thu, Feb 17, 2011 at 5:46 AM, Andrew Chapman hatmandu@gmail.com wrote:
I'm trying to work out how to get a list of all categories a page is in, including the sizes of those categories.
If I do this:
http://en.wikipedia.org/w/api.php?action=query&prop=categories&cllim...
I get all the categories, but no info about their size. But if I do this:
http://en.wikipedia.org/w/api.php?action=query&generator=categories&...
I get all the size info, but only the first 10 categories.
It looks like the answer is to use the continue option (cicontinue?) but I don't understand how to do that. Sorry if this is a dumb question - can someone clarify. Thanks! Andrew
you put whatever is in the continue as a parameter, so:
http://en.wikipedia.org/w/api.php?action=query&generator=categories&...
On Thu, Feb 17, 2011 at 11:46:50AM +0000, Andrew Chapman wrote:
http://en.wikipedia.org/w/api.php?action=query&generator=categories&...
I get all the size info, but only the first 10 categories.
Add in gcllimit=100. Any parameter you can specify for prop=foo or list=foo can be specified for generator=foo by prefixing a 'g', although some don't make much sense when used in generator mode.
It looks like the answer is to use the continue option (cicontinue?) but I don't understand how to do that. Sorry if this is a dumb question - can someone clarify.
It's pretty straightforward. If continuation is needed, the response will include a <query-continue> node, something like this: <query-continue> <categories gclcontinue="25970423|IOS (Apple)" /> </query-continue> In this case, it's telling you that for the 'categories' module you should repeat the same query adding glcontinue=25970423|IOS (Apple) to the next few results: http://en.wikipedia.org/w/api.php?action=query&generator=categories&...
If you're using the generator to generate titles for something that itself could have continuation, the situation is slightly more complicated. For example, you can find out what images and templates are used on each page in a category with a query like this: http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers... That will return multiple values in <query-continue>: <query-continue> <categorymembers gcmcontinue="022|" /> <templates tlcontinue="98358|10|Convert" /> <images imcontinue="98358|Ellipse sign 17.svg" /> </query-continue> To do it correctly, you'd want to ignore the gcmcontinue until it stops giving you tlcontinue and imcontinue: http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers... http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers... ... (10 similar queries) ... http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers... At this point, it stops giving imcontinue. You should remove prop=images from your query now, but keep on with prop=templates and tlcontinue. http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers... ... (35 similar queries) ... http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers... And finally you run out of tlcontinue too. Only now should you use gcmcontinue: http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers... And then repeat the process: http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers... http://en.wikipedia.org/w/api.php?action=query&generator=categorymembers... ... (and so on)
mediawiki-api@lists.wikimedia.org