1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-12-23 18:23:27 +01:00
ntfy/server/index.html

159 lines
6.7 KiB
HTML
Raw Normal View History

2021-10-23 03:26:01 +02:00
<!DOCTYPE html>
<html lang="en">
<head>
2021-10-24 20:22:53 +02:00
<meta charset="UTF-8">
<title>ntfy.sh | simple HTTP-based pub-sub</title>
<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-10-25 14:54:46 +02:00
<meta name="theme-color" content="#39005a">
<meta name="msapplication-navbutton-color" content="#39005a">
<meta name="apple-mobile-web-app-status-bar-style" content="#39005a">
2021-10-24 20:22:53 +02: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" />
<meta property="og:title" content="ntfy.sh | simple HTTP-based pub-sub" />
<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." />
<meta property="og:image" content="/static/img/favicon.png" />
2021-10-24 20:22:53 +02:00
<meta property="og:url" content="https://ntfy.sh" />
2021-10-23 03:26:01 +02:00
</head>
<body>
<div id="main">
2021-10-24 04:49:50 +02:00
<h1>ntfy.sh - simple HTTP-based pub-sub</h1>
<p>
<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.
2021-10-24 20:22:53 +02:00
It allows you to send <b>desktop notifications via scripts from any computer</b>, entirely <b>without signup or cost</b>.
2021-10-24 05:30:10 +02:00
It's also <a href="https://github.com/binwiederhier/ntfy">open source</a> if you want to run your own.
</p>
2021-10-24 04:49:50 +02:00
<p id="error"></p>
2021-10-23 03:26:01 +02:00
2021-10-24 04:49:50 +02:00
<h2>Subscribe to a topic</h2>
<p>
2021-10-24 04:49:50 +02:00
Topics are created on the fly by subscribing to them. 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>
<p>
Because there is no sign-up, <b>the topic is essentially a password</b>, so pick something that's not easily guessable.
</p>
2021-10-23 03:26:01 +02:00
2021-10-24 04:49:50 +02:00
<h3>Subscribe via web</h3>
<p>
If you subscribe to a topic via this web UI in the field below, messages published to any subscribed topic
2021-10-24 05:30:10 +02:00
will show up as <b>desktop notification</b>.
2021-10-24 04:49:50 +02:00
</p>
<form id="subscribeForm">
<p>
<label for="topicField">Subscribe to topic:</label>
2021-10-25 14:54:46 +02:00
<input type="text" id="topicField" placeholder="Letters, numbers, _ and -" pattern="[-_A-Za-z]{1,64}" />
2021-10-24 20:22:53 +02:00
<input type="submit" id="subscribeButton" value="Subscribe" />
</p>
</form>
<p id="topicsHeader">Topics:</p>
<ul id="topicsList"></ul>
<audio id="notifySound" src="static/sound/mixkit-message-pop-alert-2354.mp3"></audio>
2021-10-24 04:49:50 +02:00
<h3>Subscribe via your app, or via the CLI</h3>
<p class="smallMarginBottom">
Using <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource">EventSource</a>, you can consume
notifications like this (see <a href="https://github.com/binwiederhier/ntfy/tree/main/examples">full example</a>):
</p>
<code>
2021-10-25 14:54:46 +02:00
const eventSource = new EventSource('https://ntfy.sh/mytopic/sse');<br/>
eventSource.onmessage = (e) => {<br/>
&nbsp;&nbsp;// Do something with e.data<br/>
};
2021-10-24 20:22:53 +02:00
</code>
<p class="smallMarginBottom">
Or you can use <tt>curl</tt> or any other HTTP library. Here's an example for the <tt>/json</tt> endpoint,
which prints one JSON message per line (keepalive and open messages have an "event" field):
</p>
<code>
$ curl -s ntfy.sh/mytopic/json<br/>
{"time":1635359841,"event":"open"}<br/>
{"time":1635359844,"message":"This is a notification"}<br/>
{"time":1635359851,"event":"keepalive"}
</code>
<p class="smallMarginBottom">
Using the <tt>/sse</tt> endpoint (SSE, server-sent events stream):
</p>
<code>
$ curl -s ntfy.sh/mytopic/sse<br/>
event: open<br/>
data: {"time":1635359796,"event":"open"}<br/><br/>
data: {"time":1635359803,"message":"This is a notification"}<br/><br/>
event: keepalive<br/>
data: {"time":1635359806,"event":"keepalive"}
</code>
<p class="smallMarginBottom">
Using the <tt>/raw</tt> endpoint (empty lines are keepalive messages):
</p>
<code>
$ curl -s ntfy.sh/mytopic/raw<br/>
<br/>
This is a notification
</code>
2021-10-24 04:49:50 +02:00
2021-10-24 20:22:53 +02:00
<h2>Publishing messages</h2>
<p class="smallMarginBottom">
2021-10-24 04:49:50 +02:00
Publishing messages can be done via PUT or POST using. Here's an example using <tt>curl</tt>:
</p>
2021-10-24 20:22:53 +02:00
<code>
2021-10-24 04:49:50 +02:00
curl -d "long process is done" ntfy.sh/mytopic
2021-10-24 20:22:53 +02:00
</code>
<p class="smallMarginBottom">
Here's an example in JS with <tt>fetch()</tt> (see <a href="https://github.com/binwiederhier/ntfy/tree/main/examples">full example</a>):
</p>
<code>
2021-10-25 14:54:46 +02:00
fetch('https://ntfy.sh/mytopic', {<br/>
&nbsp;&nbsp;method: 'POST', // PUT works too<br/>
2021-10-25 14:54:46 +02:00
&nbsp;&nbsp;body: 'Hello from the other side.'<br/>
})
</code>
2021-10-24 04:49:50 +02:00
<p>
Messages published to a non-existing topic or a topic without subscribers will not be delivered later.
There is (currently) no buffering of any kind. If you're not listening, the message won't be delivered.
</p>
<h2>FAQ</h2>
<p>
<b>Isn't this like ...?</b><br/>
Who knows. I didn't do a lot of research before making this. It was fun making it.
</p>
<p>
<b>Can I use this in my app? Will it stay free?</b><br/>
Yes. As long as you don't abuse it, it'll be available and free of charge. I do not plan on monetizing
the service.
</p>
<p>
<b>What are the uptime guarantees?</b><br/>
Best effort.
</p>
<p>
<b>Will you know what topics exist, can you spy on me?</b><br/>
If you don't trust me or your messages are sensitive, run your own server. It's <a href="https://github.com/binwiederhier/ntfy">open source</a>.
That said, the logs do not contain any topic names or other details about you. Check the code if you don't believe me.
</p>
<center id="ironicCenterTagDontFreakOut"><i>Made with ❤️ by <a href="https://heckel.io">Philipp C. Heckel</a></i></center>
</div>
2021-10-24 20:22:53 +02:00
<script src="static/js/app.js"></script>
2021-10-23 03:26:01 +02:00
</body>
</html>