List all API categories in Wikia API

600 views Asked by At

I am playing around with the Wikia API and have listed, for instance, all comics in the Marvel or DC Fandom Wikis, all the movies, etc.. using the following URL, where I substituted the relevant category.

https://dc.fandom.com/api/v1/Articles/List?expand=1&category=comics&namespaces=0&limit=10

Some of these categories are straightforward, so far I found movies, episodes, comics, novels, audio and characters. As far as I know, a complete list of all possible API categories is nowhere in the documentation.

Is there a way to list all possible categories? For instance, I would like to list video games, but videogames or games is not a possible category. A list would make things considerably easier.

1

There are 1 answers

0
tweetotaler On BEST ANSWER

Note that there is a new endpoint for the Fandom API.

The MediaWiki query type you are looking for is Allcategories. You will want to use the API parameters

  • action = query
  • format = json
  • formatversion = 2
  • list = allcategories

You may also want to use

  • aclimit=(maximum results returned, max 500 at a time, default 10)
  • acprop=size (optional, show how many pages are in the category)
  • acfrom=(name of the category to start from, like 'Category:Video Games')

Note that if you want to paginate through more than 500 results, you will need to also use the accontinue parameter returned in the first page of results in your next API query to get the second page of results.

Here it is in action on the DC Fandom.

If you already know the higher-level categories you're interest in, you may be interested in getting their subcategories using categorymembers instead. (API query). This is also the query you would use to get the pages that are members of those categories.