Contents

Getting Started with the New Twitch API

Introduction

The New Twitch API provides tools for developing integrations with Twitch. Here, as a quick example to get you started, we make a basic request to get the top streams for a specific game, using the Get Streams endpoint.

Step 1: Setup

To make API calls, you need a client ID. To receive one, log into the Twitch developer dashboard (aka console), select the Apps tab, and click Register Your Application. Enter an app name and your OAuth redirect URI (where your users are redirected after being authorized), and select an app category. Click Create, and the app is created and listed on the dashboard as one of your registered apps. Click Manage to see the client ID.

Step 2: Sample Code

This gets information about the most active streams for game ID 33214.

curl -H 'Client-ID: p0gch4mp101fy451do9uod1s1x9i4a' \
-X GET 'https://api.twitch.tv/helix/streams?game_id=33214'

The example uses a dummy client ID. To try it out, copy and paste the example into your terminal, replacing the dummy client ID with your client ID.

Step 3: Results

The API returns an array of stream objects, along with a cursor for pagination. By default, this endpoint returns the 20 most active streams. For brevity, we truncate the long response here:

{
  "data": [
    {
      "id": "28623425344",
      "user_id": "150573462",
      "game_id": "488191",
      "community_ids": [
        "848d95be-90b3-44a5-b143-6e373754c382",
        "8deb7b0f-d5a3-4f9d-942d-2331d8f4fe3d",
        "ff1e77af-551d-4993-945c-f8ceaa2a2829"
      ],
      "type": "live",
      "title": "CHILL // PSYCHEDELIA :: ambience \u0026 tones  [ !visuals ]",
      "viewer_count": 9001,
      "started_at": "2018-05-08T18:47:34Z",
      "language": "en",
      "thumbnail_url": "https://static-cdn.jtvnw.net/previews-ttv/live_user_amorelandra-{width}x{height}.jpg"
    }
    ...
  ],
  "pagination": {
    "cursor": "eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6MX19"
  }
}

For descriptions of the response fields, see Get Streams.

What’s Next

For complete information on the API (including webhooks), see:

See the Apps & Authentication Guide for information about using Twitch Authentication, which enables your application to take actions on behalf of a Twitch account or access certain data about a user’s account. Twitch supports OAuth 2.0 and OIDC.

Stop by our Developer Forums to join our community of Twitch developers.