diff --git a/docs/subscribe/api.md b/docs/subscribe/api.md index 58da9752..3f1c0e81 100644 --- a/docs/subscribe/api.md +++ b/docs/subscribe/api.md @@ -190,9 +190,10 @@ format. Keepalive messages are sent as empty lines. ## WebSockets You may also subscribe to topics via [WebSockets](https://en.wikipedia.org/wiki/WebSocket), which is also widely -supported in many languages. Most notably, WebSockets are natively supported in JavaScript. On the command line, -I recommend [websocat](https://github.com/vi/websocat), a fantastic tool similar to `socat` or `curl`, but specifically -for WebSockets. +supported in many languages. Most notably, WebSockets are natively supported in JavaScript. You may also want to +check out the [full example on GitHub](https://github.com/binwiederhier/ntfy/tree/main/examples/web-example-websocket). +On the command line, I recommend [websocat](https://github.com/vi/websocat), a fantastic tool similar to `socat` +or `curl`, but specifically for WebSockets. The WebSockets endpoint is available at `/ws` and returns messages as JSON objects similar to the [JSON stream endpoint](#subscribe-as-json-stream). diff --git a/examples/web-example-websocket/example-ws.html b/examples/web-example-websocket/example-ws.html new file mode 100644 index 00000000..7025aa60 --- /dev/null +++ b/examples/web-example-websocket/example-ws.html @@ -0,0 +1,56 @@ + + + + + ntfy.sh: WebSocket Example + + + + +

ntfy.sh: WebSocket Example

+

+ This is an example showing how to use ntfy.sh with + WebSocket.
+ This example doesn't need a server. You can just save the HTML page and run it from anywhere. +

+ +

Log:

+
+ + + + +