Why is the Youtube API not displaying results for video IDs? - youtube-api

I'm new to basically all forms of programming, so forgive me if there's an obvious answer, but I was just trying to make a random video chooser by randomly adding characters to the Youtube API's search function under list, but when I run the API with either just id or id and snippet on, it shows this:
{
"kind": "youtube#searchListResponse",
"etag": "\"i don't know if I can post my etag"",
"regionCode": "CA",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 50
},
"items": [
]
}
.

Its hard to know exactly what you have searched on but by the looks of the result there is just no results for your request. YOu might want to try playing with the api here search.list
When you run it click Execute without OAuth not the authorize and execute button. It will return a random list of videos.
You can use the q parameter to do a text search on videos for example that like toys.

Related

Why does YouTube Data API search often find 0 results while a normal YouTube website search yields many results?

We are using YouTube Data API to show product review videos on product pages of our price comparison website. We basically grab a product title and append "review" to it. The problem is that very often we do not get any results from the API, while a normal YouTube website search yields many results.
For example, the following request, when searching for "Reiskussen Intex Downy Opblaasbaar Blauw review" (using the Try this API form in the docs) does not give us any results:
https://www.googleapis.com/youtube/v3/search?part=snippet&q=Reiskussen%20Intex%20Downy%20Opblaasbaar%20Blauw%20review&key=[YOUR_API_KEY]
This is the JSON response:
{
"kind": "youtube#searchListResponse",
"etag": "z1qySaHHjn5TA8Vggil4LrmXKdc",
"regionCode": "NL",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": []
}
When we search on Youtube, we get several (relevant) results:
Why does the YouTube website find results and our API call does not? Is there any way to have the API find the same results or any result at all?

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 :)

Retrieve the subscribers id who watched video

Overall Goal: To report possible subscribers who are not active on my YouTube channel.
I'm reading through the YouTube Data API (v3) trying to understand how to retrieve the actual ids who watched a specific video. I know you can get the number of views, but I don't see any call/response that shows you the subscriber ids. Has anyone done this?
So far what I gathered from the docs and Google searching is that this was possible using the Watch History of a subscriber, but that's been deprecated.
Thanks in advance!
So I do not believe it's possible to get IDs of users who have watched certain videos but I have a workaround for my use case; reporting inactive subscribers. This is not the best but it'll get me somewhere.
YouTube's API is very limiting now, but by calling the Subscriptions API
https://www.googleapis.com/youtube/v3/subscriptions?part=snippet%2CcontentDetails&mySubscribers=true&key=[YOUR_API_KEY]
I am able to get all subscribers with their channel IDs. Then after saving their IDs, I can check each one's statistics by making this call:
https://www.googleapis.com/youtube/v3/channels?part=statistics&id=[SUB_ID]&key=[YOUR_API_KEY]
which I receive a response like this:
{
"kind": "youtube#channelListResponse",
"etag": "\"j6xRRd8dTPVVptg711_CSPADRfg/AZpZT_vQrY3UTi57ia_QqrKdc8c\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"something\"",
"id": "[SUB_ID]",
"statistics": {
"viewCount": "0",
"commentCount": "0",
"subscriberCount": "1",
"hiddenSubscriberCount": false,
"videoCount": "0"
}
}
]
}
Using this response (see "statistics"), I am making a generalization that if the subscriber has no comments AND no videos, then it's a safe bet that they are not active.

How can I figure the youtube video out whether it is private or not existed?

When I use video.list with API_KEY (not authenticated with OAuth) for a private or not existed (maybe deleted or invalid video id) video, I can't know status of the video at all. It just only gives empty items.
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&id=foo&key={API_KEY}
{
"kind": "youtube#videoListResponse",
"etag": "\"q5k97EMVGxODeKcDgp8gnMu79wM/Rk41fm-2TD0VG1yv0-bkUvcBi9s\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 0
},
"items": [
]
}
The document is telling me if I can't find video resource, you will get an error. But, it doesn't happen to me whatever id is. I've found out the solution in similar situation for Playlist case before, it was possible to catch the information to use playlistItem.list indirectly. However, in this situation, how can I find out the status?
Tried it out myself. Returned with a response status of 200, message null and an empty JSON item object too. It's weird that this is handled for playlistitems.list but not for video.list. Google Developers might have missed out on handling these kinds of scenarios for video.list. Guess there's really no way of telling if a video is private or if it even did exist at all using the Youtube Data API.
What I thought of is to try to make requests directly to the Youtube URL using the url
https://www.youtube.com/watch?v=<id>
then just check at the contents of <div class =”content”>
You can try to do this by using XPath or any similar XML traversing tools.

Youtube Data API v3 playlistitems endpoint returning empty items array

I'm using the playlistItems endpoint to get a list of videos that have been uploaded by an account. The response shows 1 as totalResults, which is expected, but the items array is empty, which is not. It's not clear to me what's going on, since the video is public and has views on it.
I'm not seeing this issue pulling uploads from other accounts, so I'm wondering if it's a caching issue on the YT side, or some setting we need to enable on our account? I'm not able to find any documentation that would explain what's happening here.
The endpoint I'm hitting is https://www.googleapis.com/youtube/v3/playlistItems?key=<api key>&playlistId=UUjQYaIbYceXNNdC63dQ9aTg&maxResults=10&part=snippet, and the full response I'm receiving is:
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"PSjn-HSKiX6orvNhGZvglLI2lvk/eJKYM5x3WquVgzqxNc7NMRuOS4o\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 10
},
"items": []
}
The item is now showing up, so it looks to just take some time before the API reflects what's been uploaded.

Resources