How to fetch Twitch clip information using PHP and Twitch API

I’m having trouble retrieving information from a specific Twitch clip using PHP and the Twitch API. When I try to fetch clip data, I keep getting a 404 error response, even though my code works perfectly for other Twitch API endpoints like video data.

Here’s the code I’m using to fetch the clip details:

$clipEndpoint = 'https://api.twitch.tv/kraken/clips/username/FunnyAwesomeClipSlug123';
$appClientId = 'your_client_id_here';
$curl = curl_init();

curl_setopt_array($curl, array(
    CURLOPT_HTTPHEADER => array(
        'Client-ID: ' . $appClientId
    ),
    CURLOPT_SSL_VERIFYPEER => false,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_URL => $clipEndpoint
));

$result = curl_exec($curl);
curl_close($curl);

$data = json_decode($result, TRUE);

var_dump($data);

The weird thing is that when I use the same approach for fetching video information, everything works as expected:

$videoEndpoint = 'https://api.twitch.tv/kraken/videos/987654321';
// same curl configuration

What could be causing this 404 error specifically for clip data? Am I using the wrong API endpoint format or missing some required parameters?

You’re using the old Kraken API (v5) that Twitch killed off in February 2022. That’s why it’s not working anymore. Switch to the Helix API instead: https://api.twitch.tv/helix/clips with the clip ID as a query parameter like ?id=ClipSlugHere. You’ll need both your Client-ID and an OAuth token in the headers now - Helix requires proper auth for most stuff. I hit this same issue when updating an old project. Yeah, it’s annoying to migrate, but Helix is way more consistent once you’re used to it. Just check Twitch’s dev docs for the current auth requirements since they’ve gotten pickier about API access.