Get Started with the Twitch API

The Twitch API is a RESTful API that lets developers build creative integrations for the broader Twitch community.

To see how easy it is to integrate with the API, let’s use the Twitch CLI (command line interface) to get information about the TwitchDev user.

Step 1: Register an application

The first step is to register your app with Twitch. For information about how to register your app, see Register your app. For this exercise:

Step 2: Authentication using the Twitch CLI

This example uses the Twitch CLI to generate an OAuth access token that’s required to access Twitch resources.

Installing the CLI

For information about how to install the Twitch CLI, see Twitch CLI. If you have trouble installing or running the CLI, assistance is available in the #cli-help channel on the TwitchDev Discord server.

Getting an access token

To get an access token, enter twitch token at the command prompt. Because this is the first time you’re running the token command in this instance of the CLI, the CLI will prompt you for the client ID and secret you created in Step 1. After entering the ID and secret from Step 1, the CLI returns an access token that you’ll use in Step 3. (The access token is an app access token and is valid for 60 days.)

The following example shows the output from the token command.

$ twitch token
No Client ID or Secret found in configuration. Triggering configuration now.
Client ID: wbmytr93xzw8zbg0p1izqyzzc5mbiz
Client Secret: 5ykf41lduut2lvbcnu7zg1wjdhroiw
Updated configuration.
2021/07/30 20:20:06 App Access Token: 2gbdx6oar67tqtcmt49t3wpcgycthx

Note the access token, which you’ll use in Step 3 for the cURL exammple.

Step 3: Making your first Twitch API request

Now that the CLI is configured with your client ID, secret, and access token, you can make your first request. To get information about the TwitchDev user, enter the following Twitch CLI command:

twitch api get users -q login=twitchdev

For information about the api command and usage, see Twitch Api.

The JSON response

The following example shows the JSON response that the request returns.

  "data": [
      "broadcaster_type": "partner",
      "created_at": "2021-07-30T20:32:28Z",
      "description": "Supporting third-party developers building Twitch integrations from chatbots to game integrations.",
      "display_name": "TwitchDev",
      "id": "141981764",
      "login": "twitchdev",
      "offline_image_url": "",
      "profile_image_url": "",
      "type": "",
      "view_count": 6652509

Using cURL to get the information

If you use cURL, here’s the call you’d use to get the TwitchDev user’s information (remember to change the Authorization and Client-id header values to your own values).

curl -X GET '' \
-H 'Authorization: Bearer 2gbdx6oar67tqtcmt49t3wpcgycthx' \
-H 'Client-Id: wbmytr93xzw8zbg0p1izqyzzc5mbiz'

Next steps

Check out the CLI’s API usage documentation and then try out a few different endpoints and options.

For a list of the endpoints that you can call, see Twitch API Reference.

To understand Twitch API concepts, see Twitch API Guide.

To get into the nuts and bolts of authentication, see the Authentication guide. This guide explains how to enable your application to take actions on behalf of a Twitch account, or access specific data about a user’s account.

Join our community of Twitch developers! And for other ways to connect with the community, explore our developer support page.