mediawikimediawiki-api

get all sections separately with wikimedia api


I try to get all seperate sections of a wikipedia article through the api.

I know already :

Howto retrieve all sections seperately with one request ? (JSON Array for example)


Solution

  • What you ask is called parsing, because it requires interpretation of the wikitext source to split the page by sections etc. So the solution is given in https://www.mediawiki.org/wiki/API:Parsing_wikitext

    1) Get the list of sections: https://www.mediawiki.org/w/api.php?action=parse&page=API:Parsing_wikitext&prop=sections

    2) Ask the parsed wikitext of that section: https://www.mediawiki.org/w/api.php?action=parse&page=API:Parsing_wikitext&section=1&prop=text