MediaWiki API: Get pages by content model

Viewed 35

I'm trying to fetch all pages with a specific content model (js/css) via MediaWiki API. I searched the docs but couldn't find an endpoint accepting that metadata. Is that possible at all?

Thanks in advance!

1 Answers

It looks like even the info prop doesn't return the content model of a page, however, it is still possible with a workaround. You will have to query the logs using the logevents list instead for content model changes/creations, and go through the list and keep track of the ones that have js/css as their latest. An example of the query parameters needed:

{
    "action": "query",
    "format": "json",
    "list": "logevents",
    "leprop": "title|details",
    "letype": "contentmodel",
    "ledir": "newer"
}

https://de.wikipedia.org/wiki/Spezial:ApiSandbox#action=query&list=logevents&leprop=title%7Cdetails&letype=contentmodel&ledir=newer

Related