Hi:

I have been using the API (http://en.wikipedia.org/w/api.php) and found some problem. I would like to get a random article of a category or child categories. I mean if I need a random article of "Science" category, so the result can be an article in "Astronomy" category, or "Biology" category.

"random" command just have namespace not category, and "categorymembers" has not recursivity.

The problems is categories are not nested so I guess there's no command that give that recursivity since an article has just "parent categories" and not all the jerarchy information.


I have tried to mix "random" and "categorymembers" with generators:
http://en.wikipedia.org/w/api.php?action=query&list=random&generator=categorymembers&gcmtitle=Category:Physics&prop=info
http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Physics&generator=random&rnnamespace=0

...
but no luck

The only solution i'm thinking is to code some random depth search in the category I want to get the random article, and then search in that category any random article. So, I can use "categorymembers" command to deep a random number of levels, and then take the article there.

Is there any nice solution ?

Thank you