Get page history
GET | /core/v1/{project}/{language}/page/{title}/history
|
---|
Returns information about the latest revisions to a wiki page, in segments of 20 revisions, starting with the latest revision. The response includes API routes for the next oldest, next newest, and latest revision segments, letting you scroll through page history.
Examples
curl
# Get revisions to the Earth article on English Wikipedia made by bots prior to revision 981126172
$ curl https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/history?filter=bot&older_than=981126172
Python
# Python 3
# Get revisions to the Earth article on English Wikipedia made by bots prior to revision 981126172
import requests
page = 'Earth'
url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/' + page + '/history'
filter_type = 'bot'
older_than = 981126172
parameters = {'filter': filter_type, 'older_than': older_than}
headers = {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'User-Agent': 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)'
}
response = requests.get(url, headers=headers, params=parameters)
data = response.json()
print(data)
PHP
<?php
// Get revisions to the Earth article on English Wikipedia made by bots prior to revision 981126172
$page = 'Earth';
$params = array('filter' => 'bot', 'older_than' => '939967546');
$authorization = 'Authorization: Bearer YOUR_ACCESS_TOKEN';
$endpoint = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/' . $page . '/history';
$url = $endpoint . '?' . http_build_query($params);
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array( $authorization ));
curl_setopt( $ch, CURLOPT_USERAGENT, 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)' );
$output = curl_exec( $ch );
curl_close( $ch );
echo( $output );
?>
JavaScript
// Get revisions to the Earth article on English Wikipedia made by bots prior to revision 981126172
let url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/history?filter=bot&older_than=981126172';
let response = await fetch( url,
{
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Api-User-Agent': 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)'
}
}
);
response.json()
.then(console.log).catch(console.error);
Parameters
project
required path |
Project name. For example: wikipedia (encyclopedia articles), commons (images, audio, and video), wiktionary (dictionary entries). List all projects.
|
language
required path |
Language code. For example: ar (Arabic), en (English), es (Spanish). List supported languages.
|
title
required path |
Wiki page title |
older_than
optional query |
Accepts a revision ID. Returns the next 20 revisions older than the given revision ID. |
newer_than
optional query |
Accepts a revision ID. Returns the next 20 revisions newer than the given revision ID. |
filter
optional query |
Use a filter to return only revisions tagged as:
This endpoint supports one |
Responses
200 | Success: Revisions found.
Example
{
"revisions": [
{
"id": 980777318,
"timestamp": "2020-09-28T11:33:07Z",
"minor": false,
"size": 171755,
"comment": "Alter: title, url. URLs might have been internationalized/anonymized. Add: s2cid, pmid, doi-broken-date, pages, author pars. 1-1. Removed parameters. Formatted [[WP:ENDASH|dashes]]. Some additions/deletions were actually parameter name changes. | You can [[WP:UCB|use this bot]] yourself. [[WP:DBUG|Report bugs here]]. | Suggested by Abductive | All pages linked from cached copy of Black_Sea | via #UCB_webform_linked",
"user": {
"id": 7903804,
"name": "Citation bot"
},
"delta": 194
}
],
"latest": "https://en.wikipedia.org/w/rest.php/v1/page/Earth/history?filter=bot",
"older": "https://en.wikipedia.org/w/rest.php/v1/page/Earth/history?filter=bot&older_than=911020152",
"newer": "https://en.wikipedia.org/w/rest.php/v1/page/Earth/history?filter=bot&newer_than=980777318"
}
|
---|---|
400 | Error: Revision identifier must be greater than 0
Example
{
"messageTranslations": {
"en": "Revision id must be greater than 0"
},
"httpCode": 400,
"httpReason": "Bad Request"
}
|
400 | Error: Parameters older_than and newer_than cannot both be specified
Example
{
"messageTranslations": {
"en": "Parameters \"older_than\" and \"newer_than\" cannot both be specified"
},
"httpCode": 400,
"httpReason": "Bad Request"
}
|
Response schema
latest
required string |
API route to get the latest revisions |
older
optional string |
If available, API route to get the prior revisions |
newer
optional string |
If available, API route to get the following revisions |
revisions
required string |
Array of 0-20 revisions |