apprise-api/apprise_api/api/templates/welcome.html

507 lines
25 KiB
HTML
Raw Normal View History

2019-10-27 04:53:40 +01:00
{% extends 'base.html' %}
{% load i18n %}
2019-10-27 04:53:40 +01:00
{% block body %}
<h4>{% trans "The Apprise API" %}</h4>
<p>
{% blocktrans %}
<a target="_blank" href="https://github.com/caronc/apprise">Apprise</a> allows you to send a notification to almost
all of the most popular notification services available to us today such as: <em>Telegram</em>, <em>Discord</em>,
<em>Slack</em>, <em>Amazon SNS</em>, <em>Gotify</em>, etc.
This API provides a simple gateway to directly access it via an HTTP interface.{% endblocktrans %}
2019-10-27 04:53:40 +01:00
<ul>
<li><i class="tiny material-icons">chevron_right</i>{% blocktrans %}This project was designed to be incredibly light
weight.{% endblocktrans %}</li>
<li><i class="tiny material-icons">chevron_right</i>{% blocktrans %}Configuration can be persistently stored for
retrieval.{% endblocktrans %}</li>
2019-10-27 04:53:40 +01:00
</ul>
</p>
<div class="section">
<h4>{% trans "Stateless Endpoints" %}</h4>
<p>{% blocktrans %}Those who wish to treat this API as nothing but a <a
href="https://docs.microsoft.com/en-us/azure/architecture/patterns/sidecar" target="_blank">sidecar</a> and/or
microservice to their project only need to use the following URL.{% endblocktrans %}</p>
2019-10-27 04:53:40 +01:00
<table class="highlighted">
<thead>
<tr>
<th>{% trans "URL" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>{{BASE_URL}}/notify/</code></td>
2019-10-27 04:53:40 +01:00
<td>
{% blocktrans %}Used to notify one one or more specified Apprise URLs. See the <a target="_blank"
2019-10-27 04:53:40 +01:00
href="https://github.com/caronc/apprise/wiki#notification-services">Apprise Wiki</a> if you need help
constructing your URL(s).{% endblocktrans %}
2019-10-27 04:53:40 +01:00
<div class="section">
<table>
<thead>
<tr>
<th>{% trans "Parameter" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td>urls</td>
<td>{% blocktrans %}Used to define one or more Apprise URL(s). Use a comma and/or space to separate
one URL from the next.{% endblocktrans %}</td>
</tr>
<tr>
<td>body</td>
<td>{% blocktrans %}Defines the message body. This field is required!{% endblocktrans %}</td>
2019-10-27 04:53:40 +01:00
</tr>
<tr>
<td>title</td>
<td>{% blocktrans %}The title to include in the notification. This is an optional
field.{% endblocktrans %}
</td>
</tr>
<tr>
<td>type</td>
<td>{% blocktrans %}This optional field defines the notification type. The possible options
are:{% endblocktrans %}
2019-10-27 04:53:40 +01:00
<ol>
<li><i class="tiny material-icons" style="color: blue">info</i><code>{% trans "info" %}</code> -
<i>{% blocktrans %}this is the default option if a type
isn't
specified.{% endblocktrans %}</i></li>
<li><i class="tiny material-icons"
style="color: green">check_circle</i><code>{% trans "success" %}</code></li>
<li><i class="tiny material-icons"
style="color: orange">report_problem</i><code>{% trans "warning" %}</code></li>
<li><i class="tiny material-icons" style="color: red">cancel</i><code>{% trans "failure" %}</code>
</li>
2019-10-27 04:53:40 +01:00
</ol>
</td>
</tr>
</tbody>
</table>
<ul class="collapsible">
<li>
<div class="collapsible-header"><i class="material-icons">code</i>curl example</div>
<div class="collapsible-body">
<pre><code class="bash">
# {% blocktrans %}Notifies an email address{% endblocktrans %}<br/>
curl -X POST -d '{"urls":"mailto://user:pass@gmail.com","body":"test body","title":"test title"}' \<br/>
2019-10-27 04:53:40 +01:00
&nbsp;&nbsp;&nbsp;&nbsp;-H "Content-Type: application/json" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/</code></pre>
2019-10-27 04:53:40 +01:00
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>python example</div>
<div class="collapsible-body">
<pre><code class="python">
import json<br/>
from urllib.request import Request<br/>
<br/>
payload = {<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls': 'mailto://user:pass@gmail.com',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title': 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body': 'test body',<br/>
}<br/>
<br/># The URL<br/>
req = Request(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;json.dumps(payload).encode('utf-8'),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{"Content-Type": "application/json"},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;method='POST',<br/>
)
</code></pre>
</div>
</li>
2019-10-27 04:53:40 +01:00
<li>
<div class="collapsible-header"><i class="material-icons">code</i>php example</div>
<div class="collapsible-body">
<pre><code class="php">&lt;?php<br/>
<br/>
// The URL<br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
//The JSON data.<br/>
$jsonData = array(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls' => 'mailto://user:pass@hotmail.com',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body' => 'test body'<br/>
);<br/>
<br/>
//Encode the array into JSON.<br/>
$jsonDataEncoded = json_encode($jsonData);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Attach our encoded JSON string to the POST fields.<br/>
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);<br/>
<br/>
//Set the content type to application/json<br/>
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);
</code></pre>
</div>
2019-10-27 04:53:40 +01:00
</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
2019-10-27 04:53:40 +01:00
{% if STATEFUL_MODE != 'disabled' %}
<div class="section">
<h4>{% trans "Persistent Store Endpoints" %}</h4>
<p>{% blocktrans %}Those wishing to use the persistent store may do so. This section is a set it and forget it type
deal. Set your configuration once and just trigger notifications later on demand with light-weight API
calls.{% endblocktrans %}</p>
<p>{% blocktrans %}All endpoints that expect posted data can be received in either JSON or in it's standard
encoding.
You must pass along the <code>Content-Type</code> as <code>application/json</code> in order for it to be
interpreted
properly.{% endblocktrans %}</p>
<table class="highlighted">
<thead>
<tr>
<th>{% trans "URL" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>{{BASE_URL}}/add/<em>{% trans "KEY" %}</em></code></td>
<td>
{% blocktrans %}Used to add a new Apprise configuration or a set of URLs and associates them with the
specified <em>KEY</em>. See the <a target="_blank"
href="https://github.com/caronc/apprise/wiki#notification-services">Apprise Wiki</a> if you need help
constructing your URLs.{% endblocktrans %}
<div class="section">
<table>
<thead>
<tr>
<th>{% trans "Parameter" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td>urls</td>
<td>{% blocktrans %}Used to define one or more Apprise URL(s). Use a comma and/or space to separate
one URL from the next.{% endblocktrans %}</td>
</tr>
<tr>
<td>config</td>
<td>{% blocktrans %}Provide the contents of either a YAML or TEXT based Apprise
configuration.{% endblocktrans %}</td>
</tr>
<tr>
<td>format</td>
<td>{% blocktrans %}This field is only required if you've specified the config option. It's purpose
is
to tell the server which of the supported (Apprise) configuration types you are passing. Valid
options are:{% endblocktrans %}
<ol>
<li><code>{% trans "yaml" %}</code></li>
<li><code>{% trans "text" %}</code></li>
</ol>
<ul>
<li>{% blocktrans %}You must specify either the <code>urls</code> parameter or the
<code>config</code>.{% endblocktrans %}</li>
<li>{% blocktrans %}The <code>urls</code> takes priority over the <code>config</code> if both
were
specified.{% endblocktrans %}</li>
<li>{% blocktrans %}The <code>format</code> parameter is only required if the
<code>config</code>
parameter was also specified.{% endblocktrans %}</li>
</ul>
</td>
</tr>
</tbody>
</table>
<ul class="collapsible">
<li>
<div class="collapsible-header"><i class="material-icons">code</i>curl example</div>
<div class="collapsible-body">
<pre><code class="bash">
# {% blocktrans %}Load a single URL and assign it to the <em>KEY</em> of abc123{% endblocktrans %}<br/>
curl -X POST -d '{"urls":"mailto://user:pass@gmail.com"}' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-H "Content-Type: application/json" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/add/<em>abc123</em></code></pre>
<pre><code class="bash">
# {% blocktrans %}Load a simple TEXT config entry <em>KEY</em> abc123{% endblocktrans %}<br/>
curl -X POST -d '{"format":"text","config":"devops=mailto://user:pass@gmail.com"}' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-H "Content-Type: application/json" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/add/abc123/
</code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>python example</div>
<div class="collapsible-body">
<pre><code class="python">
import json<br/>
from urllib.request import Request<br/>
<br/>
payload = {<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls': 'mailto://user:pass@gmail.com',<br/>
}<br/>
<br/># The URL if the key was <em>abc123</em><br/>
req = Request(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/add/<em>abc123</em>",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;json.dumps(payload).encode('utf-8'),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{"Content-Type": "application/json"},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;method='POST',<br/>
)
</code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>php example</div>
<div class="collapsible-body">
<pre><code class="php">&lt;?php<br/>
<br/>
// The URL if the key was <em>abc123</em><br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/add/<em>abc123</em>';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
//The JSON data.<br/>
$jsonData = array(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'urls' => 'mailto://user:pass@hotmail.com'<br/>
);<br/>
<br/>
//Encode the array into JSON.<br/>
$jsonDataEncoded = json_encode($jsonData);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Attach our encoded JSON string to the POST fields.<br/>
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);<br/>
<br/>
//Set the content type to application/json<br/>
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);
</code></pre>
</div>
</li>
</ul>
</div>
</td>
</tr>
<tr>
<td><code>{{BASE_URL}}/del/<em>{% trans "KEY" %}</em></code></td>
<td>{% blocktrans %}There are no arguments required. If the <em>KEY</em> exists and has data associated with
it,
it will be removed.{% endblocktrans %}
<ul class="collapsible">
2019-10-27 04:53:40 +01:00
<li>
<div class="collapsible-header"><i class="material-icons">code</i>curl example</div>
<div class="collapsible-body">
<pre><code class="bash">
# {% blocktrans %}Remove previously loaded configuration associated with the <em>KEY</em> of abc123{% endblocktrans %}<br/>
curl -X POST {{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/del/<em>abc123</em></code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>python example</div>
<div class="collapsible-body">
<pre><code class="python">
import json<br/>
from urllib.request import Request<br/>
<br/># The request if the key was <em>abc123</em><br/>
req = Request(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/del/<em>abc123</em>",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;json.dumps(payload).encode('utf-8'),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{"Content-Type": "application/json"},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;method='POST',<br/>
)
</code></pre>
</div>
<li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>php example</div>
<div class="collapsible-body">
<pre><code class="php">&lt;?php<br/>
<br/>
// The URL if the key was <em>abc123</em><br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/del/<em>abc123</em>';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);
</code></pre>
</div>
</li>
</ul>
</td>
</tr>
<tr>
<td><code>{{BASE_URL}}/get/<em>{% trans "KEY" %}</em></code></td>
<td>{% blocktrans %}This feature can be used by Apprise itself. It provides a means of remotely fetching it's
configuration.{% endblocktrans %}<br />
<pre><code lang="bash"># Use Apprise to retrieve your configuration:<br/>
apprise --body="test message" --config={{ request.scheme }}://{{request.META.HTTP_HOST}}{{BASE_URL}}/get/<em>{% trans "KEY" %}</em></code></pre>
</p>
</td>
</tr>
<tr>
<td><code>{{BASE_URL}}/notify/<em>{% trans "KEY" %}</em></code></td>
<td>{% blocktrans %}Notifies the URLs associated with the specified <em>KEY</em>.{% endblocktrans %}
<div class="section">
<table>
<thead>
<tr>
<th>{% trans "Parameter" %}</th>
<th>{% trans "Description" %}</th>
</tr>
</thead>
<tbody>
<tr>
<td>body</td>
<td>{% blocktrans %}Defines the message body. This field is required!{% endblocktrans %}</td>
</tr>
<tr>
<td>title</td>
<td>{% blocktrans %}The title to include in the notification. This is an optional
field.{% endblocktrans %}
</td>
</tr>
<tr>
<td>type</td>
<td>{% blocktrans %}This optional field defines the notification type. The possible options
are:{% endblocktrans %}
<ol>
<li><i class="tiny material-icons" style="color: blue">info</i><code>{% trans "info" %}</code> -
<i>{% blocktrans %}this is the default option if a type
isn't
specified.{% endblocktrans %}</i></li>
<li><i class="tiny material-icons"
style="color: green">check_circle</i><code>{% trans "success" %}</code></li>
<li><i class="tiny material-icons"
style="color: orange">report_problem</i><code>{% trans "warning" %}</code></li>
<li><i class="tiny material-icons"
style="color: red">cancel</i><code>{% trans "failure" %}</code></li>
</ol>
</td>
</tr>
<tr>
<td>tag</td>
<td>{% blocktrans %}Apply tagging logic to the further filter your URLs. This is an optional
field.{% endblocktrans %}</td>
</tr>
</tbody>
</table>
<ul class="collapsible">
<li>
<div class="collapsible-header"><i class="material-icons">code</i>curl example</div>
<div class="collapsible-body">
<pre><code class="bash">
# {% blocktrans %}Notifies all URLs assigned the <em>devops</em> tag{% endblocktrans %}<br/>
curl -X POST -d '{"tag":"devops","body":"test body","title":"test title"}' \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;-H "Content-Type: application/json" \<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>KEY</em></code></pre>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>python example</div>
<div class="collapsible-body">
<pre><code class="python">
import json<br/>
from urllib.request import Request<br/>
<br/>
payload = {<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'tag': 'devops',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title': 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body': 'test body',<br/>
}<br/>
<br/># The URL if the key was <em>abc123</em><br/>
req = Request(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>abc123</em>",<br/>
&nbsp;&nbsp;&nbsp;&nbsp;json.dumps(payload).encode('utf-8'),<br/>
&nbsp;&nbsp;&nbsp;&nbsp;{"Content-Type": "application/json"},<br/>
&nbsp;&nbsp;&nbsp;&nbsp;method='POST',<br/>
)
</code></pre>
</div>
<li>
<li>
<div class="collapsible-header"><i class="material-icons">code</i>php example</div>
<div class="collapsible-body">
<pre><code class="php">&lt;?php<br/>
<br/>
// The URL if the key was <em>abc123</em><br/>
$url = '{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>abc123</em>';<br/>
<br/>
//Initiate cURL.<br/>
$ch = curl_init($url);<br/>
<br/>
//The JSON data.<br/>
$jsonData = array(<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'tag' => 'devops',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'title' => 'test title',<br/>
&nbsp;&nbsp;&nbsp;&nbsp;'body' => 'test body'<br/>
);<br/>
<br/>
//Encode the array into JSON.<br/>
$jsonDataEncoded = json_encode($jsonData);<br/>
<br/>
//Tell cURL that we want to send a POST request.<br/>
curl_setopt($ch, CURLOPT_POST, 1);<br/>
<br/>
//Attach our encoded JSON string to the POST fields.<br/>
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);<br/>
<br/>
//Set the content type to application/json<br/>
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));<br/>
<br/>
//Execute the request<br/>
$result = curl_exec($ch);
</code></pre>
</div>
</li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
2019-10-27 04:53:40 +01:00
<div class="section">
<h4>{% trans "Endpoint Notes" %}</h4>
<p>
The <em>KEY</em> you plan to associate your configuration with:
<ol>
<li>Can not have spaces and/or special characters in it. Both a dash (<code>-</code>) and underscore
(<code>_</code>) are the only exceptions to this rule.</li>
<li>Must start with at least 2 alpha/numeric characters.</li>
<li>Can not exceed 64 characters in total length.</li>
</ol>
</p>
2019-10-27 04:53:40 +01:00
</div>
</div>
{% else %}
<div class="section">
<h4>{% trans "Persistent Store Endpoints" %}</h4>
<p>{% blocktrans %}The administrator of this system has disabled persistent storage.{% endblocktrans %}</p>
</div>
{% endif %}
{% endblock %}