2

Is it possible to use the MediaWiki API to return a random image? If so can I specify a filetype such as SVG?

Tim
  • 71
  • 1
  • 7

1 Answers1

4

Random, yes; by file type, no.

If you know that the image namespace is 6, then you can use:

http://commons.wikimedia.org/w/api.php?action=query&list=random&rnnamespace=6

Note that most images on Wikipedia are on Wikimedia Commons, hence the commons.wikimedia.org URL. If you want image info, such as the URL, use random as a generator:

http://commons.wikimedia.org/w/api.php?action=query&generator=random&grnnamespace=6&prop=imageinfo&iiprop=url

Bryan
  • 692
  • 5
  • 9