Get page
GET | /core/v1/{project}/{language}/page/{title}/bare
|
---|
Returns the standard page object for a wiki page, including the API route to fetch the latest content in HTML, the license, and information about the latest revision.
Examples
curl
# Get information about the Earth article on English Wikipedia
$ curl https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/bare
Python
# Python 3
# Get information about the Earth article on English Wikipedia
import requests
page = 'Earth'
url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/' + page + '/bare'
headers = {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'User-Agent': 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)'
}
response = requests.get(url, headers=headers)
data = response.json()
print(data)
PHP
<?php
// Get information about the Earth article on English Wikipedia
$url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/bare';
$token = 'YOUR_ACCESS_TOKEN';
$authorization = 'Authorization: Bearer ' . $token;
$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 information about the Earth article on English Wikipedia
let url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/bare';
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 |
Responses
200 | Success: Page found. Returns a page with the html_url property.
Example
{
"id": 9228,
"key": "Earth",
"title": "Earth",
"latest": {
"id": 989181479,
"timestamp": "2020-11-17T14:42:31Z"
},
"content_model": "wikitext",
"license": {
"url": "//creativecommons.org/licenses/by-sa/3.0/",
"title": "Creative Commons Attribution-Share Alike 3.0"
},
"html_url": "https://en.wikipedia.org/w/rest.php/v1/page/Earth/html"
}
|
---|---|
404 | Error: Title or revision not found
Example
{
"messageTranslations": {
"en": "The specified title does not exist"
},
"httpCode": 404,
"httpReason": "Not Found"
}
|