<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.mediawiki.org/w/index.php?action=history&amp;feed=atom&amp;title=API%3AMain_module%2FSample_code_1</id>
	<title>API:Main module/Sample code 1 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.mediawiki.org/w/index.php?action=history&amp;feed=atom&amp;title=API%3AMain_module%2FSample_code_1"/>
	<link rel="alternate" type="text/html" href="https://www.mediawiki.org/w/index.php?title=API:Main_module/Sample_code_1&amp;action=history"/>
	<updated>2026-08-21T01:40:44Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.47.0-wmf.16</generator>
	<entry>
		<id>https://www.mediawiki.org/w/index.php?title=API:Main_module/Sample_code_1&amp;diff=5720637&amp;oldid=prev</id>
		<title>AKlapper (WMF): Do not set width for the code example tabbed window to 60% only but use full width. Makes reading on mobile screens easier. See phab:T327220.</title>
		<link rel="alternate" type="text/html" href="https://www.mediawiki.org/w/index.php?title=API:Main_module/Sample_code_1&amp;diff=5720637&amp;oldid=prev"/>
		<updated>2023-01-17T22:09:56Z</updated>

		<summary type="html">&lt;p&gt;Do not set width for the code example tabbed window to 60% only but use full width. Makes reading on mobile screens easier. See &lt;a href=&quot;https://phabricator.wikimedia.org/T327220&quot; class=&quot;extiw&quot; title=&quot;phab:T327220&quot;&gt;phab:T327220&lt;/a&gt;.&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:09, 17 January 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
  &lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;!-- Don&#039;t change div class name --&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;!-- Don&#039;t change div class name --&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;div class=&quot;mw-gadget-tabbedwindow&quot; style=&quot;width:&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;60&lt;/del&gt;%&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;div class=&quot;mw-gadget-tabbedwindow&quot; style=&quot;width:&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;100&lt;/ins&gt;%&quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Python ===&lt;/div&gt;&lt;/td&gt;
  &lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;
  &lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Python ===&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>AKlapper (WMF)</name></author>
	</entry>
	<entry>
		<id>https://www.mediawiki.org/w/index.php?title=API:Main_module/Sample_code_1&amp;diff=3693253&amp;oldid=prev</id>
		<title>Zaycodes: Updated as per phab:T232816 API documentation improvements</title>
		<link rel="alternate" type="text/html" href="https://www.mediawiki.org/w/index.php?title=API:Main_module/Sample_code_1&amp;diff=3693253&amp;oldid=prev"/>
		<updated>2020-03-04T07:16:51Z</updated>

		<summary type="html">&lt;p&gt;Updated as per phab:T232816 API documentation improvements&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;!-- Don&amp;#039;t change div class name --&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-gadget-tabbedwindow&amp;quot; style=&amp;quot;width:60%&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Python ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/python3&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    main_module.py&lt;br /&gt;
&lt;br /&gt;
    MediaWiki API Demos&lt;br /&gt;
    Demo of `Main module` module: Get help for the main module.&lt;br /&gt;
&lt;br /&gt;
    MIT License&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
import requests&lt;br /&gt;
&lt;br /&gt;
S = requests.Session()&lt;br /&gt;
&lt;br /&gt;
URL = &amp;quot;https://en.wikipedia.org/w/api.php&amp;quot;&lt;br /&gt;
&lt;br /&gt;
PARAMS = {&lt;br /&gt;
    &amp;quot;action&amp;quot;: &amp;quot;help&amp;quot;,&lt;br /&gt;
    &amp;quot;format&amp;quot;: &amp;quot;json&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
R = S.get(url=URL, params=PARAMS)&lt;br /&gt;
DATA = R.json()&lt;br /&gt;
&lt;br /&gt;
print(DATA)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== PHP ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
/*&lt;br /&gt;
    main_module.php&lt;br /&gt;
&lt;br /&gt;
    MediaWiki API Demos&lt;br /&gt;
    Demo of `Main module` module: Get help for the main module.&lt;br /&gt;
&lt;br /&gt;
    MIT License&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
$endPoint = &amp;quot;https://en.wikipedia.org/w/api.php&amp;quot;;&lt;br /&gt;
$params = [&lt;br /&gt;
    &amp;quot;action&amp;quot; =&amp;gt; &amp;quot;help&amp;quot;,&lt;br /&gt;
    &amp;quot;format&amp;quot; =&amp;gt; &amp;quot;json&amp;quot;&lt;br /&gt;
];&lt;br /&gt;
&lt;br /&gt;
$url = $endPoint . &amp;quot;?&amp;quot; . http_build_query( $params );&lt;br /&gt;
&lt;br /&gt;
$ch = curl_init( $url );&lt;br /&gt;
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );&lt;br /&gt;
$output = curl_exec( $ch );&lt;br /&gt;
curl_close( $ch );&lt;br /&gt;
&lt;br /&gt;
$result = json_decode( $output, true );&lt;br /&gt;
var_dump( $result );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== JavaScript ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
    main_module.js&lt;br /&gt;
&lt;br /&gt;
    MediaWiki API Demos&lt;br /&gt;
    Demo of `Main module` module: Get help for the main module.&lt;br /&gt;
&lt;br /&gt;
    MIT License&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
var url = &amp;quot;https://en.wikipedia.org/w/api.php&amp;quot;; &lt;br /&gt;
&lt;br /&gt;
var params = {&lt;br /&gt;
    action: &amp;quot;help&amp;quot;,&lt;br /&gt;
    format: &amp;quot;json&amp;quot;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
url = url + &amp;quot;?origin=*&amp;quot;;&lt;br /&gt;
Object.keys(params).forEach(function(key){url += &amp;quot;&amp;amp;&amp;quot; + key + &amp;quot;=&amp;quot; + params[key];});&lt;br /&gt;
&lt;br /&gt;
fetch(url)&lt;br /&gt;
    .then(function(response){return response.json();})&lt;br /&gt;
    .then(function(response) {console.log(response);})&lt;br /&gt;
    .catch(function(error){console.log(error);});&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== MediaWiki JS ===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
	main_module.js&lt;br /&gt;
&lt;br /&gt;
	MediaWiki API Demos&lt;br /&gt;
	Demo of `Main module` module: Get help for the main module.&lt;br /&gt;
&lt;br /&gt;
	MIT License&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
var params = {&lt;br /&gt;
		action: &amp;#039;help&amp;#039;,&lt;br /&gt;
		format: &amp;#039;json&amp;#039;&lt;br /&gt;
	},&lt;br /&gt;
	api = new mw.Api();&lt;br /&gt;
&lt;br /&gt;
api.get( params ).done( function ( data ) {&lt;br /&gt;
	console.log( data );&lt;br /&gt;
} );&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Zaycodes</name></author>
	</entry>
</feed>