Create Clips
Explore how to create clips from currently live Twitch streams using the Twitch API. Learn to send authenticated POST requests with broadcaster IDs and handle response data for clip creation, including managing access tokens and verifying live status. Understand the key parameters and workflows to integrate clip creation into your Python projects effectively.
We'll cover the following...
We retrieve information regarding clips, but we can also use the Twitch API to create a clip from a currently ongoing live stream programmatically. To do so, we can send a simple POST request to the clips endpoint and pass the ID of a currently streaming channel.
All POST requests to create a clip must be authenticated with a user access token that has the clips:edit scope.
Input parameters
It requires a single query parameter, and another optional query parameter. The table below gives an overview of both parameters:
Parameter | Type | Category | Description |
| String | Required | This is the ID of the live channel whose ongoing live stream we want to clip. |
| Boolean | Optional | This indicates whether to wait for a short period before capturing the clip. If it is |
The ID that we pass in the broadcaster_id parameter must be a valid ID, and the corresponding user must be live when we make the request. If the broadcaster is not live, clip creation will fail.
Example call
Let's make a sample call to this endpoint. First, let's query the streams endpoint to retrieve a list of ongoing streams. Next, we’ll call the clips endpoint with the ID of a user that is currently live.
Note: The code below extracts a clip ID to be used later, so don't forget to save it. If your access token has expired, return to this lesson and follow the steps to generate a new one.
Let's make a GET request to the clips endpoint to retrieve the details of the clip we just created:
Note: Clip creation may take some time, so if you don't get the expected response from the following request, try running the code again after a few minutes. If your access token has expired, return to this lesson and follow the steps to generate a new one.
Response structure
The JSON response from a POST request to the clips endpoint when creating a clip has a single top-level property—data. This property contains an array of objects, with each object representing a clip that was just created. The table below discusses the properties of these objects:
Property | Type | Description |
| String | This is the ID of the clip. |
| String | This is the URL where the created clip can be edited. |