Reputation: 161
I'm using Wikimedia random API to get random article from Wikipedia, however, using this API I get completely random articles, the only parameter that I control here is rnnamespace which allow me to filter talk pages, user pages and so on.
I know that some wikipedia pages are assessed for their quality, and I'd like to get a random article, for example, present only in the set of featured article. Is there a way I could use the API to do that ?
I was wondering if my only option was to make sql queries, even though ideally I could rely only on the API.
Upvotes: 0
Views: 454
Reputation: 161
So I found a partly satisfying solution. I can use the API categorymembers, which return pages from a given category.
There's a parameter timestamps which allow to list all article from a specific date, so my idea is to choose randomly a date, then get a list of article from this date, and choose again randomly among those articles.
Of course, it does not guarantee an uniform distribution between the random choice of articles but it should work pretty good anyway.
I'll include my code later on to complete the answer.
Upvotes: 0
Reputation: 28180
Sadly, there is no proper API (the task for it is T63840). Use Special:RandomInCategory with the Featured articles
category. Or https://randomincategory.toolforge.org/ for a slower but more mathematically correct alternative.
Upvotes: 1