Search code examples
javascriptmediawikiwikipediawikipedia-apimediawiki-api

Retrieving pageid from Wikipedia parse request


I'm retrieving article content from the Wikipedia api using the parse module:

"http://en.wikipedia.org/w/api.php?action=parse&format=json&page=[...]&callback=JSON_CALLBACK";

What I get back is an object with (amongst other properties) the html content of the requested page on it. What I would also like to have is the pageid of the requested page. Unfortunately this is not included and I can't find a way to get it as well other than making a second request using the query module.

Is it possible to get the pageid when requesting an article using the parse module?


Solution

  • Is it possible to get the pageid when requesting an article using the parse module?

    I don't think so. Usually you know the id/title identifier of the page you are interested in. You will however get back the id of the revision that is parsed.

    What I get back is an object with the html content of the requested page on it.

    If that's the only thing you're interested in, just use the query api! The revision module will get you the parsed content as well:

    http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvparse=1&titles=[…]&format=json&callback=JSON_CALLBACK