Vonage OpenTok library shims
Daily offers two shim libraries, which are drop-in replacements for Vonage video APIs (formerly Tokbox OpenTok). Our shims can help you migrate your app to Daily infrastructure.
daily-opentok-client(npm, GitHub): a client-side shim for Vonage's
daily-opentok-node(npm, GitHub): A Node.js shim for Vonage's server-side
We've created a small demo app based on Vonage's basic call demo to demonstrate how these shims can be used to replace OpenTok functionality with Daily by updating the library imports.
Shim use cases
Shims are a basic starting point for converting your application from Vonage to Daily infrastructure. Our shims implement selected functionality of their respective OpenTok libraries. Please contact us if your use case requires features that the shims do not yet implement.
Daily's APIs perform best when called from a bespoke codebase. But shims can assist you with converting your existing codebase to Daily infrastructure while giving you the time you need to fully migrate your app to our platform using our Client SDKs or Daily Prebuilt.
The shims enable you to take advantage of Daily's default call quality settings in the majority of the use cases. However, unlike OpenTok APIs, Daily's call-quality APIs enable you to further configure and adapt to your use case for the best end user experience.
Please reach out to our support team if you would like assistance with migrating your product to Daily.
Getting started with
npm install daily-opentok-client
Replace your original OpenTok client import, commented out here, with the shim:
Using a script tag
Replace your OpenTok script tag with the shim:
OT.initSession() in your code, replace your OpenTok session ID with your Daily room URL. You can obtain a Daily room URL by creating a room with either our REST API or the Daily dashboard.
Do not replace Vonage's API key with Daily's API key on the client side! Daily's API key should never be exposed to clients and is not required for client-side Daily operations. You can just set an empty string for the API-key parameter in
The Daily OpenTok client shim supports basic OpenTok functionality such as initializing sessions, getting user media, setting output media, and appending publisher and subscriber media to the DOM.
If you already have a server component that programmatically creates OpenTok sessions, you can use our OpenTok Node.js shim to create Daily rooms instead. We'll go through that process next.
Getting started with
npm install daily-opentok-node
In your server-side application, replace your original OpenTok library reference with the shim:
When creating a new
OpenTok instance, pass your Daily API key into the constructor instead of your Vonage API key and secret:
You can also optionally specify your Daily domain ID as a second argument in the
OpenTok constructor. The shim requires your domain ID in order to retrieve Daily meeting tokens.
The Daily domain ID can be obtained by making a
GET request to the domain configuration endpoint. If you opt not to pre-fetch the domain ID, you can instead have the shim itself retrieve and self-assign your Daily domain ID by adding the following call after the
OpenTok's sessions correspond to Daily's rooms. The shim creates a Daily room whenever you call
"routed" modes are supported for session/room creation. These correspond to Daily's peer-to-peer and SFU modes, respectively. You can learn more about each mode in our video call architecture guide.
OT.generateToken() method generates a Daily meeting token for the provided room ID.
If your existing
generateToken() call is specifying the
"moderator" role, an "owner" meeting token will be created, which grants the recipient admin privileges within the room.
If you do not specify an
expireTime property in your token options, a default expiry time of 24 hours will be set instead.
If you have any feedback on the shims or questions about switching from other video providers to Daily, please contact our support team.