API:REST API/Reference

The history API provides access to the revision history of a wiki page. You can use the history API to explore recent edits to a page, see metadata for a specific revision, compare versions, and get statistics about the history of a page. The history API is available in MediaWiki 1.35 and later.

Exploring page history
A wiki page's history is divided into a sequence of revisions. A revision can be any change to the content of a page: an anonymous editor correcting a typo, an admin reverting vandalism, a bot fixing a citation link. The history API lets you browse through a page's history in segments of 20 revisions.

To see the 20 most recent revisions to a page, make a request to the page history endpoint, including the page title in the path. The page history endpoint returns the latest revision segment, starting with the most recent revision. Each revision object includes the revision ID, which you can use with the get revision and compare revisions endpoints. Revision IDs do not increase sequentially, so you may see an older revision with a higher revision ID than a newer revision.

Let's say we want to look further back in the history of the page. You can use the  URL from the response above to fetch the next 20 oldest revisions, not including the revision specified by the   parameter.

In this example, the API does not return a new  URL, indicating that there are no older revisions left to return. Following the same pattern, the absence of a  URL indicates that there are no newer revisions available.

From here, you can use the  URL to scroll forward in the page's history, or, by requesting the page history without an   or   parameter, return to the most recent revisions. Remember, the page history endpoint can only return up to 20 revisions, so you cannot use both the  and   parameters in the same request.

To get information about a revision, use the revision ID to make a request to the revision endpoint.

Filtering page history
Some revisions are tagged to indicate the type of edit. The page history endpoint supports filtering by edit type, allowing you to request, for example, only edits made by bots or only edits that have since been reverted. See the endpoint reference for the complete list of supported filters.

To see the most recent edits made by bots, call the page history endpoint with the  query parameter set to.

You can pair the  parameter with the   or   parameters to explore page history by revision type. Due to differences in caching infrastructure, the number of revisions returned by the page history filters may not match the statistics returns by the page history counts endpoint.

Comparing revisions
When exploring a page's history, you can use the size and delta to understand the impact of the edit in relation to the previous edit. You can also compare any two revisions line by line using the compare revisions endpoint. The compare revision endpoint takes two revision IDs as path parameters; you can use the page history endpoint to select revision IDs.

To compare revision 388863 to revision 388864, supply the revision IDs in the endpoint path. The API returns a JSON-formatted diff object comparing the two revisions.

). It is used for testing purposes by Wikimedia developers. This wiki is configured to be like en.wikipedia.org. For more information, see [//deployment.wikimedia.beta.wmflabs.org Beta cluster main page] and wikitech:Beta Cluster."       },        {          "type": 1,          "lineNumber": 3,          "text": ""        },        {          "type": 5,          "lineNumber": 4,          "moveInfo": {            "id": "movedpara_3_1_rhs",            "linkId": "movedpara_2_0_lhs",            "linkDirection": 1          },          "text": "Hello, and welcome to the WMF integration environment known as Beta Cluster. The software running this wiki is automatically updated whenever there is a change to the software (currently running  ). It is used for testing purposes by Wikimedia developers. This wiki is configured to be like en.wikipedia.org. For more information, see [//deployment.wikimedia.beta.wmflabs.org Beta cluster main page] and wikitech:Beta Cluster.",         "highlightRanges": [            {              "start": 0,              "length": 77,              "type": 1            }          ]        },        {          "type": 1,          "lineNumber": 5,          "text": ""        },        {          "type": 0,          "lineNumber": 6,          "text": "== Other areas of Wikipedia == "        },        {          "type": 0,          "lineNumber": 7,          "text": ""        }      ]    }  } }

Get page history
Returns information about the 20 latest revisions to a wiki page, starting with the latest revision. The returned revision segment includes API routes for the next oldest, next newest, and latest revisions, letting you scroll through page history. This endpoint responds to the presence a logged-in user and displays content appropriate to that user's permissions.

Get page history counts
Returns historical data about a page's history.

Get revision
Returns details for an individual revision. This endpoint responds to the presence a logged-in user and displays content appropriate to that user's permissions.

Compare revisions
Returns data that lets you display a line-by-line comparison of two revisions. (See an example.) Only text-based wiki pages can be compared; trying to compare revisions of other page types, such as image pages, results in a 400 response code. This endpoint responds to the presence a logged-in user and displays content appropriate to that user's permissions.

The compare revisions endpoint requires Wikidiff2 1.9.0 or later.

Count the number of revisions between two revisions
Returns the number of intermediate revisions that occurred between two given revision IDs. For example, if the revision IDs 1 -> 2 -> 3 -> 4 happen in sequence:


 * The number of intermediate revisions between 1 and 2 is 0
 * The number of intermediate revisions between 1 and 3 is 1