3

I need to know all the different URLs that lead to the same end Wikipedia article URL for a project I'm doing. For example:

https://en.wikipedia.org/wiki/Lucite

redirects to the final URL:

https://en.wikipedia.org/wiki/Poly(methyl_methacrylate)

However, I'm not sure how many other URLs also redirect to the final URL of that page, times this issue for every other Wikipedia article. Is there a specific API call I'm not seeing that you can send a final page_name/URL, and it returns a JSON of all the name/URLs that redirect to the final URL? I really need something like this if it exists. For reference, I already looked, and I'm aware of the fact that you can perform two API calls for all pages like this:

https://en.wikipedia.org/w/api.php?action=query&generator=allpages&format=json&gaplimit=500&gapfilterredir=nonredirects

then the one that is nonfiltering of redirects

https://en.wikipedia.org/w/api.php?action=query&generator=allpages&format=json&gaplimit=500&

I understand that you can take the disjoint of these two sets and those are redirecting URLs, and that you can do it ad infinitum for all pages and find all redirecting names/URLs, but it would save me on my project exponential time if I could simply find a way to send a URL to Wikipeidia's API and somehow get a list of all URLs leading back to that final page URL. Thank you in advance!

EazyC
  • 809
  • 1
  • 10
  • 30
  • 1
    Note that while you can get a list of *pages* which redirect to a given page, the list of *URLs* redirecting there is infinite due to URL normalization. For example, `Lucite`, `Lucite_` and `Lucite__` will all redirect to the same place. – Tgr Jul 16 '16 at 21:36
  • Duly noted thank you. Thankfully, I just needed a direct mapping of redirects on wikipedia like the answer below because I wanted to make sure I had all possible hrefs to a specific page stored because that way I won't be miscounting how many "internal backlinks" each wikipedia article has throughout all of wikipedia itself. – EazyC Jul 17 '16 at 22:02

1 Answers1

5

I think you need this I think you need this

https://en.wikipedia.org/w/api.php?action=query&titles=Poly(methyl_methacrylate)&prop=redirects&format=jsonfm