-
-
Save QuincyLarson/2ff6892f948d0b7118a99264fd9c1ce8 to your computer and use it in GitHub Desktop.
[ | |
{ | |
"stream": { | |
"mature": false, | |
"status": "Greg working on Electron-Vue boilerplate w/ Akira #programming #vuejs #electron", | |
"broadcaster_language": "en", | |
"display_name": "FreeCodeCamp", | |
"game": "Creative", | |
"language": "en", | |
"_id": 79776140, | |
"name": "freecodecamp", | |
"created_at": "2015-01-14T03:36:47Z", | |
"updated_at": "2016-09-17T05:00:52Z", | |
"delay": null, | |
"logo": "https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-profile_image-d9514f2df0962329-300x300.png", | |
"banner": null, | |
"video_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-channel_offline_image-b8e133c78cd51cb0-1920x1080.png", | |
"background": null, | |
"profile_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-profile_banner-6f5e3445ff474aec-480.png", | |
"profile_banner_background_color": null, | |
"partner": false, | |
"url": "https://www.twitch.tv/freecodecamp", | |
"views": 161989, | |
"followers": 10048, | |
"_links": { | |
"self": "https://api.twitch.tv/kraken/channels/freecodecamp", | |
"follows": "https://api.twitch.tv/kraken/channels/freecodecamp/follows", | |
"commercial": "https://api.twitch.tv/kraken/channels/freecodecamp/commercial", | |
"stream_key": "https://api.twitch.tv/kraken/channels/freecodecamp/stream_key", | |
"chat": "https://api.twitch.tv/kraken/chat/freecodecamp", | |
"subscriptions": "https://api.twitch.tv/kraken/channels/freecodecamp/subscriptions", | |
"editors": "https://api.twitch.tv/kraken/channels/freecodecamp/editors", | |
"teams": "https://api.twitch.tv/kraken/channels/freecodecamp/teams", | |
"videos": "https://api.twitch.tv/kraken/channels/freecodecamp/videos" | |
} | |
}, | |
"_links": { | |
"self": "https://api.twitch.tv/kraken/streams/freecodecamp", | |
"channel": "https://api.twitch.tv/kraken/channels/freecodecamp" | |
} | |
}, | |
{ | |
"stream": null, | |
"display_name": "OgamingSC2", | |
"_links": { | |
"self": "https://api.twitch.tv/kraken/streams/ogamingsc2", | |
"channel": "https://api.twitch.tv/kraken/channels/ogamingsc2" | |
} | |
}, | |
{ | |
"stream": { | |
"mature": false, | |
"status": "RERUN: StarCraft 2 - Kane vs. HuK (ZvP) - WCS Season 3 Challenger AM - Match 4", | |
"broadcaster_language": "en", | |
"display_name": "ESL_SC2", | |
"game": "StarCraft II", | |
"language": "en", | |
"_id": 30220059, | |
"name": "esl_sc2", | |
"created_at": "2012-05-02T09:59:20Z", | |
"updated_at": "2016-09-17T06:02:57Z", | |
"delay": null, | |
"logo": "https://static-cdn.jtvnw.net/jtv_user_pictures/esl_sc2-profile_image-d6db9488cec97125-300x300.jpeg", | |
"banner": null, | |
"video_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/esl_sc2-channel_offline_image-5a8657f8393c9d85-1920x1080.jpeg", | |
"background": null, | |
"profile_banner": "https://static-cdn.jtvnw.net/jtv_user_pictures/esl_sc2-profile_banner-f8295b33d1846e75-480.jpeg", | |
"profile_banner_background_color": "#050506", | |
"partner": true, | |
"url": "https://www.twitch.tv/esl_sc2", | |
"views": 60843789, | |
"followers": 135275, | |
"_links": { | |
"self": "https://api.twitch.tv/kraken/channels/esl_sc2", | |
"follows": "https://api.twitch.tv/kraken/channels/esl_sc2/follows", | |
"commercial": "https://api.twitch.tv/kraken/channels/esl_sc2/commercial", | |
"stream_key": "https://api.twitch.tv/kraken/channels/esl_sc2/stream_key", | |
"chat": "https://api.twitch.tv/kraken/chat/esl_sc2", | |
"subscriptions": "https://api.twitch.tv/kraken/channels/esl_sc2/subscriptions", | |
"editors": "https://api.twitch.tv/kraken/channels/esl_sc2/editors", | |
"teams": "https://api.twitch.tv/kraken/channels/esl_sc2/teams", | |
"videos": "https://api.twitch.tv/kraken/channels/esl_sc2/videos" | |
} | |
}, | |
"_links": { | |
"self": "https://api.twitch.tv/kraken/streams/esl_sc2", | |
"channel": "https://api.twitch.tv/kraken/channels/esl_sc2" | |
} | |
}, | |
{ | |
"stream": null, | |
"display_name": "noobs2ninjas", | |
"_links": { | |
"self": "https://api.twitch.tv/kraken/streams/esl_sc2", | |
"channel": "https://api.twitch.tv/kraken/channels/esl_sc2" | |
} | |
}, | |
{ | |
"error": "Not Found", | |
"status": 404, | |
"message": "Channel 'not-a-valid-account' does not exist" | |
} | |
] |
I've updated this gist based on work by @jonataswalker. This should now mimic the current way that Twitch's API responds.
I have no problem getting data from the regular twitchtv API using my Client-ID (which are free, public, and thus can be shared; it says so when you create them). My problem is that codepen's sandboxed iframe environment will not correctly open twitchtv links (a page opens to the correct url, but it's black; won't load. Cut-n-past the url into another tab, and it works fine.)! You get wonderful errors in the console telling you so. Setting target="_blank" doesn't work, either. My project works great in my Cloud9 workspace! Just not codepen. Any thoughts on moving FCC projects to Cloud9? :)
I have the same problem as benjaminboruff's. The twitchtv link opens a black page and doesn't load.
It's a problem in Chrome and with a left-click on a mouse or tapping on screen. However it works with right-click; and works on Microsoft Edge (also left-click), for me it works on Android 7 too. So it seems to be a Chrome-related problem.
The original Gist only has two channels: FreeCodeCamp and ESL_SC2. This makes the projeIt is not enough options to fulfill the given task, have an option to alternate between online, offline and search options.
@carpben if I read your reply correctly, as far as I can see here you got enough options. Streams that have the "stream" property value of null are offline and streams that return a lot of data inside the "stream" property are online therefore giving you enough options to complete the task.
EDIT: My mistake, I looked at some wrong data. Yeah the original gist lacks offline channels, but offline channels have been added later so that the task could be completed.
how do i use this array. I am a beginner, Kindly help me . Thank you
@Ruchika30...this data is the one which is supposed to come as a successful response of our request to twitch. So, instead of using "GET" method and fetching response, we can directly store this entire thing in a variable.
If you didn't get the above part, just skip to next line.
Like var someVar = ENTIRE_ARRAY_GIVEN_HERE
. Then just use someVar[0]["XYZ"]
like that to access the contents of this entire array thing. Here you will need 'logo','status' and 'display_name' parameters of a stream.
By the looks of it, with the exception of the "not found" item, they're live stream channel data (not full stream data, which would indicate online/offline status). See: https://github.com/justintv/Twitch-API/blob/master/v3_resources/streams.md#get-streamschannel