index.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>ntfy.sh | simple HTTP-based pub-sub</title>
  6. <link rel="stylesheet" href="static/css/app.css" type="text/css">
  7. <!-- Mobile view -->
  8. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
  9. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  10. <meta name="HandheldFriendly" content="true">
  11. <!-- Mobile browsers, background color -->
  12. <meta name="theme-color" content="#39005a">
  13. <meta name="msapplication-navbutton-color" content="#39005a">
  14. <meta name="apple-mobile-web-app-status-bar-style" content="#39005a">
  15. <!-- Favicon, see favicon.io -->
  16. <link rel="icon" type="image/png" href="static/img/favicon.png">
  17. <!-- Previews in Google, Slack, WhatsApp, etc. -->
  18. <meta property="og:type" content="website" />
  19. <meta property="og:locale" content="en_US" />
  20. <meta property="og:site_name" content="ntfy.sh" />
  21. <meta property="og:title" content="ntfy.sh | simple HTTP-based pub-sub" />
  22. <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." />
  23. <meta property="og:image" content="/static/img/ntfy.png" />
  24. <meta property="og:url" content="https://ntfy.sh" />
  25. </head>
  26. <body>
  27. <div id="main">
  28. <h1><img src="static/img/ntfy.png" alt="ntfy"/><br/>ntfy.sh - simple HTTP-based pub-sub</h1>
  29. <p>
  30. <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.
  31. It allows you to send <b>desktop notifications via scripts from any computer</b>, entirely <b>without signup or cost</b>.
  32. It's also <a href="https://github.com/binwiederhier/ntfy">open source</a> if you want to run your own.
  33. </p>
  34. <p id="error"></p>
  35. <h2>Publishing messages</h2>
  36. <p>
  37. Publishing messages can be done via PUT or POST using. Topics are created on the fly by subscribing or publishing to them.
  38. Because there is no sign-up, <b>the topic is essentially a password</b>, so pick something that's not easily guessable.
  39. </p>
  40. <p class="smallMarginBottom">
  41. Here's an example showing how to publish a message using <tt>curl</tt>:
  42. </p>
  43. <code>
  44. curl -d "long process is done" ntfy.sh/mytopic
  45. </code>
  46. <p class="smallMarginBottom">
  47. Here's an example in JS with <tt>fetch()</tt> (see <a href="https://github.com/binwiederhier/ntfy/tree/main/examples">full example</a>):
  48. </p>
  49. <code>
  50. fetch('https://ntfy.sh/mytopic', {<br/>
  51. &nbsp;&nbsp;method: 'POST', // PUT works too<br/>
  52. &nbsp;&nbsp;body: 'Hello from the other side.'<br/>
  53. })
  54. </code>
  55. <h2>Subscribe to a topic</h2>
  56. <p>
  57. You can create and subscribe to a topic either in this web UI, or in your own app by subscribing to an
  58. <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource">EventSource</a>, a JSON feed, or raw feed.
  59. </p>
  60. <h3>Subscribe via web</h3>
  61. <p>
  62. If you subscribe to a topic via this web UI in the field below, messages published to any subscribed topic
  63. will show up as <b>desktop notification</b>.
  64. </p>
  65. <form id="subscribeForm">
  66. <p>
  67. <label for="topicField">Subscribe to topic:</label>
  68. <input type="text" id="topicField" placeholder="Letters, numbers, _ and -" pattern="[-_A-Za-z]{1,64}" />
  69. <input type="submit" id="subscribeButton" value="Subscribe" />
  70. </p>
  71. </form>
  72. <p id="topicsHeader">Topics:</p>
  73. <ul id="topicsList"></ul>
  74. <audio id="notifySound" src="static/sound/mixkit-message-pop-alert-2354.mp3"></audio>
  75. <h3>Subscribe via your app, or via the CLI</h3>
  76. <p class="smallMarginBottom">
  77. Using <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource">EventSource</a> in JS, you can consume
  78. notifications like this (see <a href="https://github.com/binwiederhier/ntfy/tree/main/examples">full example</a>):
  79. </p>
  80. <code>
  81. const eventSource = new EventSource('https://ntfy.sh/mytopic/sse');<br/>
  82. eventSource.onmessage = (e) => {<br/>
  83. &nbsp;&nbsp;// Do something with e.data<br/>
  84. };
  85. </code>
  86. <p class="smallMarginBottom">
  87. You can also use the same <tt>/sse</tt> endpoint via <tt>curl</tt> or any other HTTP library:
  88. </p>
  89. <code>
  90. $ curl -s ntfy.sh/mytopic/sse<br/>
  91. event: open<br/>
  92. data: {"id":"weSj9RtNkj","time":1635528898,"event":"open","topic":"mytopic"}<br/><br/>
  93. data: {"id":"p0M5y6gcCY","time":1635528909,"event":"message","topic":"mytopic","message":"Hi!"}<br/><br/>
  94. event: keepalive<br/>
  95. data: {"id":"VNxNIg5fpt","time":1635528928,"event":"keepalive","topic":"test"}
  96. </code>
  97. <p class="smallMarginBottom">
  98. To consume JSON instead, use the <tt>/json</tt> endpoint, which prints one message per line:
  99. </p>
  100. <code>
  101. $ curl -s ntfy.sh/mytopic/json<br/>
  102. {"id":"SLiKI64DOt","time":1635528757,"event":"open","topic":"mytopic"}<br/>
  103. {"id":"hwQ2YpKdmg","time":1635528741,"event":"message","topic":"mytopic","message":"Hi!"}<br/>
  104. {"id":"DGUDShMCsc","time":1635528787,"event":"keepalive","topic":"mytopic"}
  105. </code>
  106. <p class="smallMarginBottom">
  107. Or use the <tt>/raw</tt> endpoint if you need something super simple (empty lines are keepalive messages):
  108. </p>
  109. <code>
  110. $ curl -s ntfy.sh/mytopic/raw<br/>
  111. <br/>
  112. This is a notification
  113. </code>
  114. <h3>Message buffering and polling</h3>
  115. <p class="smallMarginBottom">
  116. Messages are buffered in memory for a few hours to account for network interruptions of subscribers.
  117. You can read back what you missed by using the <tt>since=...</tt> query parameter. It takes either a
  118. duration (e.g. <tt>10m</tt> or <tt>30s</tt>) or a Unix timestamp (e.g. <tt>1635528757</tt>):
  119. </p>
  120. <code>
  121. $ curl -s "ntfy.sh/mytopic/json?since=10m"<br/>
  122. # Same output as above, but includes messages from up to 10 minutes ago
  123. </code>
  124. <p class="smallMarginBottom">
  125. You can also just poll for messages if you don't like the long-standing connection using the <tt>poll=1</tt>
  126. query parameter. The connection will end after all available messages have been read. This parameter has to be
  127. combined with <tt>since=</tt>.
  128. </p>
  129. <code>
  130. $ curl -s "ntfy.sh/mytopic/json?poll=1&since=10m"<br/>
  131. # Returns messages from up to 10 minutes ago and ends the connection
  132. </code>
  133. <h2>FAQ</h2>
  134. <p>
  135. <b>Isn't this like ...?</b><br/>
  136. Who knows. I didn't do a lot of research before making this. It was fun making it.
  137. </p>
  138. <p>
  139. <b>Can I use this in my app? Will it stay free?</b><br/>
  140. Yes. As long as you don't abuse it, it'll be available and free of charge. I do not plan on monetizing
  141. the service.
  142. </p>
  143. <p>
  144. <b>What are the uptime guarantees?</b><br/>
  145. Best effort.
  146. </p>
  147. <p>
  148. <b>Will you know what topics exist, can you spy on me?</b><br/>
  149. 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>.
  150. That said, the logs do not contain any topic names or other details about you. Check the code if you don't believe me.
  151. </p>
  152. <center id="ironicCenterTagDontFreakOut"><i>Made with ❤️ by <a href="https://heckel.io">Philipp C. Heckel</a></i></center>
  153. </div>
  154. <script src="static/js/app.js"></script>
  155. </body>
  156. </html>