move usage documentation to subpage, per Template:Documentation doc
New page
{{Documentation subpage}}
<!-- Categories go at the bottom of this page and interwikis go in Wikidata. -->
Use this template on [[API:Main page|API]] documentation pages to format an example API request.
Note as an alternative, {{tl|Api help}} transcludes localized API documentation generated from source code which normally has API examples in it.
== Usage ==
<pre><nowiki>
{{TNT|ApiEx
| desc=Capitalization, localization, "_" => " ", "Project" => "Wikipedia", ...
| p1=action=query
| p2=titles=Project:articleA{{!}}article_B
| result=<source lang="xml">
<api>
<query>
<normalized>
<n from="Project:articleA" to="Wikipedia:ArticleA" />
<n from="article_B" to="Article B" />
</normalized>
<pages>
<page ns="4" title="Wikipedia:ArticleA" missing="" />
<page ns="0" title="Article B" missing="" />
</pages>
</query>
</api>
</source>
}}
</nowiki></pre>
== Parameters ==
* desc - API request description
* lang - two-letter code for the wiki language. 'en' by default.
* site - full URL of site to use in example (e.g., www.mediawiki.org). Overrides lang parameter.
* p1-p9 - parameter groups, each containing either one param=value pair or multiple pairs each separated by an ampersand (&), e.g. <kbd>p3=param=value¶mB=valueBbbb</kbd>). Changes spaces in parameter values to <code>%20</code>.
* result - the result of the query execution. Add the template, preview, click the api.php link, and copy and paste the API response into the template as<br><kbd><nowiki>| result=<source lang="javascript"></nowiki>''PASTE RESPONSE HERE''</source></kbd>
* post - a "list" of {{tl|ApiEx/Post}} objects, to generate a post table
* collapse - set to "no" to stop "result" and "post" sections from being collapsed with {{tl|Collapse top}}/{{tl|Collapse bottom}}
== Notes ==
* This template outputs a wikitext link. Any spaces in the URL parameters <code>p1</code>...<code>p9</code> will garble the link, so change them to <code>%20</code>.
* Similarly, any pipe-separate values in the URL parameters such as a group of pages "title1|title2" must be escaped, so use the <code><nowiki>{{!}}</nowiki></code> magic word.
== Example ==
{{ {{TNTN|ApiEx}}
| desc=Capitalization, localization, "_" => " ", "Project" => "Wikipedia", ...
| p1=action=query
| p2=titles=Project:articleA{{!}}article_B
| result=<source lang="xml">
<api>
<query>
<normalized>
<n from="Project:articleA" to="Wikipedia:ArticleA" />
<n from="article_B" to="Article B" />
</normalized>
<pages>
<page ns="4" title="Wikipedia:ArticleA" missing="" />
<page ns="0" title="Article B" missing="" />
</pages>
</query>
</api>
</source>
}}
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox||
<!-- Categories go here and interwikis go in Wikidata. -->
[[Category:API templates{{translation}}|ApiEx]]
}}</includeonly>