apiwikipediawikipedia-apiwikimedia

How to get random page of specific "Portal:" using WikiMedia API


Is there any way to get random article of specific wikimedia portal using wikimedia API?

For example, I need random page of Portal:Science.

Does anyone know how to do this?


Solution

  • What you're asking for doesn't make much sense, because a portal doesn't have a list of pages associated with it.

    The closest thing you can do is to get a random page from e.g. Category:Science or one of its subcategories. There is no way to do that directly using the API, you would need to traverse all the subcategories and choose a random page from them by yourself.

    There is a tool that already does this (with a limit on the depth of the category tree): erwin85's random article and there is also a template for it on the English Wikipedia.