Search code examples
mediawikiwikipediawikipedia-apimediawiki-api

Wikipedia API - How to get all links from multiple pages?


I'm new to wiki api. I have read how to get all links from a specific page, and managed to do so, but in my case I need a list of links from many pages. And sending a request for each page is inefficient. This is the kind of request I use -

http://en.wikipedia.org/w/api.php?action=query&format=jsonfm&generator=links&gpllimit=500&redirects=true&pageids=1234

I must admit that I don't fully understand what each argument means. So -

  1. How do you chain multiple pageids to 'pageids' argument? I guess that's a silly question but I didn't find any reference :\
  2. Can the response point out which page owns each link?

Thanks!


Solution

  • You can just join page IDs (or names if you use the titles parameter) with | which is in general how you make lists in the MediaWiki API. I don't think there is a way to find out which link comes from which page, though.