Skip to content

WebSocket API (V4)

Cameron Fleming edited this page Jun 26, 2018 · 1 revision

tmw.media WebSocket API

In API Version 4 we introduced a WebSocket that sends push messages out everytime the song on our radio station changes.

Connecting

As our websocket may change it's location down the line, you must first make a HTTP GET request to api.tmw.media/gateway where you will receive the gateway address in JSON, for example {"gateway": "gateway.tmw.media"} use this to connect to our WS gateway.

Once your connection opens

We will first send you this payload:

{"cmd":"HELLO","message":"Welcome to the tmw.media API! - Read the docs for more information or hang around for live song updates.", "version": "4"}

Use this to ensure you have connected correctly and are using your supported version of the websocket, if not we suggest you fall back to the REST API.

After that we will instantly send you a currently playing payload for you to update your page to the active song with the "DISPATCH_PAYLOAD" command, it contains all of the information aggregates on the rest API does.

For example:

{"cmd": "DISPATCH_PAYLOAD", "service": "ggradio", "payload": {"live": SONG/LIVE modal (See REST docs), "artwork": "artwork_url", "recent": 4 recent songs}}

Please see the REST documentation for aggregates information.

Feel free to connect or disconnect at any time. you will receive all the data for all stations "service" contains the station name.

We're busy updating our API Documentation to our V4 standard, we're sorry if any information is currently missing.

Clone this wiki locally
You can’t perform that action at this time.