Sfoglia il codice sorgente

More updates for API documentation.

pull/24/head
Ben Kurtovic 10 anni fa
parent
commit
7ea8f00f68
2 ha cambiato i file con 17 aggiunte e 6 eliminazioni
  1. +7
    -0
      static/api.css
  2. +10
    -6
      templates/api.mako

+ 7
- 0
static/api.css Vedi File

@@ -13,10 +13,12 @@ span.code {

span.param-key {
color: #009;
font-weight: bold;
}

span.param-val {
color: #900;
font-weight: bold;
}

table.parameters {
@@ -52,3 +54,8 @@ a:link { color: #373; text-decoration: none; }
a:visited { color: #373; text-decoration: none; }
a:hover { color: #040; text-decoration: underline; }
a:active { color: #404; text-decoration: underline; }

a.no-color:link { color: #000; text-decoration: none; }
a.no-color:visited { color: #000; text-decoration: none; }
a.no-color:hover { color: #000; text-decoration: underline; }
a.no-color:active { color: #000; text-decoration: underline; }

+ 10
- 6
templates/api.mako Vedi File

@@ -153,7 +153,7 @@
</table>
<h2>Responses</h2>
<p>The JSON response object always contains a <span class="code">status</span> key, whose value is either <span class="code">ok</span> or <span class="code">error</span>. If an error has occurred, the response will look like this:</p>
<pre>{
<pre>{
"status": "error",
"error": {
"code": (string) error code,
@@ -161,7 +161,7 @@
}
}</pre>
<p>Valid responses for <span class="code">action=compare</span> and <span class="code">action=search</span> are formatted like this:</p>
<pre>{
<pre>{
"status": "ok",
"meta": {
"time": (float) time to generate results, in seconds,
@@ -196,7 +196,7 @@
<p>In the case of <span class="code">action=search</span>, <span class="code">sources</span> will contain one entry for each source checked (or skipped if the check ends early), sorted in order of confidence, with skipped sources at the bottom.</p>
<p>In the case of <span class="code">action=compare</span>, <span class="code">best</span> will always contain information about the URL that was given, so <span class="code">response["best"]["url"]</span> will never be <span class="code">null</span>. Also, <span class="code">sources</span> will always contain one entry, with the same data as <span class="code">best</span>, since only one source is checked in comparison mode.</p>
<p>Valid responses for <span class="code">action=sites</span> are formatted like this:</p>
<pre>{
<pre>{
"status": "ok",
"langs": [
[
@@ -213,10 +213,14 @@
...
]
}</pre>
<h2>Caveats</h2>
<ul>
<li>There is currently no way to get the contents of the article or suspected source, nor can you get the data behind the visual comparison available from the main tool. This may be changed in a future version if there is sufficient demand for it.</li>
<li>Requests are typically not rate-limited, but the tool uses the same workers to handle all requests, so making simultaneous API calls is only going to slow you down. In general, you are fine making an unlimited number of requests, as long as they are not concurrent and you wait a few seconds between them.</li>
</ul>
<h2>Example</h2>
<p><a href="https://tools.wmflabs.org/copyvios/api.json?version=1&amp;action=search&amp;project=wikipedia&amp;lang=en&amp;title=User:The_Earwig/Sandbox/CopyvioExample"><span class="code">https://tools.wmflabs.org/copyvios/api.json?<span class="param-key">version</span>=<span class="param-value">1</span>&amp;<span class="param-key">action</span>=<span class="param-value">search</span>&amp;<span class="param-key">project</span>=<span class="param-value">wikipedia</span>&amp;<span class="param-key">lang</span>=<span class="param-value">en</span>&amp;<span class="param-key">title</span>=<span class="param-value">User:The_Earwig/Sandbox/CopyvioExample</span></span></a></p>
<pre>
{
<p><a class="no-color" href="https://tools.wmflabs.org/copyvios/api.json?version=1&amp;action=search&amp;project=wikipedia&amp;lang=en&amp;title=User:The_Earwig/Sandbox/CopyvioExample"><span class="code">https://tools.wmflabs.org/copyvios/api.json?<span class="param-key">version</span>=<span class="param-val">1</span>&amp;<span class="param-key">action</span>=<span class="param-val">search</span>&amp;<span class="param-key">project</span>=<span class="param-val">wikipedia</span>&amp;<span class="param-key">lang</span>=<span class="param-val">en</span>&amp;<span class="param-key">title</span>=<span class="param-val">User:The_Earwig/Sandbox/CopyvioExample</span></span></a></p>
<pre>{
"status": "ok",
"meta": {
"time": 2.2474379539489746,


Caricamento…
Annulla
Salva