Connecting to Twitch API with NodeJS and socket io

Chat libraries generally won’t.
As they handle chat rather than API or EventSub operations, which is where CP’s reside.

cURL is more like the alphabet than a different langauge but sure.
Since use seem to be using node/JS

You’ll need to pick a library to make HTTP requests with and then something like

Where the token is a user token

curl -X GET 'https://api.twitch.tv/helix/users' \
-H 'Authorization: Bearer cfabdegwdoklmawdzdo98xt2fo512y' \
-H 'Client-Id: uo6dggojyb8d6soh92zknwmi5ej1q2'

becomes, when using the HTTP Lib got

got({
    url: 'https://api.twitch.tv/helix/users',
    headers: {
        'Client-ID': 'uo6dggojyb8d6soh92zknwmi5ej1q2',
        'Authorization': 'Bearer cfabdegwdoklmawdzdo98xt2fo512y'
    },
    responseType: 'json'
})
.then(resp => {
    // process resp.body
})
.catch(err => {
    // do error processing
})

Once you know how to make HTTP calls in your language of choice then you can read any docs in cURL.

Not really no.

SocketIO is WS but encapsulated.

So socketIO you do io.on('eventDefinedByTheProvider

Where is WebSocket it’s all .on('message

It doesn’t split them into events for you it’s all one event.

So a “full” pubsub example is linked

This

  • sets up the pubsub socket connection.
  • The Ping/Pong loop functions
  • Asking for topics (fake/bad topics in the runAuth)
  • Message console.log-ing (no processing)

So

That line is the actual messge recieverm, the process msg (line 93) to see what topic it is and action/do your own stuff as needed when this triggers.