I am able to get the list of live stream: https://developers.google.com/youtube/v3/live/docs/liveStreams/list#examples But how to get the live stream status and live stream link or id for particular channel using youtube v3 api in android?
-
did you get any ANS? – Hamza Jan 29 '17 at 10:26
-
No ANS if you get any plz share it. – YLS Jan 30 '17 at 07:15
-
i am also looking for this. but what about scrap the youtube channel and get the url of live stream ? – Hamza Jan 30 '17 at 18:22
-
1Still no answers? Did you found a solution? I need also need to get the live stream videos available from a channel id. – hsantos May 02 '17 at 14:55
-
@hsantos I have added an answer for the same, if you are still looking for a solution. – Harikrishnan Jul 03 '17 at 17:14
-
@AmeerHamza have added a solution – Harikrishnan Jul 03 '17 at 17:15
-
thank man i already have done this, – Hamza Jul 03 '17 at 22:12
-
@AmeerHamza can you post the answer or any link here so that it will be useful for all – YLS Jul 04 '17 at 07:39
-
ok i add the code – Hamza Jul 04 '17 at 07:41
-
you can now check @YLS i added the code – Hamza Jul 04 '17 at 08:05
2 Answers
I have faced the same problem and managed to figure out a solution for the same. YouTube actually provides an API for this purpose. You can use the search API to get the currently active Live Video ID, if you have the channel ID.
Use the following API:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={YOUR_CHANNEL_ID}&eventType=live&type=video&key={YOUR_API_KEY}
The key factor here is you have to set the eventType
to live
and type
to video
.
For getting the channel ID, you can use the following request, if you have the channel's username.
https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername={CHANNEL_USER_NAME}&key={YOUR_API_KEY}

- 7,765
- 13
- 62
- 113
-
2This only works for PUBLIC livestreams. Does not work for UNLISTED or PRIVATE livestreams. – jsherk Nov 20 '17 at 00:08
-
My live streaming is PUBLIC and LISTED but still no results on api request https://prnt.sc/p8qce3 – Gaston Coroleu Sep 20 '19 at 14:01
-
@GastonCoroleu I'm having a similar issue. I was using the above code snippet for a while until it stopped working about a week ago. Not too sure as to why – SteppingHat Sep 23 '19 at 01:42
-
@GastonCorole Please verify if there is any limit exceeding issue. I just tried after seeing these comments, it is still working for me. Checked the API documentation, there is no change there as well. – Harikrishnan Oct 01 '19 at 15:21
-
-
@Harikrishnan Usage limits were the first thing I checked. I was always way under the quota as I make a maximum of 5 calls a day due to a rate limiting/caching layer. To further troubleshooting I also created a new property on another account and ran the same query with the same result on the main property. However it seems to be working again for some odd reason as of a few days ago. Not too sure what was going on there – SteppingHat Oct 02 '19 at 04:43
-
I confirm, this api call hasn't been working in September 2019. Now it works, yay! – Ivan Oct 02 '19 at 19:31
-
-
Im trying to get all live streams for this channel but it returns no resuls https://www.youtube.com/channel/UCXzGWycANrrfyBmzX6JMsvQ/live – Kay Aug 03 '20 at 08:48
This will return live stream ID
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={CHANNEL_ID}&eventType=live&type=video&key={YOUR_API_KEY}
You can also pass Query to YouTube so YouTube give you all live stream events
https://www.googleapis.com/youtube/v3/search?part=snippet&q={YOUR_SEARCH_QuERY}&eventType=live&type=video&key={YOUR_YOUTUBE_API}
This how i get live stream videos in my app
private void initVolley(String[] urls) {
for (String url : urls) {
if (url.startsWith("https://www.googleapis.com/youtube/v3/")) {
jsonObjectRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray jsonArray = response.getJSONArray("items");
if (jsonArray.length() > 0) {
for (int getItem = 0; getItem < jsonArray.length(); getItem++) {
JSONObject jsonObject = jsonArray.getJSONObject(getItem).getJSONObject("id");
String videoID = jsonObject.getString("videoId");
Log.d(TAG, "void id " + videoID);
mUrlList.add(new video(jsonArray.getJSONObject(getItem).getJSONObject("snippet").getString("title"), jsonArray.getJSONObject(getItem).getJSONObject("snippet").getJSONObject("thumbnails").getJSONObject("medium").getString("url"), " ", "https://www.youtube.com/watch?v=" + videoID, true));
if (mAdapter != null)
mAdapter.notifyDataSetChanged();
Log.d(TAG, videoID + jsonArray.length() + jsonArray.getJSONObject(getItem).getJSONObject("snippet").getJSONObject("thumbnails").getJSONObject("default").getString("url"));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue.add(jsonObjectRequest);
}
}
}
And if you have YouTube links maybe you store your in database then this will return you some usefull info with out API key
https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=lUOhCtXPN40&format=json
and below code for this
JsonObjectRequest obreq = new JsonObjectRequest(Request.Method.GET, JsonURL, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
// mVideo = new video(response.getString("title"), response.getString("thumbnail_url"), response.getString("author_name"));
// mVideoDataSet.add(mVideo);
mVideo = new video(url);
mVideo.setVideoTitle(response.getString("title"));
mVideo.setVideoThimailUrl(response.getString("thumbnail_url"));
mVideo.setVideoChannalName(response.getString("author_name"));
mVideo.setLiveNow(false);
mVideoDataSet.add( mVideo);
Log.d(TAG, "inside the volly" + mVideo.getVideoTitle());
// Log.d(TAG, mVideoDataSet.get(i).getVideoStreemUrl());
if (mAdapter != null) {
mAdapter.notifyDataSetChanged();
// if(mSwipeRefreshLayout.isRefreshing())
// mSwipeRefreshLayout.setRefreshing(false);
} else {
Log.d(TAG, "setingAdupter");
// if(mSwipeRefreshLayout.isRefreshing())
// mSwipeRefreshLayout.setRefreshing(false);
mAdapter = new CustomAdapter(mVideoDataSet);
mRecyclerView.setAdapter(mAdapter);
}
i++;
if (i != mUrlList.size())
initVolly();
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// if(error)
i++;
initVolly();
Log.e("Volley", "Error");
}
}
);
// Adds the JSON object request "obreq" to the request queue
requestQueue.add(obreq);
and last if you want to see source code here is link

- 2,017
- 1
- 19
- 40
-
This only works for PUBLIC livestreams. Does not work for UNLISTED or PRIVATE livestreams. – jsherk Nov 20 '17 at 00:09
-