# Nube learning to play with apis

**URL:** <https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544>\
**Category:** API\
**Created:** [April 30, 2018, 7:14am UTC](https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544 "2018-04-30T07:14:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![888Owl](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/888owl/32/4494_2.png) [@888Owl](https://discuss.dev.twitch.com/u/888Owl)\
**Post date:** [April 30, 2018, 7:14am UTC](https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544/1 "2018-04-30T07:14:40Z")

</div>

i want to use this \*\* [https://api.twitch.tv/helix/streams\*\*](https://api.twitch.tv/helix/streams**) endpoint and i wasted about two days setting up authentication before re-re-reading about it and seeing no authentication required and was wondering for the endpoint the only authent i need is to put my id in the header of my ajax and i really don’t understand how to do that and was wondering if anyone had advice or could help,

i appreciate anything

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 30, 2018, 7:25am UTC](https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544/2 "2018-04-30T07:25:01Z")

</div>

You can refer to the example calls to the right of the docs here

> **[Reference](https://dev.twitch.tv/docs/api/reference/#get-streams)**
>
> Twitch Developer tools and services to integrate Twitch into your development or create interactive experience on twitch.tv.

Failing that provide the code you are using and we can see what needs to be fixed

---

<div class="post-metadata">

**Author:** ![888Owl](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/888owl/32/4494_2.png) [@888Owl](https://discuss.dev.twitch.com/u/888Owl)\
**Post date:** [April 30, 2018, 7:39am UTC](https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544/3 "2018-04-30T07:39:39Z")

</div>

thank you for that,  
i dont really know how to use curl, so i have been using ajax which i am sort of comfortable with for this purpose…  
and im pretty sure it needs my client id and my secret which i tried using the ajax built in methods{username:name, password:password} would that not be the right way to go?

ill post up my code in just a second

---

<div class="post-metadata">

**Author:** ![888Owl](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/888owl/32/4494_2.png) [@888Owl](https://discuss.dev.twitch.com/u/888Owl)\
**Post date:** [April 30, 2018, 7:43am UTC](https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544/4 "2018-04-30T07:43:34Z")

</div>

```
$(document).ready(function(){

```

//make sure jquery library is working  
$(“p”).append(“hello world”);  
//declare stream array  
var twitchers=[“dmbrandon”,“MedryBW”,“ESL\_SC2”, “OgamingSC2”, “cretetion”, “freecodecamp”, “storbeck”, “habathcx”, “RobotCaleb”, “noobs2ninjas”];  
//declare endpoint  
var endPoint=“[https://api.twitch.tv/helix/streams?user\_id=](https://api.twitch.tv/helix/streams?user_id=)”+twitchers;  
//declare get method

$.ajax({  
//headers:"user-id: **my-twitch-id**",  
url:endPoint,  
dataType: ‘json’,  
async:false,  
type:‘GET’,  
username:“ **my-twitch-id** ”,  
password:“ **my-twitch-secret** ”,  
success: function(data){  
console.log(data);  
},  
error:function(error){  
console.log("Your ERROR is: "+ error);  
}  
});

});

---

<div class="post-metadata">

**Author:** ![3ventic](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/3ventic/32/298_2.png) [@3ventic](https://discuss.dev.twitch.com/u/3ventic)\
**Post date:** [April 30, 2018, 12:50pm UTC](https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544/5 "2018-04-30T12:50:42Z")

</div>

Your `twitchers` contains `user_login`s, not `user_id`s.

The **secret** is only needed in the authorization flow (hitting [id.twitch.tv](http://id.twitch.tv)), and _only in code running on a server, **never** in a browser_.

Using ajax, the client-id header is sent as

```auto
headers: { 'client-id': your_client_id }

```

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [April 30, 2018, 1:15pm UTC](https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544/6 "2018-04-30T13:15:45Z")

</div>

```
var twitchers=[“dmbrandon”,“MedryBW”,“ESL_SC2”, “OgamingSC2”, “cretetion”, “freecodecamp”, “storbeck”, “habathcx”, “RobotCaleb”, “noobs2ninjas”];
//declare endpoint
var endPoint=“https://api.twitch.tv/helix/streams?user_id=”+twitchers;

```

should/could be

```
var twitchers=[“dmbrandon”,“MedryBW”,“ESL_SC2”, “OgamingSC2”, “cretetion”, “freecodecamp”, “storbeck”, “habathcx”, “RobotCaleb”, “noobs2ninjas”];
//declare endpoint
var endPoint="https://api.twitch.tv/helix/streams?user_login="+twitchers.join('&user_login=');

```

As you just pass multiple `user_login` to the end point

```
https://api.twitch.tv/helix/streams?user_login=foo&user_login=bar

```

It’s not a CSV/object

(don’t direct copy paste the " got trashed)

---

<div class="post-metadata">

**Author:** ![888Owl](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/888owl/32/4494_2.png) [@888Owl](https://discuss.dev.twitch.com/u/888Owl)\
**Post date:** [May 1, 2018, 12:23am UTC](https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544/7 "2018-05-01T00:23:04Z")

</div>

![progress_capture](https://d2opxh93rbxzdn.cloudfront.net/original/2X/c/c127bc32dcef3df51504c8bc17d23b765f1ba13c.PNG)  
thank you both so much! its now displaying all live streamers so i can start building it from there!

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [May 31, 2018, 12:23am UTC](https://discuss.dev.twitch.com/t/nube-learning-to-play-with-apis/15544/8 "2018-05-31T00:23:06Z")

</div>

Closed on May 31, 2018, 12:23am UTC

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