TheWhaleOnPluto
TheWhaleOnPluto

Reputation: 51

Trying to retrieve the first image on Wikipedia pages using Wikipedia API - isn't working specifically for articles on video games?

I am attempting to retrieve box art for video game titles from Wikipedia using a GET query and the Wikipedia API. I am using the below query string which seems to be working fine for any other article, such as for the article about the Wii:

https://en.wikipedia.org/w/api.php?action=query&titles=Wii&prop=pageimages&pithumbsize=400&format=json&formatversion=2

Which produces the below result:

{
    "batchcomplete": true,
    "query": {
        "pages": [
            {
                "pageid": 421853,
                "ns": 0,
                "title": "Wii",
                "thumbnail": {
                    "source": "https://upload.wikimedia.org/wikipedia/commons/thumb/1/14/Wii-console.jpg/400px-Wii-console.jpg",
                    "width": 400,
                    "height": 400
                },
                "pageimage": "Wii-console.jpg"
            }
        ]
    }
}

However whenever I try it with any article about an individual video game title it isn't working. For example, for Wii Sports:

https://en.wikipedia.org/w/api.php?action=query&titles=Wii_Sports&prop=pageimages&pithumbsize=400&format=json&formatversion=2

Which produces the below:

{
    "batchcomplete": true,
    "query": {
        "normalized": [
            {
                "fromencoded": false,
                "from": "Wii_Sports",
                "to": "Wii Sports"
            }
        ],
        "pages": [
            {
                "pageid": 5077457,
                "ns": 0,
                "title": "Wii Sports"
            }
        ]
    }
}

Every other title I try is bringing up the same results.

Is there any way to resolve this?

Upvotes: 4

Views: 210

Answers (1)

xdumaine
xdumaine

Reputation: 10329

I believe you will only get image results when the image is free in the public domain or licensed in such a way that it is free to use and not when it is licensed or fair use.

When I query for pageprops on wii, I see a page_image_free and indeed, the image on that page is in the public domain. However, on wii sports, it instead has page_image which means the license is not free, and indeed the image on that page is fair use which means it's not licensed or free.

Upvotes: 2

Related Questions