Mixer Client Node
This is a client library for Mixer written in Node.js.
Support
If you ever need any support on using the client be sure to join the Discord or post an issue on the Github Repo. Discord is highly recommended when asking for support as I check it more frequently.
Installation
npm install --save mixer-client-node
Once github registry is open I will add a way to install it via github as well!
Tutorials
Need some help with tutorials? You can find the tutorials I have made HERE. There is a limited amount of tutorials due to the fact that I want to make sure the tutorials are high quality and understandable. If you want to submit any tutorials to me you can reach out to me via Discord: Unsmart#0917 or via email: me@unsmart.co.
I recommend you look at the tutorials to get a basic understanding of how to use the client, and what each thing does.
Usage
Here you can find all the basic things that this client can handle for you and how to use the client. If you have any issues understanding any documentation or if you find something is not working as you believe it should either send an issue on the Github Repo or join the Discord and ask for support in the dev-support channel.
Client
let Mixer = Client; // (All possibilities for inputs): This is recommended when using the chat serviceslet client = tokens: access: 'xxxxxxxx' refresh: 'xxxxxxxx' clientid: 'xxxxxxxx' secretid: 'xxxxxxxx' user: userid: 755643 channelid: 529479 // See note* ; // (Only required variables): This is all you need if you are only using constellationlet client = clientid: 'xxxxxxxx';
*Note: The channelid you set in the user object does NOT have to be the owner of the tokens (the userid has to be) you can set the channelid to any channel you want, so if the userid is the bot account you can set the channelid to the streamers channelid. When joining chats this user object is highly recommended to be set but is not needed.
If you have a secretid for your client you must set it in order to use the authorization features of this client.
clientid must always be set as every service is required to know the clientid the requests are coming from to work.
When using the chat features you must at least specify the access token and clientid at a minimum. It is recommended you specify the access and refresh (refresh tokens do not come with an implicit grant) tokens, client and secret ids, and the user object. As it will make connecting to chat much easier.
Chat
The following is a list of all the chat methods implemented.
Join a chat
client;client;client;client;client;client; // OR you can get the chat socket using promises client
It is recommended that you set the user object when creating the client instance as it makes the join command much simpler. You can do just client.joinChat() instead of having to input the channelid to join, and the userid of the token owner. Also note: The channelid you set in the user object does NOT have to be the owner of the tokens (the userid has to be) you can set the channelid to any channel you want, so if the userid is the bot account you can set the channelid to the streamers channelid. See client info
Anonymous chat joining is not supported and not planned currently.
Close connection to chat
client; //CHANNEL_ID not needed if you are only connected to one chat//No 'closed' event will be emitted
Send a chat message
client; //CHANNEL_ID not needed if you are only connected to one chat
Note: The 360 character count limit is handled by this client so put your full message in there without worrying about how long it is!
Chat Events
let chat = clientchatService chat; // This is only sent when you are authenticated to the chat chat; chat; chat; chat chat;
*Event Names The data sent is is the data object from the payload of each event, not the full payload object.
Authentication
This client will handle refreshing tokens and checking tokens via introspection for you.
Refresh Tokens
client
Introspect
client;
Set Tokens
clienttokens = access: 'xxxxxxxx' refresh: 'xxxxxxxx' //refresh is optional expires: 0 // expires is optional (The second timestamp for when the token expires)
Note when using the refresh tokens part of this client the new tokens are automatically set including the new expire time. The expires time is also set if you use the introspect part of the client with the access token as the checked token.
Get Tokens
let tokens = clienttokens let accessToken = clientaccessToken || clienttokensaccesslet refreshToken = clientrefreshToken || clienttokensrefreshlet expiresAt = clientexpires || clienttokensexpires let didExpire = clientdidExpire
API Requests
Using the request module from the client automatically limits requests to the correct rate-limit.
Request
let requestOptions = method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' uri: "FULL_API_URL" headers?: {} body?: {} auth?: true | false // Default: false;client
Constellation
Need to connect to events using the mixer constellation in order to get live updates to channels like follows, subs, or updated view counts, or features, etc? This client can handle that as well. You can see a full list of event HERE to subscribe to.
*Note: This is currently an early test version of my own constellation handler, as I am new to the constellation service, it may be buggy and if you notice any bugs during development please submit an issue on the GitHub Repo or let me know in the dev-support channel on the Discord.
Some constellation features may change often and may include breaking changes, if anything ever breaks come back here as this will always be up to date.
Info on what each event returns may not be fully complete as I am still investigating every possibility of what constellation returns.
Subscribe
client
Unsubscribe
client
Get Subscribed Events
let events = clientsubscribedEvents // returns a string array of events
Constellation Events
clientconstellationService clientconstellationService clientconstellationService clientconstellationService clientconstellationService clientconstellationService
*Note: The payload data for each constellation event can be found HERE. This also shows the event argument to pass in the subscribe event.