Determine if a user exists through the API?

I have an app that allows users to enter broadcaster usernames so they can pull up multiple streams at once, but if they enter it incorrectly it’ll just load a broken iframe of the stream and chat. Are there any ways to verify if a user exists when they’re not logged in to your application?

Make a request to https://api.twitch.tv/kraken/channels/user_to_test.

If the user exists, you’ll get a whack of data about them:

{
  "name": "user_to_test",
  "game": "Dark Souls II",
  "created_at": "2011-02-24T01:38:43Z",
  "title": "user_to_test",
  "updated_at": "2012-06-18T05:22:53Z",
  "banner": "http://static-cdn.jtvnw.net/jtv_user_pictures/user_to_test-channel_header_image-7d10ec1bfbef2988-640x125.png",
  "video_banner": "http://static-cdn.jtvnw.net/jtv_user_pictures/user_to_test-channel_offline_image-bdcb1260130fa0cb.png",
  "background": "http://static-cdn.jtvnw.net/jtv_user_pictures/user_to_test-channel_background_image-eebc4eabf0686bb9.png",
  "_links": {. . .},
  "logo": "http://static-cdn.jtvnw.net/jtv_user_pictures/user_to_test-profile_image-7243b004a2ec3720-300x300.png",
  "_id": 20694610,
  "mature": true,
  "url": "http://www.twitch.tv/user_to_test",
  "display_name": "user_to_test"
}

If the user doesn’t exist, you’ll get a 404:

{
  "error":"Not Found",
  "status":404,
  "message":"Channel 'user_to_test' does not exist"
}

The API endpoint can be found here.

I know I can use that to get the information of a user that’s already logged in, but I need to determine if the name they enter into a different field is an actual user. I won’t have access to the other user that they enter because they aren’t the one who logs in. Trying to make that request will just get me an Unauthorization error.

I guess for a better understanding you can try it out here.

Go to Add Stream at the top right and enter a user that doesn’t exist. It will still add that but nothing will actually work since that broadcaster never actually existed. I’m trying to catch this error beforehand rather than making the user have to go and remove the stream manually.

When the you add a stream, can you not use that text field data to first make a call to the api if it exists, and then create the iframe only if the stream exists? Why does a user need to be logged in for you to call the channel endpoint? It is not an authenticated request.

That’s what I figured. I’m gonna look over how I made the call. Thanks!