juanpex
juanpex

Reputation: 140

How to get all Wikipedia pages from category with title and primary image?

I want to list all pages from category with the title and primary image.

My current API url is this:

https://en.wikipedia.org/w/api.php?action=query&cmlimit=100&list=categorymembers&cmtitle=Category%3AAmerican%20male%20film%20actors

with this results:

....
{
    "pageid": 3600962,
    "ns": 0,
    "title": "Lee Aaker"
},
....

I don't know the right parameters to get a response like this:

{
   "pageid": 3600962,
   "ns": 0,
   "title": "Lee Aaker",
   "thumbnail": {
       "original": "https://upload.wikimedia.org/wikipedia/some_image_path.jpg"
    }
}

Upvotes: 2

Views: 1207

Answers (1)

Termininja
Termininja

Reputation: 7036

You can do this by using categorymembers in combination with pageimages:

https://en.wikipedia.org/w/api.php?action=query&generator=categorymembers&gcmlimit=100&gcmtitle=Category:American male film actors&prop=pageimages&pilimit=100
  • categorymembers parameters: gcmtitle=Category:American male film actors, gcmlimit=100
  • pageimages parameters: pilimit=100

Upvotes: 3

Related Questions