API:REST API/Reference/Sample code:Get revision with HTML
< API:REST API | Reference
curl
edit# Get information about revision 764138197 along with rendered HTML
$ curl "https://en.wikipedia.org/w/rest.php/v1/revision/764138197/with_html"
Python
edit# Get information about revision 764138197 along with rendered HTML
import requests
url = 'https://en.wikipedia.org/w/rest.php/v1/revision/764138197/with_html'
headers = {
'User-Agent': 'MediaWiki REST API docs examples/0.1 (https://www.mediawiki.org/wiki/API_talk:REST_API)'
}
response = requests.get(url, headers=headers)
data = response.json()
print(data)
PHP
edit<?php
/*
Get information about revision 764138197 along with rendered HTML
*/
$url = "https://en.wikipedia.org/w/rest.php/v1/revision/764138197/with_html";
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_USERAGENT, "MediaWiki REST API docs examples/0.1 (https://www.mediawiki.org/wiki/API_talk:REST_API)" );
$output = curl_exec( $ch );
curl_close( $ch );
echo($output);
?>
JavaScript
edit/*
Get information about revision 764138197 along with rendered HTML
*/
async function doFetch() {
let url = "https://en.wikipedia.org/w/rest.php/v1/revision/764138197/with_html";
let headers = {'Api-User-Agent': 'MediaWiki REST API docs examples/0.1 (https://www.mediawiki.org/wiki/API_talk:REST_API)'}
const rsp = await fetch(url, headers);
const data = await rsp.json();
return data;
}
async function fetchAsync()
{
try {
let result = await doFetch();
console.log(result);
} catch( err ) {
console.error( err.message );
}
}
fetchAsync();