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:

  1. Get a list of streams
  2. Get information about a particular stream
  3. 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.

Swift


ApiKey

A UUID provided by HotMic. 

AccessToken

Use any JWT library to create a token.  Format is as follows:

JS


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 method for representing claims securely between two parties. - 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:

JS


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://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:

Document image


And here is a sample payload that should work for your application:

JSON


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



JS




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.