Fetch the complete documentation index at: https://streamlabs.readme.io/llms.txt. Use this file to discover all available pages before exploring further.

# Socket API

Socket Token can be fetched using **[/socket/token endpoint](https://streamlabs.readme.io/docs/sockettoken)**
Sample Code:

[block:code]
{
  "codes": [
    {
      "code": "<script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js' type='text/javascript'></script>\n<script type = 'text/javascript'>\n  const socketToken = ''; //Socket token from /socket/token end point\n\t\n\t//Connect to socket\n\tconst streamlabs = io(`https://sockets.streamlabs.com?token=${socketToken}`);\n\t\n\t//Perform Action on event\n\tstreamlabs.on('event', (eventData) => {\n    if (!eventData.for && eventData.type === 'donation') {\n    \t//code to handle donation events\n      console.log(eventData.message);\n    }\n    if (eventData.for === 'twitch_account') {\n      switch(eventData.type) {\n        case 'follow':\n          //code to handle follow events\n          console.log(eventData.message);\n          break;\n        case 'subscription':\n          //code to handle subscription events\n          console.log(eventData.message);\n          break;\n        default:\n          //default case\n          console.log(eventData.message);\n      }\n    }\n  });\n</script>",
      "language": "javascript"
    }
  ]
}
[/block]

[block:callout]
{
  "type": "danger",
  "title": "eventData.message",
  "body": "This will always be an array"
}
[/block]

***type*** and ***for*** values for different events are described below

[block:parameters]
{
  "data": {
    "h-0": "type",
    "h-1": "for",
    "1-0": "follow",
    "1-1": "twitch_account",
    "h-2": "Event",
    "1-2": "Twitch Follow",
    "2-0": "subscription",
    "3-0": "host",
    "4-0": "bits",
    "2-1": "twitch_account",
    "3-1": "twitch_account",
    "4-1": "twitch_account",
    "2-2": "Twitch Subscription",
    "3-2": "Twitch Host",
    "4-2": "Twitch Bits/Cheers",
    "0-0": "donation",
    "0-1": "-",
    "0-2": "Donations",
    "5-0": "follow",
    "6-0": "subscription",
    "7-0": "superchat",
    "5-1": "youtube_account",
    "6-1": "youtube_account",
    "7-1": "youtube_account",
    "5-2": "Youtube Subscriber",
    "6-2": "Youtube Sponsor",
    "7-2": "Youtube Superchats",
    "8-0": "follow",
    "8-1": "mixer_account",
    "8-2": "Mixer Follow",
    "9-0": "subscription",
    "9-1": "mixer_account",
    "9-2": "Mixer Subscription",
    "10-0": "host",
    "10-1": "mixer_account",
    "10-2": "Mixer Host"
  },
  "cols": 3,
  "rows": 11
}
[/block]

# Sample Responses:

Donations

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"donation\",\n  \"message\": [\n    {\n      \"id\": 96164121,\n      \"name\": \"test\",\n      \"amount\": \"13.37\",\n      \"formatted_amount\": \"$13.37\",\n      \"formattedAmount\": \"$13.37\",\n      \"message\": \"test donation\",\n      \"currency\": \"USD\",\n      \"emotes\": null,\n      \"iconClassName\": \"user\",\n      \"to\": {\n        \"name\": \"Sai Harsha Maddela\"\n      },\n      \"from\": \"test\",\n      \"from_user_id\": null,\n      \"_id\": \"0820c9d5bafd768c9843f5e35c885e71\"\n    }\n  ],\n  \"event_id\": \"evt_17e5f4dc6888767ed9799f78dfa2cabc\"\n}",
      "language": "json"
    }
  ]
}
[/block]

Twitch Subscription

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"subscription\",\n  \"message\": [\n    {\n      \"name\": \"kevin\",\n      \"months\": 7,\n      \"message\": \"sub message\",\n      \"emotes\": null,\n      \"sub_plan\": 1000,\n      \"sub_plan_name\": \"Sample Plan name\",\n      \"sub_type\": \"resub\",\n      \"_id\": \"a226a8c223634afdc368439c1da7aaba\"\n    }\n  ],\n  \"for\": \"twitch_account\"\n}",
      "language": "json",
      "name": null
    }
  ]
}
[/block]

Twitch Follow

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"follow\",\n  \"message\": [\n    {\n      \"created_at\": \"2017-08-22 00:14:35\",\n      \"id\": \"170884026\",\n      \"name\": \"h4r5h48002\",\n      \"_id\": \"74a0b93e736f1f14762111f8ae34bf42\"\n    }\n  ],\n  \"for\": \"twitch_account\"\n}",
      "language": "json"
    }
  ]
}
[/block]

Twitch Host

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"host\",\n  \"message\": [\n    {\n      \"name\": \"h4r5h48002\",\n      \"viewers\": \"1\",\n      \"type\": \"manual\",\n      \"_id\": \"74a0b93e736f1f14762111f8ae34bf42\"\n    }\n  ],\n  \"for\": \"twitch_account\"\n}",
      "language": "json"
    }
  ]
}
[/block]

Twitch Bits

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"bits\",\n  \"message\": [\n    {\n      \"id\": \"fc546f7d-aab8-42b2-9933-8681e9fb5eb0\",\n      \"name\": \"h4r5h48002\",\n      \"amount\": \"1\",\n\t\t\t\"emotes\": null,\n\t\t\t\"message\": \"streamlabs1\",\n      \"_id\": \"74a0b93e736f1f14762111f8ae34bf42\"\n    }\n  ],\n  \"for\": \"twitch_account\"\n}",
      "language": "json"
    }
  ]
}
[/block]

Youtube Subscriber

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"follow\",\n  \"message\": [\n    {\n      \"publishedAt\": \"2017-08-22 00:25:57\",\n      \"id\": \"UCec4hVEu3ZXE8qlRtUeK0DA\",\n      \"name\": \"Kappa Lord\",\n      \"_id\": \"6af0964e548a6d93c192c9e31e0959cc\"\n    }\n  ],\n  \"for\": \"youtube_account\"\n}",
      "language": "json"
    }
  ]
}
[/block]

Youtube Sponsor

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"subscription\",\n  \"message\": [\n    {\n      \"sponsorSince\": \"2017-08-22 00:45:48\",\n      \"id\": \"UCec4hVEu3ZXE8qlRtUeK0DA\",\n      \"name\": \"Kappa Lord\",\n      \"channelUrl\": \"http://www.youtube.com/channel/UCec4hVEu3ZXE8qlRtUeK0DA\",\n      \"months\": 3,\n      \"_id\": \"33d396edab6e2e2e8b37a7b6f1b60b82\"\n    }\n  ],\n  \"for\": \"youtube_account\"\n}",
      "language": "json"
    }
  ]
}
[/block]

Youtube Superchat

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"superchat\",\n  \"message\": [\n    {\n      \"id\": \"LCC.Cg8KDQoLWmpUemdzdU1vM2sSHAoaQ05PcW01UzJ3dElDRll2WkhBb2RLd0lBOWc0.028141892513880107\",\n      \"channelId\": \"UCec4hVEu3ZXE8qlRtUeK0DA\",\n      \"channelUrl\": \"http://www.youtube.com/channel/UCec4hVEu3ZXE8qlRtUeK0DA\",\n      \"name\": \"Kappa Lord\",\n      \"comment\": \"love the stream\",\n      \"amount\": \"2000000\",\n      \"currency\": \"USD\",\n      \"displayString\": \"$2.00\",\n      \"messageType\": 2,\n      \"createdAt\": \"2017-08-22 00:51:57\",\n      \"_id\": \"ad46c7e468331c5e39373e05876fa17e\"\n    }\n  ],\n  \"for\": \"youtube_account\"\n}",
      "language": "json"
    }
  ]
}
[/block]

Mixer Follow

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"follow\",\n  \"message\": [\n    {\n      \"id\": 1816,\n      \"name\": \"Jamacanbacn\",\n      \"created_at\": \"2017-08-22 00:30:25\",\n      \"_id\": \"4fbcdd82bc9fd39467572b24ee20a766\"\n    }\n  ],\n  \"for\": \"mixer_account\"\n}",
      "language": "json"
    }
  ]
}
[/block]

Mixer Subscription

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"subscription\",\n  \"message\": [\n    {\n      \"id\": \"123456\",\n      \"name\": \"h4r5h4\",\n      \"months\": 2,\n      \"message\": null,\n      \"emotes\": null,\n      \"since\": \"2017-08-22 00:36:59\",\n      \"_id\": \"68f034214d68dce22431801b940d2b90\"\n    }\n  ],\n  \"for\": \"mixer_account\"\n}",
      "language": "json"
    }
  ]
}
[/block]

Mixer Host

[block:code]
{
  "codes": [
    {
      "code": "{\n  \"type\": \"host\",\n  \"message\": [\n    {\n      \"name\": \"h4r5h47\",\n      \"viewers\": \"5\",\n      \"type\": \"manual\",\n      \"_id\": \"4ee5fcf7e34128f4f07bb978c9e35fd4\"\n    }\n  ],\n  \"for\": \"mixer_account\"\n}",
      "language": "json"
    }
  ]
}
[/block]