ntfy/server/index.gohtml

207 lines
11 KiB
Plaintext
Raw Normal View History

2021-11-08 17:24:34 +03:00
{{- /*gotype: heckel.io/ntfy/server.indexPage*/ -}}
2021-10-23 04:26:01 +03:00
<!DOCTYPE html>
<html lang="en">
<head>
2021-10-24 21:22:53 +03:00
<meta charset="UTF-8">
2021-12-03 01:27:31 +03:00
<title>ntfy.sh | PUT/POST push notifications to your phone</title>
2021-10-24 21:22:53 +03:00
<link rel="stylesheet" href="static/css/app.css" type="text/css">
<!-- Mobile view -->
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="HandheldFriendly" content="true">
<!-- Mobile browsers, background color -->
2021-11-12 22:43:32 +03:00
<meta name="theme-color" content="#317f6f">
<meta name="msapplication-navbutton-color" content="#317f6f">
<meta name="apple-mobile-web-app-status-bar-style" content="#317f6f">
2021-10-24 21:22:53 +03:00
<!-- Favicon, see favicon.io -->
<link rel="icon" type="image/png" href="static/img/favicon.png">
<!-- Previews in Google, Slack, WhatsApp, etc. -->
<meta property="og:type" content="website" />
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="ntfy.sh" />
2021-12-03 01:27:31 +03:00
<meta property="og:title" content="ntfy.sh | send push notifications to your phone via simple PUT/POST requests" />
2021-10-24 21:22:53 +03:00
<meta property="og:description" content="ntfy is a simple HTTP-based pub-sub notification service. It allows you to send desktop notifications via scripts from any computer, entirely without signup or cost. Made with ❤ by Philipp C. Heckel, Apache License 2.0, source at https://heckel.io/ntfy." />
2021-10-31 06:46:08 +03:00
<meta property="og:image" content="/static/img/ntfy.png" />
2021-10-24 21:22:53 +03:00
<meta property="og:url" content="https://ntfy.sh" />
2021-11-08 17:24:34 +03:00
{{if .Topic}}
<!-- Never index topic page -->
<meta name="robots" content="noindex, nofollow" />
{{end}}
2021-10-23 04:26:01 +03:00
</head>
<body>
2021-11-24 04:22:09 +03:00
<div id="header"><div id="headerBox"><img src="static/img/ntfy.png" alt="ntfy"/></div></div>
2021-11-08 17:24:34 +03:00
<div id="main"{{if .Topic}} style="display: none"{{end}}>
2021-12-03 01:27:31 +03:00
<h1>ntfy.sh | PUT/POST push notifications to your phone</h1>
<p>
2021-11-24 04:22:09 +03:00
<b>ntfy</b> (pronounce: <i>notify</i>) is a simple HTTP-based <a href="https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern">pub-sub</a> notification service.
It allows you to send notifications to your phone or desktop via scripts from any computer,
entirely <b>without signup, cost or setup</b>. It's also <a href="https://github.com/binwiederhier/ntfy">open source</a> if you want to run your own.
</p>
2021-11-09 18:46:47 +03:00
<div id="screenshots">
<a href="static/img/screenshot-curl.png"><img src="static/img/screenshot-curl.png"/></a>
<a href="static/img/screenshot-web-detail.png"><img src="static/img/screenshot-web-detail.png"/></a>
<span class="nowrap">
<a href="static/img/screenshot-phone-main.jpg"><img src="static/img/screenshot-phone-main.jpg"/></a>
<a href="static/img/screenshot-phone-detail.jpg"><img src="static/img/screenshot-phone-detail.jpg"/></a>
<a href="static/img/screenshot-phone-notification.jpg"><img src="static/img/screenshot-phone-notification.jpg"/></a>
</span>
</div>
2021-11-05 05:47:29 +03:00
<p>
2021-11-24 04:22:09 +03:00
There are many ways to use it: Notify yourself when a build finishes, when an rsync is done or a backup fails,
or know when somebody logs into your server. There are <a href="#examples">many more examples</a>, endless possibilities 😀.
2021-11-05 05:47:29 +03:00
</p>
2021-10-23 04:26:01 +03:00
2021-11-18 04:50:47 +03:00
<h2 id="publish" class="anchor">Publishing messages</h2>
<p>
2021-11-18 21:14:55 +03:00
Publishing messages can be done via PUT or POST. Topics are created on the fly by subscribing or publishing to them.
2021-10-29 20:58:14 +03:00
Because there is no sign-up, <b>the topic is essentially a password</b>, so pick something that's not easily guessable.
</p>
<p class="smallMarginBottom">
2021-11-24 04:22:09 +03:00
Here's an example showing how to publish a message using a POST request (via <tt>curl -d</tt>):
2021-10-29 20:58:14 +03:00
</p>
<code>
2021-11-22 16:30:09 +03:00
curl -d "Backup successful 😀" <span class="ntfyUrl">ntfy.sh</span>/mytopic
2021-11-18 21:14:55 +03:00
</code>
2021-11-28 00:12:08 +03:00
<p class="smallMarginBottom">
There are <a href="#other-features">more features</a> related to publishing messages: You can set a
<a href="#priority">notification priority</a>, a <a href="#title">title</a>, and <a href="#tags">tag messages</a>.
Here's an example using all of them:
</p>
<code>
curl \<br/>
&nbsp;&nbsp;-H "Title: Unauthorized access detected" \<br/>
&nbsp;&nbsp;-H "Priority: urgent" \<br/>
&nbsp;&nbsp;-H "Tags: warning,skull" \<br/>
2021-11-28 00:12:08 +03:00
&nbsp;&nbsp;-d "Remote access to $(hostname) detected. Act right away." \<br/>
&nbsp;&nbsp;<span class="ntfyUrl">ntfy.sh</span>/mytopic
</code>
2021-10-29 20:58:14 +03:00
2021-11-18 04:50:47 +03:00
<h2 id="subscribe" class="anchor">Subscribe to a topic</h2>
2021-10-24 05:49:50 +03:00
<p>
2021-10-29 20:58:14 +03:00
You can create and subscribe to a topic either in this web UI, or in your own app by subscribing to an
<a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource">EventSource</a>, a JSON feed, or raw feed.
</p>
2021-10-23 04:26:01 +03:00
2021-11-04 17:55:34 +03:00
<div id="subscribeBox">
2021-11-18 04:50:47 +03:00
<h3 id="subscribe-web" class="anchor">Subscribe in this Web UI</h3>
2021-11-05 05:32:17 +03:00
<p id="error"></p>
<p>
Subscribe to topics here and receive messages as <b>desktop notification</b>. Topics are not password-protected,
so choose a name that's not easy to guess. Once subscribed, you can publish messages via PUT/POST.
</p>
2021-11-04 17:55:34 +03:00
<form id="subscribeForm">
<p>
2021-11-05 05:32:17 +03:00
<b>Topic:</b><br/>
2021-11-08 17:24:34 +03:00
<input type="text" id="topicField" autocomplete="off" placeholder="Topic name, e.g. phil_alerts" maxlength="64" pattern="[-_A-Za-z0-9]{1,64}" />
2021-11-04 17:55:34 +03:00
<button id="subscribeButton">Subscribe</button>
</p>
2021-11-05 05:32:17 +03:00
<p id="topicsHeader"><b>Subscribed topics:</b></p>
<ul id="topicsList"></ul>
2021-11-04 17:55:34 +03:00
</form>
<audio id="notifySound" src="static/sound/mixkit-message-pop-alert-2354.mp3"></audio>
</div>
2021-11-18 17:22:33 +03:00
<h3 id="subscribe-phone" class="anchor">Subscribe from your phone</h3>
2021-11-01 23:39:40 +03:00
<p>
2021-11-03 18:33:34 +03:00
You can use the <a href="https://play.google.com/store/apps/details?id=io.heckel.ntfy">Ntfy Android App</a>
to receive notifications directly on your phone. Just like the server, this app is also <a href="https://github.com/binwiederhier/ntfy-android">open source</a>.
2021-11-18 17:22:33 +03:00
Since I don't have an iPhone or a Mac, I didn't make an iOS app yet. I'd be awesome if <a href="https://github.com/binwiederhier/ntfy/issues/4">someone else could help out</a>.
</p>
<p>
<a href="https://play.google.com/store/apps/details?id=io.heckel.ntfy"><img src="static/img/badge-googleplay.png"></a>
<a href="https://github.com/binwiederhier/ntfy/issues/4"><img src="static/img/badge-appstore.png"></a>
2021-11-01 23:39:40 +03:00
</p>
2021-11-18 04:50:47 +03:00
<h3 id="subscribe-api" class="anchor">Subscribe via your app, or via the CLI</h3>
<p class="smallMarginBottom">
2021-10-29 20:58:14 +03:00
Using <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource">EventSource</a> in JS, you can consume
2021-11-18 17:22:33 +03:00
notifications like this (see <a href="example.html">live example</a>):
</p>
<code>
2021-11-22 16:30:09 +03:00
const eventSource = new EventSource('<span class="ntfyProtocol">https://</span><span class="ntfyUrl">ntfy.sh</span>/mytopic/sse');<br/>
eventSource.onmessage = (e) => {<br/>
&nbsp;&nbsp;// Do something with e.data<br/>
};
2021-10-24 21:22:53 +03:00
</code>
<p class="smallMarginBottom">
2021-10-29 20:58:14 +03:00
You can also use the same <tt>/sse</tt> endpoint via <tt>curl</tt> or any other HTTP library:
</p>
<code>
2021-11-22 16:30:09 +03:00
$ curl -s <span class="ntfyUrl">ntfy.sh</span>/mytopic/sse<br/>
event: open<br/>
2021-10-29 20:58:14 +03:00
data: {"id":"weSj9RtNkj","time":1635528898,"event":"open","topic":"mytopic"}<br/><br/>
2021-10-29 20:58:14 +03:00
data: {"id":"p0M5y6gcCY","time":1635528909,"event":"message","topic":"mytopic","message":"Hi!"}<br/><br/>
event: keepalive<br/>
2021-10-29 20:58:14 +03:00
data: {"id":"VNxNIg5fpt","time":1635528928,"event":"keepalive","topic":"test"}
</code>
<p class="smallMarginBottom">
To consume JSON instead, use the <tt>/json</tt> endpoint, which prints one message per line:
</p>
<code>
2021-11-22 16:30:09 +03:00
$ curl -s <span class="ntfyUrl">ntfy.sh</span>/mytopic/json<br/>
2021-10-29 20:58:14 +03:00
{"id":"SLiKI64DOt","time":1635528757,"event":"open","topic":"mytopic"}<br/>
{"id":"hwQ2YpKdmg","time":1635528741,"event":"message","topic":"mytopic","message":"Hi!"}<br/>
{"id":"DGUDShMCsc","time":1635528787,"event":"keepalive","topic":"mytopic"}
</code>
<p class="smallMarginBottom">
2021-10-29 20:58:14 +03:00
Or use the <tt>/raw</tt> endpoint if you need something super simple (empty lines are keepalive messages):
</p>
<code>
2021-11-22 16:30:09 +03:00
$ curl -s <span class="ntfyUrl">ntfy.sh</span>/mytopic/raw<br/>
<br/>
2021-11-18 17:22:33 +03:00
This is a notification<br/>
And another one with a smiley face 😀
2021-11-05 05:47:29 +03:00
</code>
2021-10-24 05:49:50 +03:00
2021-11-18 17:22:33 +03:00
<h2 id="privacy" class="anchor">Privacy policy</h2>
2021-11-01 23:39:40 +03:00
<p>
Neither the server nor the app record any personal information, or share any of the messages and topics with
2021-11-03 18:33:34 +03:00
any outside service. All data is exclusively used to make the service function properly. The one exception
2021-11-01 23:39:40 +03:00
is the Firebase Cloud Messaging (FCM) service, which is required to provide instant Android notifications (see
FAQ for details).
</p>
<p>
The web server does not log or otherwise store request paths, remote IP addresses or even topics or messages,
2021-11-18 04:50:47 +03:00
aside from a short on-disk cache (for {{.CacheDuration}}) to support service restarts.
2021-11-01 23:39:40 +03:00
</p>
<center id="ironicCenterTagDontFreakOut"><i>Made with ❤️ by <a href="https://heckel.io">Philipp C. Heckel</a></i></center>
</div>
2021-11-08 17:24:34 +03:00
<div id="detail"{{if not .Topic}} style="display: none"{{end}}>
<div id="detailMain">
2021-11-29 03:03:15 +03:00
<button id="detailCloseButton"><img src="static/img/close.svg"/></button>
2021-11-24 04:22:09 +03:00
<h1><span id="detailTitle"></span></h1>
2021-11-08 17:24:34 +03:00
<p class="smallMarginBottom">
2021-11-24 04:22:09 +03:00
<b>ntfy</b> is a simple HTTP-based pub-sub notification service. This is a ntfy topic.
2021-11-08 17:24:34 +03:00
To send notifications to it, simply PUT or POST to the topic URL. Here's an example using <tt>curl</tt>:
</p>
<code>
2021-11-22 16:30:09 +03:00
curl -d "Backup failed" <span id="detailTopicUrl">ntfy.sh/topic</span>
2021-11-08 17:24:34 +03:00
</code>
<p id="detailNotificationsDisallowed">
If you'd like to receive desktop notifications when new messages arrive on this topic, you have
<a href="#" onclick="return requestPermission()">grant the browser permission</a> to show notifications.
Click the link to do so.
</p>
<p class="smallMarginBottom">
<b>Recent notifications</b> (cached for {{.CacheDuration}}):
</p>
<p id="detailNoNotifications">
<i>You haven't received any notifications for this topic yet.</i>
</p>
<div id="detailEventsList"></div>
</div>
</div>
2021-11-09 18:46:47 +03:00
<div id="lightbox" class="lightbox"></div>
<script src="static/js/emoji.js"></script>
2021-10-24 21:22:53 +03:00
<script src="static/js/app.js"></script>
2021-10-23 04:26:01 +03:00
</body>
</html>