index.gohtml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. {{- /*gotype: heckel.io/ntfy/server.indexPage*/ -}}
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>ntfy.sh | PUT/POST push notifications to your phone</title>
  7. <link rel="stylesheet" href="static/css/app.css" type="text/css">
  8. <!-- Mobile view -->
  9. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
  10. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  11. <meta name="HandheldFriendly" content="true">
  12. <!-- Mobile browsers, background color -->
  13. <meta name="theme-color" content="#317f6f">
  14. <meta name="msapplication-navbutton-color" content="#317f6f">
  15. <meta name="apple-mobile-web-app-status-bar-style" content="#317f6f">
  16. <!-- Favicon, see favicon.io -->
  17. <link rel="icon" type="image/png" href="static/img/favicon.png">
  18. <!-- Previews in Google, Slack, WhatsApp, etc. -->
  19. <meta property="og:type" content="website" />
  20. <meta property="og:locale" content="en_US" />
  21. <meta property="og:site_name" content="ntfy.sh" />
  22. <meta property="og:title" content="ntfy.sh | send push notifications to your phone via simple PUT/POST requests" />
  23. <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." />
  24. <meta property="og:image" content="/static/img/ntfy.png" />
  25. <meta property="og:url" content="https://ntfy.sh" />
  26. {{if .Topic}}
  27. <!-- Never index topic page -->
  28. <meta name="robots" content="noindex, nofollow" />
  29. {{end}}
  30. </head>
  31. <body>
  32. <nav id="header">
  33. <div id="headerBox">
  34. <img id="logo" src="static/img/ntfy.png" alt="logo"/>
  35. <div id="name">ntfy.sh</div>
  36. <ol>
  37. <li><a href="docs/">Getting started</a></li>
  38. <li><a href="docs/subscribe/phone/">Android/iOS</a></li>
  39. <li><a href="docs/publish/">API</a></li>
  40. <li><a href="docs/install/">Self-hosting</a></li>
  41. </ol>
  42. </div>
  43. </nav>
  44. <div id="main"{{if .Topic}} style="display: none"{{end}}>
  45. <h1>Send push notifications to your phone or desktop via PUT/POST</h1>
  46. <p>
  47. <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.
  48. It allows you to send notifications to your phone or desktop via scripts from any computer,
  49. 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.
  50. </p>
  51. <div id="screenshots">
  52. <a href="static/img/screenshot-curl.png"><img src="static/img/screenshot-curl.png"/></a>
  53. <a href="static/img/screenshot-web-detail.png"><img src="static/img/screenshot-web-detail.png"/></a>
  54. <span class="nowrap">
  55. <a href="static/img/screenshot-phone-main.jpg"><img src="static/img/screenshot-phone-main.jpg"/></a>
  56. <a href="static/img/screenshot-phone-detail.jpg"><img src="static/img/screenshot-phone-detail.jpg"/></a>
  57. <a href="static/img/screenshot-phone-notification.jpg"><img src="static/img/screenshot-phone-notification.jpg"/></a>
  58. </span>
  59. </div>
  60. <p>
  61. There are many ways to use it: Notify yourself when a build finishes, when an rsync is done or a backup fails,
  62. or know when somebody logs into your server. There are <a href="#examples">many more examples</a>, endless possibilities 😀.
  63. </p>
  64. <h2 id="publish" class="anchor">Publishing messages</h2>
  65. <p>
  66. Publishing messages can be done via PUT or POST. Topics are created on the fly by subscribing or publishing to them.
  67. Because there is no sign-up, <b>the topic is essentially a password</b>, so pick something that's not easily guessable.
  68. </p>
  69. <p class="smallMarginBottom">
  70. Here's an example showing how to publish a message using a POST request (via <tt>curl -d</tt>):
  71. </p>
  72. <code>
  73. curl -d "Backup successful 😀" <span class="ntfyUrl">ntfy.sh</span>/mytopic
  74. </code>
  75. <p class="smallMarginBottom">
  76. There are <a href="#other-features">more features</a> related to publishing messages: You can set a
  77. <a href="#priority">notification priority</a>, a <a href="#title">title</a>, and <a href="#tags">tag messages</a>.
  78. Here's an example using all of them:
  79. </p>
  80. <code>
  81. curl \<br/>
  82. &nbsp;&nbsp;-H "Title: Unauthorized access detected" \<br/>
  83. &nbsp;&nbsp;-H "Priority: urgent" \<br/>
  84. &nbsp;&nbsp;-H "Tags: warning,skull" \<br/>
  85. &nbsp;&nbsp;-d "Remote access to $(hostname) detected. Act right away." \<br/>
  86. &nbsp;&nbsp;<span class="ntfyUrl">ntfy.sh</span>/mytopic
  87. </code>
  88. <h2 id="subscribe" class="anchor">Subscribe to a topic</h2>
  89. <p>
  90. You can create and subscribe to a topic either <a href="docs/subscribe/phone/">using your phone</a>,
  91. in <a href="docs/subscribe/web/">this web UI</a>, or in your own app by <a href="docs/subscribe/api/">subscribing via the API</a>.
  92. </p>
  93. <div id="subscribeBox">
  94. <h3 id="subscribe-web" class="anchor">Subscribe in this Web UI</h3>
  95. <p id="error"></p>
  96. <p>
  97. Subscribe to topics here and receive messages as <b>desktop notification</b>. Topics are not password-protected,
  98. so choose a name that's not easy to guess. Once subscribed, you can publish messages via PUT/POST.
  99. </p>
  100. <form id="subscribeForm">
  101. <p>
  102. <b>Topic:</b><br/>
  103. <input type="text" id="topicField" autocomplete="off" placeholder="Topic name, e.g. phil_alerts" maxlength="64" pattern="[-_A-Za-z0-9]{1,64}" />
  104. <button id="subscribeButton">Subscribe</button>
  105. </p>
  106. <p id="topicsHeader"><b>Subscribed topics:</b></p>
  107. <ul id="topicsList"></ul>
  108. </form>
  109. <audio id="notifySound" src="static/sound/mixkit-message-pop-alert-2354.mp3"></audio>
  110. </div>
  111. <h3 id="subscribe-phone" class="anchor">Subscribe from your phone</h3>
  112. <p>
  113. You can use the <a href="https://play.google.com/store/apps/details?id=io.heckel.ntfy">Ntfy Android App</a>
  114. 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>.
  115. 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>.
  116. </p>
  117. <p>
  118. <a href="https://play.google.com/store/apps/details?id=io.heckel.ntfy"><img src="static/img/badge-googleplay.png"></a>
  119. <a href="https://github.com/binwiederhier/ntfy/issues/4"><img src="static/img/badge-appstore.png"></a>
  120. </p>
  121. <h3 id="subscribe-api" class="anchor">Subscribe via your app, or via the CLI</h3>
  122. <p class="smallMarginBottom">
  123. Using <a href="https://developer.mozilla.org/en-US/docs/Web/API/EventSource">EventSource</a> in JS, you can consume
  124. notifications like this (see <a href="example.html">live example</a>):
  125. </p>
  126. <code>
  127. const eventSource = new EventSource('<span class="ntfyProtocol">https://</span><span class="ntfyUrl">ntfy.sh</span>/mytopic/sse');<br/>
  128. eventSource.onmessage = (e) => {<br/>
  129. &nbsp;&nbsp;// Do something with e.data<br/>
  130. };
  131. </code>
  132. <p class="smallMarginBottom">
  133. You can also use the same <tt>/sse</tt> endpoint via <tt>curl</tt> or any other HTTP library:
  134. </p>
  135. <code>
  136. $ curl -s <span class="ntfyUrl">ntfy.sh</span>/mytopic/sse<br/>
  137. event: open<br/>
  138. data: {"id":"weSj9RtNkj","time":1635528898,"event":"open","topic":"mytopic"}<br/><br/>
  139. data: {"id":"p0M5y6gcCY","time":1635528909,"event":"message","topic":"mytopic","message":"Hi!"}<br/><br/>
  140. event: keepalive<br/>
  141. data: {"id":"VNxNIg5fpt","time":1635528928,"event":"keepalive","topic":"test"}
  142. </code>
  143. <p class="smallMarginBottom">
  144. To consume JSON instead, use the <tt>/json</tt> endpoint, which prints one message per line:
  145. </p>
  146. <code>
  147. $ curl -s <span class="ntfyUrl">ntfy.sh</span>/mytopic/json<br/>
  148. {"id":"SLiKI64DOt","time":1635528757,"event":"open","topic":"mytopic"}<br/>
  149. {"id":"hwQ2YpKdmg","time":1635528741,"event":"message","topic":"mytopic","message":"Hi!"}<br/>
  150. {"id":"DGUDShMCsc","time":1635528787,"event":"keepalive","topic":"mytopic"}
  151. </code>
  152. <p class="smallMarginBottom">
  153. Or use the <tt>/raw</tt> endpoint if you need something super simple (empty lines are keepalive messages):
  154. </p>
  155. <code>
  156. $ curl -s <span class="ntfyUrl">ntfy.sh</span>/mytopic/raw<br/>
  157. <br/>
  158. This is a notification<br/>
  159. And another one with a smiley face 😀
  160. </code>
  161. <center id="ironicCenterTagDontFreakOut"><i>Made with ❤️ by <a href="https://heckel.io">Philipp C. Heckel</a></i></center>
  162. </div>
  163. <div id="detail"{{if not .Topic}} style="display: none"{{end}}>
  164. <div id="detailMain">
  165. <button id="detailCloseButton"><img src="static/img/close.svg"/></button>
  166. <h1><span id="detailTitle"></span></h1>
  167. <p class="smallMarginBottom">
  168. <b>ntfy</b> is a simple HTTP-based pub-sub notification service. This is a ntfy topic.
  169. To send notifications to it, simply PUT or POST to the topic URL. Here's an example using <tt>curl</tt>:
  170. </p>
  171. <code>
  172. curl -d "Backup failed" <span id="detailTopicUrl">ntfy.sh/topic</span>
  173. </code>
  174. <p id="detailNotificationsDisallowed">
  175. If you'd like to receive desktop notifications when new messages arrive on this topic, you have
  176. <a href="#" onclick="return requestPermission()">grant the browser permission</a> to show notifications.
  177. Click the link to do so.
  178. </p>
  179. <p class="smallMarginBottom">
  180. <b>Recent notifications</b> (cached for {{.CacheDuration}}):
  181. </p>
  182. <p id="detailNoNotifications">
  183. <i>You haven't received any notifications for this topic yet.</i>
  184. </p>
  185. <div id="detailEventsList"></div>
  186. </div>
  187. </div>
  188. <div id="lightbox" class="lightbox"></div>
  189. <script src="static/js/emoji.js"></script>
  190. <script src="static/js/app.js"></script>
  191. </body>
  192. </html>