Get page offline

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

Returns information about a wiki page, including the license, latest revision, and latest content in HTML.

Examples

curl

# Get HTML and metadata for the Earth article on English Wikipedia
$ curl https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/with_html

Python

# Python 3
# Get HTML and metadata for the Earth article on English Wikipedia

import requests

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

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 HTML and metadata for the Earth article on English Wikipedia

$url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/with_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 HTML and metadata for the Earth article on English Wikipedia

let url = 'https://api.wikimedia.org/core/v1/wikipedia/en/page/Earth/with_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: Page found. Returns a page with html 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": "<!DOCTYPE html>..."
}
404 Error: Title or revision not found
Example
{
  "messageTranslations": {
    "en": "The specified title does not exist"
  },
  "httpCode": 404,
  "httpReason": "Not Found"
}