Per WikiProject Portals discussion on enwiki:
Some portals would like to show an excerpt from a page chosen from a category. Is there any way for a module or template to list the members of a category? title:getContent() on a category page just returns the "This is a list of foos" blurb, not the actual members. mw.site.stats.pagesInCategory counts the pages but doesn't reveal the titles. getContent doesn't work on Special:RandomInCategory, and transcluding it just produces a link rather than the text. Surely we don't need to write a bot to periodically copy the category page to a standard page (which we can then read easily)? Certes (talk) 01:32, 28 April 2018 (UTC)
Attempting to expand or pre-process a category tree or a Special:WhatWhatLinksHere page does not work either.
From the final comment in that thread:
This is another use-case for an interface between the MediaWiki API and Lua, even if only some API entry points.