Wikipedia API - skolakoda/programming-quotes GitHub Wiki

API for an image

https://en.wikipedia.org/w/api.php?action=query&origin=*&titles=Aristotle&prop=pageimages&format=json&pithumbsize=50

  • param titles: title of a wiki page
  • param pithumbsize: image size

API for a lead paragraph

https://en.wikipedia.org/w/api.php?action=query&titles=Albert%20Einstein&prop=extracts&format=json&exintro

  • titles: title of a wiki page, i.e. person name
  • exintro: only introductory pagragraph, not a whole article
  • explaintext: plan text, instead of HTML

Important parameters

  • redirects=1 allows redirection. Without it, there's no response if page was renamed.
  • origin=* solves CORS problem.

Pipes

With one API request we can get information from multiple wiki pages (up to 50). We just need to connect params with pipes |, for example: titles=Socrates|Aristotle|Plato

https://en.wikipedia.org/w/api.php?action=query&titles=Socrates|Aristotle|Plato&prop=extracts&format=json&exintro