The optk Developer Command Line Utility

tokbox-inc_markWhen I’m working on developing an OpenTok application, I want to move fast. As a software engineer, I have loads of little workflow shortcuts, scripts, tricks, and favorite tools. When I started to build optk, I wanted to shave off just a couple seconds off of something that I had to do dozens of times a day.

I usually start my OpenTok project building the client, whether that be using the OpenTok JavaScript SDK, iOS SDK, or Android SDK. A button here, a label there, fill out the menu, and then add some WebRTC-powered streaming goodness. At that point I’m not worried about how Sessions and Tokens are going to be generated, that’s a concern for my server, and I’ll solve that after I have some basic tangible UX.

Getting the interactions with Publishers and Subscribers right is a central part of all apps that use the platform. In order to create these objects, I will need a sessionId and token. There’s already a handy shortcut built right into the Dashboard:

Screen Shot 2016-01-29 at 2.29.42 PM.png

But I want to go faster. As a developer, I live inside my Terminal, so wouldn’t it be great if I didn’t have to leave it just to get those values? That’s where optk comes in.

The optk CLI utility outputs a session and token that I can use as a temporary value inside my client application. It is flexible enough to make routed or relayed sessions, tokens with various role based permissions, and many more options. To get it set up, you need node and npm on your development machine, and run the command: npm install -g optk-cli . Place an OpenTok API Key and Secret into a text file named .optk inside your home directory like below:



Now you’re all set up. Use the optk help command to see the commands and optk session -h to understand all the options for a given command.

Building the tool was as simple as wrapping OpenTok Node SDK in a node module, and designing the CLI interface. I’d love to hear if you find it helpful (or not), and hear your suggestions for new functionality. Feel free to contribute or create new issues on GitHub: