Answer the question
In order to leave comments, you need to log in
Why is the YouTube API returning results but no video?
Greetings
There is a video ID: AvWYF1sa1Fw . There is no video, but when requesting data about it through the API in JSON format, it returns a value about the existence of some result of the existence of the video - in totalResults and resultsPerPage it returns ones instead of zeros.
In theory, these fields should be zeros. Please tell me why this is happening and maybe there is another way to check the existence of the video through the API?
I ask, like, standardly:
https://www.googleapis.com/youtube/v3/videos?id={VIDEO_ID}&part=snippet,contentDetails,statistics,status&key={API_KEY}
Answer the question
In order to leave comments, you need to log in
My modest experience shows that when working through an API key, you can only indirectly check the existence of a video - if you have error handling configured when trying to request data from an empty array, as in the example with your video (ID AvWYF1sa1Fw).
Maybe, if you use Google OAuth 2.0, then the API will correctly process the request and return a response that is relevant in such cases, as it is written in the documentation for the Video resource:
notFound (404)
videoNotFound
The video that you are trying to retrieve cannot be found. Check the value of the request's id parameter to ensure that it is correct.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question