Get information by channel name

So, there are a few web pages where you just type your channel name and it returns a LOT of info about your channel.

Reading the api doc, I could only find requests using user/channel ID.

How could we get info only by channel name?

Use the Get Users API to convert a login to an ID

Then use the ID with Get Channel Information

Streams API supports username or ID

1 Like

Thanks for the reply!!

That’s weird. One example is https://sullygnome.com/
I can just select any channel, no login required and I can get a bunch of analytics info.

Also. What I need in order to get a list of followers by channel name ?

I was generating the Access_Token, but I found your old response here and I got confused. So I need NO TOKEN at all?

I was generating token like (my own info from my dashboard):

async function getToken() {
    const clientId = ENV.CLIENT_ID
    const secret = ENV.SECRET
    const url = `https://id.twitch.tv/oauth2/token?client_id=${clientId}&client_secret=${secret}&grant_type=client_credentials`
  
    const { data } = await axios.post(url)
    console.log(data)
    return data
}

Reading get-users endpoint, I do need to pass as Authorization value.

Here I was trying to get user info

async function getData() {
  const url = "https://api.twitch.tv/helix/users?login=ghaleon_rlz"
  const { access_token } = await getToken()

  const data = await axios.get(url, {
    headers: { Authorization: `Bearer ${access_token}` }
  })

  return data
}

But it returns

 data: {
      error: 'Unauthorized',
      status: 401,
      message: 'Client ID and OAuth token do not match'
    }

Could you give me some light?

This website will use the API in the background and/or return data it already collected.

It collects information from public endpoints and draws it’s own conclusions.

First convert the channel name (aka login) to an ID

Then call Get Users Follows, this endpoint only supports ID’s

A token is required… The authentication requirements have changed since February 2020. This changed in (started to change in) April (and enforced in May) as per the announcmenet thread I linked to in the post you linked to.

You omitted the Client-ID header.

async function getData() {
  const url = "https://api.twitch.tv/helix/users?login=ghaleon_rlz"
  const { access_token } = await getToken()

  const data = await axios.get(url, {
    headers: { Authorization: `Bearer ${access_token}` }
  })

  return data
}

Should be

async function getData() {
  const url = "https://api.twitch.tv/helix/users?login=ghaleon_rlz"
  const { access_token } = await getToken()

  const data = await axios.get(url, {
    headers: {
        Authorization: `Bearer ${access_token}`,
        'Client-ID': ENV.CLIENT_ID
    }
  })

  return data
}
1 Like

Hello again, Barry!

Thank you so much for patience explaining this again. It’s working perfect!

I have 2 more dumb question though.

  1. Will I always use my own client-id in my requests? I mean, if I want to someone else make these requests, do they need to authenticate themselves?

  2. to use the pagination cursor i just need to send it inside header as a value for key after? like:

pagination: { cursor: "eyJiIjpudWxsLCJhIjp7IkN1cnNvciI6ImV5SjBjQ0k2SW5WelpYSTZORGd5TkRZeU5ERTVPbVp2Ykd4dmQzTWlMQ0owY3lJNkluVnpaWEk2TlRVM01qY3dORE1pTENKcGNDSTZJblZ6WlhJNk5UVTNNamN3TkRNNlptOXNiRzkzWldSZllua2lMQ0pwY3lJNklqRTJNRGt3T1RJd09EUTFNelE1TWpZNE5UTWlmUT09In19"}
  const { data } = await axios.get(url, {
    headers: {
      Authorization: `Bearer ${token}`,
      'Client-ID': clientId,
      'after': <cursor_value>
    }
  })

Thanks again!

The ClientID has to be that of which the oAuth token was generated with.

If you are using an App Access token, then the user visits your website, the front end tells the backend what to do and the backend runs with the existing access token.

I’m not sure who the someone else is in this scenario

No i’ts not a header, it’s a query string argument.

1 Like