How to get the contents of a wiki template?

Does anyone know how to access the body of a template inside a page?

I am familiar with an API that returns a list of ALL templates that exist on a page , but how can I access the body template? Is there an API for this? So far I see only one possible way ... to parse it manually. I'm wrong?

+4
source share
2 answers

You can use the expandtemplates API call or the rvexpandtemplates parameter for the revisions API call.

+6
source

This is an old question, but it helped me figure out how to get a mediawiki page with advanced template macros. Very useful if you are doing the conversion.

 <MW_BASEURL>/api.php?action=query&prop=revisions &titles=<url_encoded_page_title>&format=xml&rvprop=content&rvexpandtemplates 

I am parsing the xml returned from this request to get an extended page.

+2
source

All Articles