Integrations & SDKs
Javascript SDK
the javascript sdk is in beta for access, please contact sales the hotmic javascript sdk is primarily used to allow the following activities from inside your web application get a list of streams get information about a particular stream let a user join a particular stream, using the information your provide and without them having to log into hotmic javascript sdk installation you do need to contact our sales team to install the javascript application this javascript sdk is designed to run in a frontend application, to communicate with the hotmic backend here are instructions on how to install the ios sdk if you ever have issues installing the ios sdk, please contact our team the name of our sdk is hotmicmediaplayer requirements api key and jwt secret will be provided by hotmic we recommend accessing streams via chromium based browsers namely chrome or edge api key and authorization token you will need an api key for your app to use the hotmic service you will also need to create an authorization token hotmic will provide you with the key and information on how to create the token in the appropriate format initialization initialize hmmediaplayer with your api key and authorization token this must be done before any other functions are called in hmmediaplayer, so we recommend performing initialization in your appdelegate’s didfinishlaunchingwithoptions if needed, it can be called again later, for example if the token changes import hotmicmediaplayer hmmediaplayer initialize(apikey "your key", accesstoken token) apikey a uuid provided by hotmic accesstoken use any jwt library to create a token format is as follows const accesstoken = jwt sign({identity { user id \[consistent id for user], display name user display name, profile pic user profile pic, }}, apisecret, { expiresin '1d'}) authentication with jwt token for security, when using the sdk your app controls authentication with a jwt token, which you pass to hotmic json web tokens are an open, industry standard rfc 7519 https //tools ietf org/html/rfc7519 method for representing claims securely between two parties jwt io http //jwt io/ you will receive an api secret from hotmic, which you will use to create the token the token will be used to authenticate the user, as well as provide information such as their name, an avatar, a unique id, or another information which is needed by the sdk this is the expected format of the jwt token // nodejs example const jwt = require('jsonwebtoken'); accesstoken = jwt sign({identity { user id user id, // should be consistent for the user (uuid4) display name user display name, // name displayed in chat/profiles profile pic user profile pic, // image url (https //ui avatars com/api/?name=test\&background=0dcad6\&color=fff) }}, \[api secret], { expiresin '7d'}) note, the user id field should be consistent for each invocation of the sdk for that particular user quick steps to generate a jwt token online you can also generate jwt tokens online! this is good for test purposes while getting started, or to use the sample app here is one way to do it we do not recommend using this method with any sensitive data go to https https //jwt io/ and scroll down add a payload like the following into the "payload" section paste your secret into the "verify signature" section this screenshot shows how it looks and here is a sample payload that should work for your application { "identity" { "user id" "3d5567c2 603c 4b08 b917 7e9f05c8ebb5", "display name" "tester1", "profile pic" "https //ui avatars com/api/?name=test\&background=0dcad6\&color=fff", "badge" "https //hotmic content s3 us west 1 amazonaws com/badges/10 badge png?c251fece c08f 48a0 931e 70cfe8ea7ed4" }, "iat" 1657658555, "exp" 1821724014 } then copy the code from the "encoded" section of this page, and use that in the sample app available functions get streams (or stream) streams are returned in reverse chronological order you can fetch 1 or more streams from hotmic with the following filters that are live, scheduled, and/or video on demand replays userid the userid you want to filter the streams by type string default null (all possible streams) limit the max number of streams to return type integer example 40 default 30 skip the number of results to skip you want to not return in the results, typically used for pagination type integer example 10 default 0 hmmediaplayer getstreams(live true, scheduled true, vod true, userid nil, limit nil, skip nil) { result in switch result { case success(let streams) // display the list of streams case failure(let error) // handle error } } join stream each stream has a url associated with it, hosted by hotmic users can go to the url after getting the jwt token and authenticating generally speaking, for most customers you would want to show 1 or more streams to the user if the user taps a stream to join it, then authenticate and create the jwt token send the user to the url of the stream note add exit redirect/url note how to handle hosts differently (just redirect to broadcast page?) while urls for streams are hosted on hotmic, we can do some themeing or branding of the stream linking followers/following to your application to support following and unfollowing users from inside the hotmic experience, contact sales linking in app purchases to your application to support tipping hosts and joining their streams for a price, you can implement integrate with your payment provider and system for tipping contact sales for more information