What is WebSocket?

As wikipedia says:

"Websocket is a protocol providing full-duplex communications channels over a single TCP connection. WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application."

Getting started with thethings.iO WebSocket API

thethings.iO offers a socket.io server to be able to develop realtime browser apps. So you have to build your client with socket.io to be able to connect with our socket.io server. The REST API subscription endpoint is not reliable on browsers, so you'll better subscribe via Websockets.

Our Websocket server only subscribes. To authenticate, write, etc. You have to use the REST API as explained at our APP Development Docs.

To be able to follow this example you will need a session token. You can get the session token via register or login with the respective REST API endpoints, as commented before.

thethings.iO Websocket server:


In the examples, the { {SOMETHING} } (braces included) indicate variables that you may replace for the appropiate value.


You have to subscribe to a topic. Where a topic can be:

  • An user’s resource, eg. /me/resources/{ {resource} }
  • A thing eg. /things/{ {thingToken} } . But be careful here, You don't want to make public your thingToken. This option is only recommended for intranets or other private pages under authentication.


At this example, we show how to subscribe to the topic '/me/resources/temperature' , to get in real-time the values published.