Board Thread:Support Requests - Getting Technical/@comment-3032314-20150605133249

I would like to get a list of categories for the current page, using JavaScript. seems like the natural choice, but it doesn't work on "Module:" pages (even if you manually categorize them). According to the documentation:

"If the category box is not shown on the current page (as is the case when editing/viewing history), will be an empty array."

Since there's no way a regular expression will work, I think the best solution is to use the MediaWiki API. The URL is simple enough:

/api.php?action=query&pageids=&prop=categories&clprop=hidden&cllimit=500&format=json


 * gets information about the wiki
 * is a placeholder for the current page's id
 * gets a list of categories
 * indicates if a category is hidden
 * gets as many categories as possible
 * makes the API return JSON instead of XML

...And that's where I got stuck. What's the best way to request data from the API using JavaScript? ResourceLoader's mw.Api, maybe? (There's a function called  that sounds like exactly what I want, but I can't get it to work.)

Any help would be appreciated! 