Is it possible to download images from Wikipedia with MediaWiki API?
Asked
Active
Viewed 5,403 times
7
-
1Are you looking for a specific image or set of images? The API will help you find say the images used on a page but you don't need the API to actually download the image. You just need to point your browser or curl or wget at the image URL. – Christian Sep 19 '12 at 17:50
2 Answers
10
No, it is not possible to get the images via the API. Images in a MediaWiki are stored just in folders, not in a database and are not delivered dynamically (more information on that in the Manual:Image administration).
However, you can retrieve the URLs of those image files via the API. For example see the API:Allimages list or imageinfo property querymodules. Then you can download the files from those URLs with your favourite tool (curl
, wget
, whatever).
If your question is about downloading all images from Wikipedia, meta:data dumps would be a good start. You also may ask on the data-dump mailing list on how to sync with a repository like Wikimedia Commons.

Bergi
- 630,263
- 148
- 957
- 1,375
-
This is not strictly true, private wikis force image requests to go via a PHP file that streams them only after an authentication check. And while MediaWiki defaults to storing on the file system, it does support alternative file backends. – Krenair Nov 06 '16 at 06:49
-
@Krenair Thanks, I must have missed the link to [Manual:Image Authorization](https://www.mediawiki.org/wiki/Manual:Image_Authorization). Still, regardless of the file backend, the API only will get you the location of the image file. – Bergi Nov 06 '16 at 11:35
2
Given you know the file's name, no need for the API. This works:
# Curl download, -L: follow redirect, -C -: resume downloads, -O: keep filename
curl -L -C - -O http://commons.wikimedia.org/wiki/Special:FilePath/Example.jpg # Example.jpg

Hugolpz
- 17,296
- 26
- 100
- 187