Search code examples
mediawikimediawiki-apiwikimedia

MediaWiki query wont redirect


I am getting some #REDIRECT in the snippet but i actually want the query to give me the redirected results, is there a way to do that without parsing what the redirect is and initialed another query? I tried setting the parameter redirects but it did nothing.

Example: https://en.wikipedia.org/w/api.php?format=json&action=query&list=search&srsearch=Unity3D&utf8&srlimit=10&srwhat=nearmatch&redirects

i would like it to return something like this: https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=Unity%20(game%20engine)&srlimit=1


Solution

  • What you can do is to use search as a generator. If you do that, redirects will work:

    https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrsearch=Unity3D&utf8&gsrlimit=10&gsrwhat=nearmatch&redirects