YouTube API - Get live streams by channelIds - youtube-api

How do you query multiple channels to see if they are streaming at that moment?
I tried to add multiple channelIds in this query:
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId={channels_seperated_by_comma_and_http_query}&eventType=live&type=video&key={my_key}
That only gives the result of the first key

You can use Channels:list, which returns a collection of more than one channel.
HTTP request
GET https://www.googleapis.com/youtube/v3/channels
From the parameter part, it will give you contentDetails part=contentDetails
Response
If successful, this method returns a response body with the following structure:
{
"kind": "youtube#channelListResponse",
"etag": etag,
"nextPageToken": string,
"prevPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
channel Resource
]
}
Based from Ibrahim Ulukaya, you can not add comma separated channels here. Either you can leave it blank to search all channels, or you can have a request per each channel and merge results. There is no multichannel search API.

Related

Youtube Reporting API returns video data but Youtube Data API does not for specific channel

I have this issue where a specific channel is not returning any videos on the Data-API (see response from API below):
{
"kind": "youtube#videoListResponse",
"etag": "YIUPVpqNjppyCWOZfL-19bLb7uk",
"items": [],
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 0
}
}
In the meanwhile I can see data on its videos on Reporting API, both for Combined A2 and Basic A2 report types, like below (anonymized):
date,channel_id,video_id,live_or_on_demand,subscribed_status,country_code,views,comments,likes,dislikes,shares,watch_time_minutes,average_view_duration_seconds,average_view_duration_percentage,annotation_impressions,annotation_clickable_impressions,annotation_clicks,annotation_click_through_rate,annotation_closable_impressions,annotation_closes,annotation_close_rate,card_teaser_impressions,card_teaser_clicks,card_teaser_click_rate,card_impressions,card_clicks,card_click_rate,subscribers_gained,subscribers_lost,videos_added_to_playlists,videos_removed_from_playlists,red_views,red_watch_time_minutes
20221018,CHANNEL_ID,VIDEO_ID,on_demand,not_subscribed,FR,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
The request done to Data API has the following parts specified: snippet,contentDetails,statistics,id,topicDetails (independent of parts the request yields an empty answer as well)
Channel ID: UCs5DLbzGZJ559lKPP2pEWCw
Playlist ID: UUs5DLbzGZJ559lKPP2pEWCw
Tried calling Data API with third party token, with channel's token, checked on Reporting API (there is data there but not on Data API).
I expected: that videos are listed in Data API's PlaylistItems.list edge.

How to get a simplified version of a Youtube subscriber count

So I am using the smiirl counter and was hoping to not have to try and scrub data after the fact instead just use google api directly... i got as far as this example below but it looks like it wont work for me if items and statistics are included, no attributes are identified for me to use in the smiirl interface...i literally can only have 1 line with subscribercount on it...is there a direct way to dig that deep?
currently getting
{
"items": [
{
"statistics": {
"subscriberCount": "3"
}
}
]
}
what i need
{
"subscriberCount": "3"
}
You appear to be using the Channels: list method.
The response returned by this method is
{
"kind": "youtube#channelListResponse",
"etag": etag,
"nextPageToken": string,
"prevPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
channel Resource
]
}
You can use the fields optional parameter to reduce the fields returned. which i suspect you are already doing something like this.
FieldMask used for response filtering. If empty, all fields should be returned unless documented otherwise.
fields = items(statistics(subscriberCount))
That is the best your going to be able to get. You can not change the format of a response from an api endpoint.
May i suggest creating a method on your end that when the data is returned reformat it locally

YouTube api returns empty results where video exists

Using the youtube API, I get no results for either channels list, search, ... for a channel where there is some content.
There is no error returned, just an empty set. No channels, no video, nothing either in the API explorer or through my code.
Everything was working correctly up until a few days/weeks (hard to tell when since I had no errors)
curl -v 'https://www.googleapis.com/youtube/v3/search?key=[api_key]&channelId=UCKTgGP9lrL5Yjs4f8WuI1Vw&part=snippet,id&order=date&maxResults=20'
is the query I used but I tried to get the uploads channel id as some answers here advised but the channels/list endpoint is empty too. I checked the documentation and I couldn't find anything wrong with my query.
This is the answer I currently get:
{
"kind": "youtube#searchListResponse",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/nrqzXB-_ht29Bt6u-f7_lLyFcCw\"",
"regionCode": "BE",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 20
},
"items": []
}
and you can see here https://www.youtube.com/channel/UCKTgGP9lrL5Yjs4f8WuI1Vw/videos that it's not empty.
Try to add type=video as param, it seems working :)

YouTube Data API channels list returning no results for valid Channel ID

I'm attempting to access https://www.youtube.com/channel/UC7LoiySz7-FcGgZCKBq_2vQ via the YouTube Data API v3 however am not able to load channel by id:
https://content.googleapis.com/youtube/v3/channels?part=snippet&id=UC7LoiySz7-FcGgZCKBq_2vQ&key=<omitted>
{
"kind": "youtube#channelListResponse",
"etag": "\"XI7nbFXulYBIpL0ayR_gDh3eu1k/Rk41fm-2TD0VG1yv0-bkUvcBi9s\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 0
},
"items": []
}
other channels that this same error occurs for:
https://www.youtube.com/channel/UCzwNZaQ2qyZw0n3xOSNoXaQ
https://www.youtube.com/channel/UC0iFwqagVPP6pXiDwYU170g
Your channels are of type hidden. This is the expected outcome. Unhide it and work your way from there.
Delete or hide your YouTube channel:
You can hide content from your YouTube channel and choose to re-enable
it later. When you hide content, your channel name, videos, likes,
subscriptions, and subscribers will be made private.
All your comments and replies will be permanently deleted. Your
account data on other Google properties will not be removed.
One more time YouTube Data API v3 doesn't provide a basic feature.
I recommend you to try out my open-source YouTube operational API. Indeed by fetching https://yt.lemnoslife.com/channels?part=status&id=CHANNEL_ID, you will get the YouTube channel status message you are looking for in item["status"].
For instance with this channel id UC7LoiySz7-FcGgZCKBq_2vQ you would get:
{
"kind": "youtube#channelListResponse",
"etag": "NotImplemented",
"items": [
{
"kind": "youtube#channel",
"etag": "NotImplemented",
"id": "UC7LoiySz7-FcGgZCKBq_2vQ",
"status": "This channel is not available."
}
]
}
For a suspended YouTube channel such as UCF_UozwQBJY4WHZ7yilYkjA, you would get for status: "This account has been terminated due to multiple or severe violations of YouTube's policy on nudity or sexual content.".
For a normal channel, such as UC4QobU6STFB0P71PMvOGN5A, you would get for status: null.

not getting result from youtube channel:list api

I am using youtube data api (GET https://www.googleapis.com/youtube/v3/channels?part=snippet&categoryId=GCQ29va2luZyAmIEhlYWx0aA&maxResults=5&key={YOUR_API_KEY}). but getting no channel list in response. tried for so many categoryId's from different regionCode.
response from youtube api - 200
{
"kind": "youtube#channelListResponse",
"etag": "Wu2llbfqCdxIVjGbVPm2DslKPCA/ewwRz0VbTYpp2EGbOkvZ5M_1mbo",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
}
Looks like you copy pasted the URI
GET https://www.googleapis.com/youtube/v3/channels
,attached an API_KEY then pasted it on your browser.
What I would recommend is use the Try-it for testing then use OAuth for authorization when actually coding the app. You can see several Quickstarts in the Youtube Guide.

Resources