wikipediawikipedia-apimediawiki-api

Wikipedia API: How to get article on a specific date?


I want to find a way to get the contents of a Wikipedia article on a specific date. For example, I'd like to see an article in the version it was on January 1 2022.

Given none of these methods work well, what is the correct way of retrieving a Wiki entry from a given date?


Solution

  • Use the Action API's prop=revisions instead:

    https://en.wikipedia.org/w/api.php
    ?action=query
    &format=json
    &formatversion=2
    
    &titles=Jupiter
    
    &prop=revisions
    &rvprop=timestamp|ids
    &rvlimit=1
    &rvstart=2022-01-01T00:00:00.000Z
    

    Try it using the API sandbox.

    rvstart denotes the timestamp from which MediaWiki will start enumerating, and rvlimit=1 means that we are only interested in the first revision it has to offer.

    rvprop controls which data properties to be included in each revision's result; timestamp is for that revision's timestamp, and ids is for its and the previous revision's IDs.