Displaying available streams with a given tag

Hi, I’m new to developing with Twitch API.
I wanted to make a simple script for a website that would display current streams with a given tag. But unfortunately, each of my attempts ends with a 401 error in the console.
I have created my application at Twitch Developers, where I get Client ID and Client Secret. Some solution? If necessary, I will post the script I use.

This sounds like you tried to use your Client Secret as a token.

You need to use the ClientID and ClientSecret to generate a token to use to call the API.

For your described use case a Client Credentials token would be sufficent assuming the API calls are done on your backend

Could you help me get this token? I don’t understand anything from this documentation. I spent all night on this and it sucks

It’s just a single POST request

So the same way you did a HTTP Call to try and get streams and got a 401 you just need to do a HTTP Call to get a token instead

Here are three examples in three different languages for obtaining a Client Credentials/App Access Token: https://github.com/BarryCarlyon/twitch_misc/tree/main/authentication/app_access_tokens

do I need to download this token on the machine where my website is located?

Your website would generate a token to use, you wouldn’t “download this token” as the token will expire after around 60 days*

These code examples just demonstrate how to get a token to use for your API calls in server side code.

*there are other reasons a token can expire/be revoked

Okay, thank you very much. Works.
And how can I find out what tagid a given tag has?

tagid’s are no longer a thing

Streams are tagged using just words now.

For example https://api.twitch.tv/helix/streams?tag_id=RolePlay ?

tag_id isn’t a supported filter for this endpoint

So to filter by tags you’d have to Get Streams and filter in code instead

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.