Hello everyone! I am making a twitch bot that would change the title and/or game of my streams. I have been following the documentation and some threads already here and have gotten all the way up to getting an access token. However, the issue now lies with making a request and actually changing the title by using the following code:
channelEDIT_url = “https://api.twitch.tv/kraken/channels/” + “MY_CHANNEL_NAME”
headers =
{
‘Accept’: ‘application/vnd.twitchtv.v5+json’,
“Client-ID”: “MY_BOTS_CLIENT_ID”,
“client_secret” : “MY_BOTS_CLIENT_SECRET”,
“Authorization”: "OAuth " + (access token from https://id.twitch.tv/oauth2/authorize),
“Content-Type”: “application/json”,
“scope” : “channel_editor”
}
data = {“channel[status]”: “NEW TITLE”}
response = requests.post(url=channelEDIT_url, headers=headers, params=data)
The code doesn’t crash at least lol, but it still does not change the title of my stream or do anything… Would anybody know any fixes? Thank you for your time!
URL: https://api.twitch.tv/helix/channels?broadcaster_id=YOURID (not the username)
Method: PATCH
Headers: Authorization is prefixed with Bearer not OAuth
Payload: updated to match documented
It didn’t seem to work am I missing something? here is the code now:
channelEDIT_url = “https://api.twitch.tv/helix/channels?broadcaster_id=” + “CHANNEL_ID_NUMERIC”
data =
{
“Client-ID”: “BOT_CLIENT_ID”,
“Authorization”: "Bearer " + ACCESS_TOKEN,
“Content-Type”: “application/json”,
“title” : “TEST TITLE”
}
response = requests.patch(channelEDIT_url, json=data)
I figured out the issue, the PATCH request helped me figure out it was the wrong type of access token i am running a bot of my laptop not a server so i had a different type of access code ran and it solved it thanks so much for your help!