I am trying to use the wikimedia API for wiki commons at:
http://commons.wikimedia.org/w/api.php
It seems like the commons API is very immature
have a look at Mediawiki and try this function:
import json, requests
def extract_image_license(image_name):
start_of_end_point_str = 'https://commons.wikimedia.org' \
'/w/api.php?action=query&titles=File:'
end_of_end_point_str = '&prop=imageinfo&iiprop=user' \
'|userid|canonicaltitle|url|extmetadata&format=json'
result = requests.get(start_of_end_point_str + image_name+end_of_end_point_str)
result = result.json()
page_id = next(iter(result['query']['pages']))
image_info = result['query']['pages'][page_id]['imageinfo']
return image_info
then you call the function and pass in the image name you want to query for example:
extract_image_license('Albert_Einstein_Head.jpg')