Get Extract From Wikipedia Page With The Wikipedia API
July 3, 2020 by Andreas Wik
I recently needed a way to fetch the beginning of Wikipedia pages (leadermap.org). The Wikipedia API gives you a quick way to do this without authenticating.
The API endpoint lives at: https://en.wikipedia.org/w/api.php
We can get the extract from a page in JSON format by passing a few parameters to it, namely format=json, origin=*, action=query, prop=extracts, explaintext, exintro, titles=my+title
So to get the extract of Kobe Bryant’s Wikipedia page, I would use:
Play around with the parameters for different results. If you leave explaintext out, for example, the extract will come back with HTML tags.
GLHF