Core REST API/Reference/Pages/Get HTML

GET /core/v1/{project}/{language}/page/{title}/html

Returns the latest content of a wiki page in HTML. This endpoint returns content type text/html.

Examples

curl

# Get the HTML version of the Earth article on English Wikipedia
$ curl https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/html

Python

# Python 3
# Get the HTML version of the Earth article on English Wikipedia

import requests

page = 'Earth'
url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/' + page + '/html'

headers = {
  'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
  'User-Agent': 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)'
}

response = requests.get(url, headers=headers)
print(response.text)

PHP

<?php
// Get the HTML version of the Earth article on English Wikipedia

$url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/html';
$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 the HTML version of the Earth article on English Wikipedia

let url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/html';
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

Responses

200 Success: Returns page HTML.
404 Error: Title or revision not found
Example
{
  "messageTranslations": {
    "en": "The specified title does not exist"
  },
  "httpCode": 404,
  "httpReason": "Not Found"
}