Template:ApiEx/sv

From mediawiki.org
This page is a translated version of the page Template:ApiEx and the translation is 70% complete.


Template documentation

Använd den här mallen på API-dokumentationssidor för att formatera ett exempel av en API-begäran.

Notera som ett alternativ, {{Api help }} infogar lokaliserad API-dokumentation genererad från källkod som normalt sett har API-exempel i sig.

User:SPage (WMF)/ApiEx utility skapar en åkallan på en {{ApiEx }}-mall om du klipper in en api.php-URL i den.

Användning

{{ApiEx
| desc=Capitalization, localization, "_" => " ", "Project" => "Wikipedia", ...
| p1=action=query
| p2=titles=Project:articleA{{!}}article_B
| result=<syntaxhighlight 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>
</syntaxhighlight>
| post={{ApiEx/Post|parameter=days|value=integer|default=7|comment=comment}}
}}

Parametrar

  • desc — Beskrivning av en API-begäran
  • lang — kod i två bokstäver för wikispråket. Förinställt som 'en'.
  • site — sidans hela URL som ska användas i exempel (t.ex., www.mediawiki.org) Överskrider parametern lang.
  • p1-p9 — parametergrupper, var och en innehåller antingen ett par param=value eller flera par separerade av ett et-tecken (&), t.ex. p3=param=value&paramB=valueBbbb
  • 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 | result=<syntaxhighlight lang="javascript">PASTE RESPONSE HERE</syntaxhighlight>
  • post — a "list" of {{ApiEx/Post }} objects, to generate a post table
  • collapse — set to "no" to stop "result" and "post" sections from being collapsed with {{Mall:Fäll ihop toppen }}/{{Collapse bottom }}
  • apisandbox — whether to show a "[try in ApiSandbox]" link that loads the example API query parameters into Special:ApiSandbox. Default is 1, add | apisandbox=0 to not show this link.

Anteckningar

  • This template outputs a wikitext link. Any spaces in the URL parameters p1...p9 will garble the link, so change them to %20.
  • Similarly, any pipe-separate values in the URL parameters such as a group of pages "title1|title2" must be escaped, so use the {{!}} magic word.

Exempel

Capitalization, localization, "_" => " ", "Project" => "Wikipedia", ...

Resultat
Postparametrar
Parameternamn Värde Förinställt Kommentar
days integer 7 comment
<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>