Skip to content

How to get Wikipedia image by title? [closed]

I want to get Image from wikipedia by title, for example I have a image title File:Island of Ireland location map Dublin.svg, and I also know the page id 1642839. Any way to get the image url/link?

Answer

Using Api You can.

https://en.wikipedia.org/w/api.php?action=query&prop=info|extracts|pageimages|images&inprop=url&exsentences=1&titles=india

prop=pageimages

Prop plays an important role.if you want image description, you can get it by prop=pageimages|pageterms

we can also get the original image using piprop=original

or if you want in thumbnail size image, you can get it using piprop=thumbnail&pithumbsize=500 if the size height/width=500

if we want to request in Json format, we should always use formatversion=2 in the Api Query.

Original Image Size

https://en.wikipedia.org/w/api.php?action=query&format=json&formatversion=2&prop=pageimages|pageterms&piprop=original&titles=Albert Einstein

Thumbnail Image Size

https://en.wikipedia.org/w/api.php?action=query&format=json&formatversion=2&prop=pageimages|pageterms&piprop=thumbnail&pithumbsize=500&titles=Albert Einstein

We can fetch the specific data using Api and by Modifying it too On Web and Mobile Apps.