GET /core/v1/{project}/{language}/page/{title}/history/counts/{type}

Returns data about a page's history.

Examples

curl

# Get the number of edits made to the Earth article on English Wikipedia between revisions 986561235 and 985158000
$ curl https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/history/counts/edits?from=986561235&to=985158000

Python

# Python 3
# Get the number of edits made to the Earth article on English Wikipedia between revisions 986561235 and 985158000

import requests

page = 'Earth'
url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/' + page + '/history/counts/edits'
from_revision = 986561235
to_revision = 985158000
parameters = {'from': from_revision, 'to': to_revision}

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 the number of edits made to the Earth article on English Wikipedia between revisions 986561235 and 985158000

$page = 'Earth';
$count_type = 'edits';
$params = array('from' => 986561235, 'to' => 985158000);
$authorization = 'Authorization: Bearer YOUR_ACCESS_TOKEN';

$endpoint = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/' . $page . '/history/counts/' . $count_type;
$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 the number of edits made to the Earth article on English Wikipedia between revisions 986561235 and 985158000

let url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/history/counts/edits?from=986561235&to=985158000';
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.
Note: The language parameter is prohibited for commons and other multilingual projects.
title

required path

Wiki page title
type

required path

Type of count, one of:
  • anonymous: Edits made by anonymous users. Limit: 10,000
  • bot: Edits made by bots. Limit: 10,000
  • editors: Users or bots that have edited a page. Limit: 25,000
  • edits: Any change to page content. Limit: 30,000
  • minor: Edits marked as minor. If the minor edit count exceeds 2,000, the API returns a 500 error. Limit: 1,000
  • reverted: Edits that revert an earlier edit. Limit: 30,000
For edits and editors types only:
from

optional query

Restricts the count to between two revisions, specified by revision ID. The from and to query parameters must be used as a pair. The result excludes the edits or editors represented by the from and to revisions.
to

optional query

Responses

200 Success
Example
{
  "count": 99,
  "limit": false
}
400 Error: Invalid parameter or combination of parameters
Example
{
  "messageTranslations": {
    "en": "The specified combination of parameters is not supported."
  },
  "httpCode": 400,
  "httpReason": "Bad Request"
}
404 Error: Title or revision not found
Example
{
  "messageTranslations": {
    "en": "The specified title does not exist"
  },
  "httpCode": 404,
  "httpReason": "Not Found"
}
500 Error: Minor edit count exceeds 2000
Example
{
  "messageTranslations": {
    "en": "The specified title contains too many revisions to retrieve this count."
  },
  "httpCode": 500,
  "httpReason": "Internal Server Error"
}

Response schema

count

required integer

The value of the data point up to the type's limit. If the value exceeds the limit, the API returns the limit as the value of count and sets the limit property to true.
limit

required boolean

Returns true if the data point exceeds the type's limit.