Get description
GET | /core/v1/{project}/{language}/page/{title}/description
|
---|
Returns a description of a page. A page description is a short, plain-text phrase summarizing the page’s topic. While descriptions are available for most pages, some pages may not have a description. In case of a missing description, the API returns a 404 error.
Most Wikimedia projects get page descriptions from the corresponding topic on Wikidata, a free repository of structured knowledge. Page descriptions from Wikidata are licensed under CC0 1.0 Universal Public Domain.
Note: Since English Wikipedia maintains page descriptions locally instead of getting them from Wikidata, page descriptions from English Wikipedia are licensed under Creative Commons Attribution-ShareAlike 3.0 Unported License.
Examples
curl
# Get a short description of the Earth article on English Wikipedia
$ curl https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/description
Python
# Python 3
# Get a short description of the Earth article on English Wikipedia
import requests
page = 'Earth'
url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/' + page + '/description'
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 a short description of the Earth article on English Wikipedia
$url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/description';
$authorization = 'Authorization: Bearer YOUR_ACCESS_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 a short description of the Earth article on English Wikipedia
let url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/description';
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: This endpoint does not support
commons or other multilingual projects. |
title
required path |
Wiki page title with spaces replaced with underscores |
Headers
Accept-Language
optional |
Some Wikimedia projects include content in more than one script. For example, Kurdish Wikipedia includes content in both Latin and Arabic scripts. For languages that support multiple scripts, use this header to specify the script. For example, Accept-Language: ku-arab to request the Kurdish language in Arabic script. Defaults to the wiki's primary script.
Supported languages
|
Responses
200 | Success: Article found. Returns the description property.
Example
{
"description": "Third planet from the Sun in the Solar System"
}
|
---|---|
404 | Error: Description not found
Example
{
"status": 404,
"type": "not_found",
"title": "Short description not found",
"detail": "404: not_found",
"method": "GET",
"uri": "REQUEST_URL"
}
|