Skip to content

Latest commit

 

History

History
100 lines (73 loc) · 1.82 KB

Clips.md

File metadata and controls

100 lines (73 loc) · 1.82 KB

HypeRate DevDocs

Getting an API key

You need to request your websocket key on our website.

Connecting to the API

URL: wss://app.hyperate.io/socket/websocket?token=<MY-WEBSOCKET-KEY>

Required websocket messages

Join Channel

You need to join the appropiate channel before any data will be sent to your client.

To do this you need to send the following JSON message:

{
	"topic": "clips:<ID>",
	"event": "phx_join",
	"payload": {},
	"ref": 0
}

This would be the correct message to join the "internal-testing" channel:

{
	"topic": "clips:internal-testing",
	"event": "phx_join",
	"payload": {},
	"ref": 0
}

Receiving data

Every time the user creates a clip the following JSON will be send from the server to the client:

HINT: The twitch_slug key in the payload object is the slug directly from Twitch.

You would build the correct URL like this:

https://clips.twitch.tv/<twitch_slug>

Example with the slug from below:

https://clips.twitch.tv/FuriousExuberantTruffleCmonBruh-AmSuUmskamv8RPin

{
	"ref": null,
	"payload": {
		"twitch_slug": "FuriousExuberantTruffleCmonBruh-AmSuUmskamv8RPin"
	},
	"topic": "clips:internal-testing",
	"event": "clip:created"
}

Send keep-alive packet

Phoenix expects that you send the keep-alive packet every 10 seconds otherwise the connection will be closed.

{
	"topic": "phoenix",
	"event": "heartbeat",
	"payload": {},
	"ref": 0
}

Leave channel

In case you only want to leave a joined channel you can send the following message:

{
	"topic": "clips:<ID>",
	"event": "phx_leave",
	"payload": {},
	"ref": 0
}

This would be the correct message to leave the "internal-testing" channel:

{
	"topic": "clips:internal-testing",
	"event": "phx_leave",
	"payload": {},
	"ref": 0
}