Introducing the Twitch Command Line Interface Tool
During Twitch Developer Day we announced a number of new products including EventSub, our new solution for building real-time experiences with Twitch. We’ve been delighted to share EventSub and look forward to its continued evolution with your feedback.
A common theme that arose from initial reactions was the challenge of migrating to a new format of webhooks – and other potential transport protocols in the future like websockets – as well as testing webhooks without creating your own staging server or using third-party tools like ngrok to stand up a localhost server.
To help solve this and other common development challenges, we are delighted to announce the Twitch CLI (Command Line Interface). This officially-supported tool is now available in an open beta. During this period of time, we’d like to receive your feedback for improvements in the Twitch CLI UserVoice category. Once feedback has been incorporated and we’re ready to move beyond the beta, we will distribute the tool more widely through updates such as including its use in technical documentation and adding it to popular package managers. Let’s review some of the functionality you can expect to leverage in your development workflow.
Test and Migrate to EventSub
The most significant feature within the CLI at this time is the ability to generate and trigger mock events to local web servers without a need for additional software. While this data is not real, it allows developers to test EventSub servers locally. It supports several helpful functions including secret signing, headers, and all topics that require payments (e.g. Bits and Subscriptions). Support for additional topics will be added in the near future.
Generate OAuth Tokens
Grasping the underlying concepts of authentication can be a significant hurdle for developers just getting started with Twitch development and generating tokens can even be cumbersome for more experienced developers. To make this process quicker and easier, we’ve included support in the CLI to generate tokens locally for your application (including app access tokens).
In conjunction with this announcement, we’ve also published code samples for products released during Developer Day that demonstrate how the CLI can be used for generating authentication tokens.
Query the Twitch API
The CLI also includes the ability to send Twitch API requests for convenience. This allows you to test the return payloads of endpoints or even carry out quick requests such as setting the category on your channel, getting a game ID, or searching for broadcasters playing your game or using your Extension.
It supports all endpoints and methods, and includes support for passing bodies with a cURL-like syntax instead of passing in a string.
Community-Driven and Twitch-Supported
While building the CLI, we decided early in the process that it should be a Twitch-supported open-sourced project. We believe that you, the developer community, will help us accelerate its development and contribute features we may have not considered to solve common development challenges. To empower this innovation, we are open-sourcing the project on GitHub and will be accepting your contributions. Even if you find a small bug, feel free to open an issue or make a pull request!
Beyond community contributions, we want this to be a starting point for a number of features supporting EventSub and other developer products. For example, investigating how we can add CI/CD integrations (Continuous Integration, Delivery, and Deployment) for testing events. Our aim is to consider additional features such as these in the new year.
To get started with the Twitch CLI, refer to the twitchdev/twitch-cli repository or go directly to the releases section to download the tool. You can then provide feedback contributing to the tool’s future plans via the Twitch Developer UserVoice category.