Search code examples
apimediawikimediawiki-api

how to get current page size (that is raw content) in mediawiki api?


I don't know where to put the size argument, here I only managed to get a single edit size:

https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=size&format=xml&titles=United_States_of_America

but I need the size of whole raw content as it is on last revision.


Solution

  • You are getting that, the page United States of America contains the following 69 bytes:

    #REDIRECT [[United States]]
    
    {{Redr|move|from long name|printworthy}}
    

    What this code means is that it's a redirect and the name of the real article is United States.

    https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=size&format=xml&titles=United_States

    This returns the size you want: 267582 bytes.

    Another option would be let the API follow the redirect automatically using redirects:

    https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=size&format=xml&titles=United_States_of_America&redirects