Creates a clip of the last 30–60 seconds of a live Twitch stream via the Twitch Clips API. Includes a 30-second cooldown to prevent accidental spam clipping.
http://localhost, Category: Other)Visit this URL in your browser (replace YOUR_CLIENT_ID):
text
https://id.twitch.tv/oauth2/authorize?client_id=YOUR_CLIENT_ID&redirect_uri=http://localhost&response_type=token&scope=clips:edit
Copy the access_token from the redirect URL.
bash
export TWITCH_CLIENT_ID="your_client_id"
export TWITCH_ACCESS_TOKEN="your_access_token"
export TWITCH_BROADCASTER_ID="your_broadcaster_id" # numeric user ID
To find your broadcaster ID:
bash
curl -s -H "Authorization: Bearer $TWITCH_ACCESS_TOKEN" \
-H "Client-Id: $TWITCH_CLIENT_ID" \
https://api.twitch.tv/helix/users | python3 -c "import json,sys; print(json.load(sys.stdin)['data'][0]['id'])"
Run the clip script:
bash
bash scripts/create_clip.sh [duration_seconds]
A 30-second cooldown is enforced between clips. If a clip request comes in during cooldown:
⏳ Cooldown active — try again in XsSuccess: Clipped! 🎬 https://clips.twitch.tv/<clip_id>
Cooldown active: ⏳ Cooldown active — try again in Xs
Not live: Stream is offline — can't clip right now
Tokens expire. If you get a 401 error, re-authorize using the URL in Setup step 2.