You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

70 lines
2.5 KiB

<!doctype html>
<html>
<head>
<link rel="stylesheet" href="{{ url_for('web.static', filename='style/api.css') }}" type="text/css">
<title>API documentation</title>
</head>
<body>
<h1>CouchPotato API Documentation</h1>
<div class="api">
You can access the API via <pre>{{ fireEvent('app.api_url', single = True)|safe }}/</pre>
To see it in action, have a look at the webinterface with Firebug (on firefox) or the development tools included in Chrome.
All the data that you see there are from the API.
<br />
<br />
A normal API call:
<pre><a href="{{ fireEvent('app.api_url', single = True)|safe }}/updater.info/">{{ fireEvent('app.api_url', single = True)|safe }}/updater.info/</a></pre>
<br />
You can also use the API over another domain using JSONP, the callback function should be in 'callback_func'
<pre><a href="{{ fireEvent('app.api_url', single = True)|safe }}/updater.info/?callback_func=myfunction">{{ fireEvent('app.api_url', single = True)|safe }}/updater.info/?callback_func=myfunction</a></pre>
<br />
<br />
Get the API key:
<pre><a href="{{ url_for('web.index') }}getkey/?p=md5(password)&amp;u=md5(username)">{{ url_for('web.index') }}getkey/?p=md5(password)&amp;u=md5(username)</a></pre>
Will return {"api_key": "XXXXXXXXXX", "success": true}. When username or password is empty you don't need to md5 it.
<br />
</div>
{% for route in routes %}
{% if api_docs.get(route) %}
<div class="api">
<h2>{{route}}</h2>
<div class="description">{{api_docs[route].get('desc', '')}}</div>
{% if api_docs[route].get('params') %}
<h3>Params</h3>
<table class="params" cellspacing="0" cellpadding="0">
{% for param in api_docs[route]['params'] %}
<tr class="param">
<th>{{param}}</th>
<td class="type">{{ api_docs[route]['params'][param].get('type', 'string') }}</td>
<td class="description">{{ api_docs[route]['params'][param]['desc'] }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
{% if api_docs[route].get('return') %}
<h3>Return</h3>
<div class="return">
<div class="type">{{ api_docs[route]['return'].get('type', '{"success": True}') }}</div>
{% if api_docs[route]['return'].get('example') %}
<div class="example">
<h4>Example</h4>
<pre>{{ api_docs[route]['return'].get('example', '')|safe }}</pre>
</div>
{% endif %}
</div>
{% endif %}
</div>
{% endif %}
{% endfor %}
<div class="missing">
<h1>Missing documentation</h1>
{{', '.join(api_docs_missing)}}
</div>
</body>
</html>