Skip to content

How to get Twitch clips and their view counts with an API

Updated · 2 steps

Clips are the short, shareable moments of a Twitch stream, and their view counts show what an audience actually rewatches. Fetchproof returns a channel's public clips and any single clip's details, for highlight reels, creator analytics or clip-sharing tools.

01

List a channel's clips

Pass the channel login. Each clip has its id, slug, title, viewCount, url, createdAt and durationSeconds. Send the returned cursor to get the next page.

GET /v1/twitch/user/clips 1 credit per call

cURL

curl --request GET 'https://api.fetchproof.com/v1/twitch/user/clips?handle=nasa' \
  --header 'x-api-key: YOUR_API_KEY'

JavaScript

const response = await fetch("https://api.fetchproof.com/v1/twitch/user/clips?handle=nasa", {
  method: 'GET',
  headers: {
    'x-api-key': process.env.FETCHPROOF_API_KEY,
  },
});
const data = await response.json();
console.log(data);

Python

import os
import requests

response = requests.get(
    "https://api.fetchproof.com/v1/twitch/user/clips?handle=nasa",
    headers={"x-api-key": os.environ["FETCHPROOF_API_KEY"]},
)
print(response.json())

Go

package main

import (
  "fmt"
  "io"
  "net/http"
  "os"
)

func main() {
  req, _ := http.NewRequest("GET", "https://api.fetchproof.com/v1/twitch/user/clips?handle=nasa", nil)
  req.Header.Set("x-api-key", os.Getenv("FETCHPROOF_API_KEY"))
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}

PHP

<?php
$ch = curl_init("https://api.fetchproof.com/v1/twitch/user/clips?handle=nasa");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    'x-api-key: ' . getenv('FETCHPROOF_API_KEY'),
  ],
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Excerpt of published sample response Full response →
{
  "success": true,
  "credits_remaining": 100,
  "credits_charged": 1,
  "clips": [
    {
      "id": "2870106419",
      "slug": "IronicGrotesqueCaribouDxAbomb",
      "title": "Left SD card at home LUL",
      "viewCount": 352094,
      "url": "https://www.twitch.tv/nasa/clip/IronicGrotesqueCaribouDxAbomb",
      "createdAt": "2018-05-16T12:40:12Z",
      "durationSeconds": 42
    }
  ],
  "cursor": "MjA="
}
02

Get one clip's details

Pass a clip URL to get the clip's title, viewCount, language, embedURL and its video assets with thumbnail and quality options.

This response is a bare JSON array with no envelope. The credits charged and remaining are in the fetchproof-credits-charged and fetchproof-credits-remaining response headers.

GET /v1/twitch/clip 1 credit per call

cURL

curl --request GET 'https://api.fetchproof.com/v1/twitch/clip?url=https%3A%2F%2Fwww.twitch.tv%2Fnasa%2Fclip%2FIronicGrotesqueCaribouDxAbomb' \
  --header 'x-api-key: YOUR_API_KEY'

JavaScript

const response = await fetch("https://api.fetchproof.com/v1/twitch/clip?url=https%3A%2F%2Fwww.twitch.tv%2Fnasa%2Fclip%2FIronicGrotesqueCaribouDxAbomb", {
  method: 'GET',
  headers: {
    'x-api-key': process.env.FETCHPROOF_API_KEY,
  },
});
const data = await response.json();
console.log(data);

Python

import os
import requests

response = requests.get(
    "https://api.fetchproof.com/v1/twitch/clip?url=https%3A%2F%2Fwww.twitch.tv%2Fnasa%2Fclip%2FIronicGrotesqueCaribouDxAbomb",
    headers={"x-api-key": os.environ["FETCHPROOF_API_KEY"]},
)
print(response.json())

Go

package main

import (
  "fmt"
  "io"
  "net/http"
  "os"
)

func main() {
  req, _ := http.NewRequest("GET", "https://api.fetchproof.com/v1/twitch/clip?url=https%3A%2F%2Fwww.twitch.tv%2Fnasa%2Fclip%2FIronicGrotesqueCaribouDxAbomb", nil)
  req.Header.Set("x-api-key", os.Getenv("FETCHPROOF_API_KEY"))
  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}

PHP

<?php
$ch = curl_init("https://api.fetchproof.com/v1/twitch/clip?url=https%3A%2F%2Fwww.twitch.tv%2Fnasa%2Fclip%2FIronicGrotesqueCaribouDxAbomb");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => [
    'x-api-key: ' . getenv('FETCHPROOF_API_KEY'),
  ],
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Excerpt of published sample response Full response →
[
  {
    "data": {
      "clip": "{…}"
    },
    "extensions": {
      "durationMilliseconds": 86,
      "operationName": "Clip",
      "requestID": "01M7K9CKVVKEZVPSCE1C12JBXM"
    }
  }
]

What it costs

Each call costs 1 credit. A page with no clips costs 0, and cache_max_age serves a recent cached copy for 0 credits.

Limits

Only public clips are returned. For a channel's past broadcasts, use the user videos endpoint, and for its stream schedule, the user schedule endpoint.

Try it with 100 free credits

Sign up with an email address, no card. Credits never expire. Errors cost 0 credits, and each endpoint page lists exactly what it charges.