# New to api, It's 4am. Let me wake up to some understanding

**URL:** <https://discuss.dev.twitch.com/t/new-to-api-its-4am-let-me-wake-up-to-some-understanding/27975>\
**Category:** API\
**Created:** [August 31, 2020, 7:51am UTC](https://discuss.dev.twitch.com/t/new-to-api-its-4am-let-me-wake-up-to-some-understanding/27975 "2020-08-31T07:51:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cody\_Eddingfield](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/cody_eddingfield/32/10118_2.png) [@Cody\_Eddingfield](https://discuss.dev.twitch.com/u/Cody_Eddingfield)\
**Post date:** [August 31, 2020, 7:51am UTC](https://discuss.dev.twitch.com/t/new-to-api-its-4am-let-me-wake-up-to-some-understanding/27975/1 "2020-08-31T07:51:21Z")

</div>

Um, I am new to api… Wanting to show if streamers on a stream team are live on my site or even just a individual streamer. Clearly just testing my own account atm. Using a website I currently have to test on.

Thinking I need to get a OAuth token, below is as far as I got…

“object(stdClass)#4 (3) { [“error”]=\> string(12) “Unauthorized” [“status”]=\> int(401) [“message”]=\> string(22) “OAuth token is missing” } lets see”

I mean I am game for really any kinda of PHP break down on how to get this done. Please be clear if I need to do something outside of PHP.

$ch = curl\_init(‘[https://api.twitch.tv/helix/streams?user\_login=](https://api.twitch.tv/helix/streams?user_login=)’);  
curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, 1);  
curl\_setopt($ch, CURLOPT\_HTTPHEADER, array(  
'Client-ID: ’  
));

$data = curl\_exec($ch);  
$info = curl\_getinfo($ch);  
curl\_close($ch);

if ($info[‘http\_code’] != “”) {  
$data = json\_decode($data);  
var\_dump($data);  
} else {  
echo 'Failed with ’ . $info[‘http\_code’];  
}  
die(“lets see”);

---

<div class="post-metadata">

**Author:** ![Cody\_Eddingfield](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/cody_eddingfield/32/10118_2.png) [@Cody\_Eddingfield](https://discuss.dev.twitch.com/u/Cody_Eddingfield)\
**Post date:** [August 31, 2020, 8:00am UTC](https://discuss.dev.twitch.com/t/new-to-api-its-4am-let-me-wake-up-to-some-understanding/27975/2 "2020-08-31T08:00:19Z")

</div>

Honestly even a ajax example would be awesome. Cause I could do a simple display if data eq …

---

<div class="post-metadata">

**Author:** ![Cody\_Eddingfield](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/cody_eddingfield/32/10118_2.png) [@Cody\_Eddingfield](https://discuss.dev.twitch.com/u/Cody_Eddingfield)\
**Post date:** [August 31, 2020, 8:25am UTC](https://discuss.dev.twitch.com/t/new-to-api-its-4am-let-me-wake-up-to-some-understanding/27975/3 "2020-08-31T08:25:11Z")

</div>

fetch(  
‘[https://api.twitch.tv/kraken/videos/SOMEID](https://api.twitch.tv/kraken/videos/SOMEID)’,  
{  
headers: {  
‘client-id’: ‘SOMECLIENTID’,  
‘accept’: ‘application/vnd.twitchtv.v5+json’  
}  
}  
)  
.then(resp =\> { return resp.json() })  
.then(resp =\> { console.log(resp) })  
.catch(err =\> { console.log(err) });

I’ve got this working, Just don’t know where to see if they are live. I get all their stream info just not data that screams this streamer is live to me.

---

<div class="post-metadata">

**Author:** ![Breci](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/breci/32/5635_2.png) [@Breci](https://discuss.dev.twitch.com/u/Breci)\
**Post date:** [August 31, 2020, 8:31am UTC](https://discuss.dev.twitch.com/t/new-to-api-its-4am-let-me-wake-up-to-some-understanding/27975/4 "2020-08-31T08:31:04Z")

</div>

If the stream info is present in the array, it means they are live, if they are not returned, they are not live.

---

<div class="post-metadata">

**Author:** ![Cody\_Eddingfield](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/cody_eddingfield/32/10118_2.png) [@Cody\_Eddingfield](https://discuss.dev.twitch.com/u/Cody_Eddingfield)\
**Post date:** [August 31, 2020, 8:44am UTC](https://discuss.dev.twitch.com/t/new-to-api-its-4am-let-me-wake-up-to-some-understanding/27975/6 "2020-08-31T08:44:24Z")

</div>

Thank you, atm I was trying to use [https://api.twitch.tv/kraken/channels](https://api.twitch.tv/kraken/channels) instead of [https://api.twitch.tv/kraken/streams](https://api.twitch.tv/kraken/streams).

---

<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:** [September 30, 2020, 8:49am UTC](https://discuss.dev.twitch.com/t/new-to-api-its-4am-let-me-wake-up-to-some-understanding/27975/7 "2020-09-30T08:49:48Z")

</div>

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