Accessing comments of a video - youtube-api

I'm having trouble finding a way to access comments from a youtube video.
The closest thing I came across told me that that feature was a google+ only api call.
using
https://developers.google.com/youtube/v3/docs/comments/list#try-it
i get
SHOW HEADERS -
{
"error": {
"errors": [
{
"domain": "youtube.comment",
"reason": "operationNotSupported",
"message": "The id filter is only compatible with comments based on Google+.",
"locationType": "parameter",
"location": "id"
}
],
"code": 400,
"message": "The id filter is only compatible with comments based on Google+."
}
}

You can use CommentThreads:list which returns a list of all comments threads that match the API request parameters.
HTTP request
GET https://www.googleapis.com/youtube/v3/commentThreads
If the response is successfull, method returns a response body with the following structure:
{
"kind": "youtube#commentThreadListResponse",
"etag": etag,
"nextPageToken": string,
"pageInfo": {
"totalResults": integer,
"resultsPerPage": integer
},
"items": [
commentThread Resource
]
}
Here's a YouTube API sample code with different supported programming languages: https://developers.google.com/youtube/v3/docs/commentThreads/list#examples
Found this Stack Overflow related ticket, discuss how to get comments through YouTube API: How to get comments through Youtube Data API v3 / JSOUP parsing?

Related

I can't get this Google Sheets API Get request to work

I am trying to have a game to request data from the Google Sheets API, and I can't get the API Key to function properly. I can visit my API Link in the browser, and it tells me it is getting HTTP 400 (Bad Request) and Google additionally says it's a bad API Key, despite having JUST generated it. For reference my link looks like this: "https://sheets.googleapis.com/v4/spreadsheets/[SHEET_ID]?key=[API_KEY]/values", and the browser views this when using it:
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_INVALID",
"domain": "googleapis.com",
"metadata": {
"service": "sheets.googleapis.com"
}
}
]
}
}
I have absolutely no idea what is going wrong, I know the API key and Sheet ID are right (Directly copied each from their respective source).

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.

Youtube API: Get videos from autogenerated channels (like Music)

Is there any way to get the videos from autogenerated channels (like this one https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ/videos) directly, without having to access all the playlists?
Using https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&key=... gives me 0 items.
Gives me 0 Items
If you mean running the following exactly
https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&key=
Returns the following error
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
That is because you have neglected to add an API key on the end.
Try testing in the query explorer this seams to return quite a few no idea if its all of them.
GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&maxResults=25&key={YOUR_API_KEY}
returns
"pageInfo": {
"totalResults": 786,
"resultsPerPage": 25
},
This apears to return a list of the playlists only for this user.
Update:
If you try and only request videos for this user you get 0 returned. This is not the case for any other user which i have tested.
GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC-9-kyTW8ZkZNDHQJ6FgpwQ&maxResults=50&order=date&type=video&key={YOUR_API_KEY}
This leads me to believe that it is not possible to retrieve the videos for an autogenerated channel. I recommend either logging this as a bug or adding it as a feature request here. Personally i think its more a feature request.

get the title on live video in youtube using API YouTube V3

i am using API Live Streaming youtube to retrieve list of live chat messages on youtube video using id_video, exits serveral properties that appear in this resource such as snippet.liveChatId, snippet.displayMessage which i can found them from this ressource,
so my question is how can i get the title on live video in channel youtube which is not for me ?
thanks
You may want to check this documentation. The items[] property will return a list of live streams that match the request criteria.
{
...
},
"items": [
liveStream Resource
]
}
The following JSON structure shows the format of a liveStreams resource:
{
"kind": "youtube#liveStream",
"etag": etag,
"id": string,
"snippet": {
"publishedAt": datetime,
"channelId": string,
"title": string,
"description": string,
"isDefaultStream": boolean
},
...
}

How to know a playlist is whether private or not through YouTube API not using OAuth

I'm running into a problem with status of a playlist. What I want to do is to get a playlist status without OAuth. But, it is only retrieved when I use playlists.list with OAuth.
When I send a request about a private playlist with playlists.list using API_KEY, it responses with:
GET https://www.googleapis.com/youtube/v3/playlists?part=id%2Csnippet%2Cstatus&id={PRIVATE_PLAYLIST_ID}&key={API_KEY}
{
"kind": "youtube#playlistListResponse",
"etag": "\"q5k97EMVGxODeKcDgp8gnMu79wM/zJL80hJ0IwMo5wddECFapC8I6Q4\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": [
]
}
This doesn't give any clues the playlist is private or other status to me. If I figure it out through YouTube API, how should I do?
Use playlistItems.list instead of playlist.list.
It'll give kind of the indirect information. Even though it doesn't make sure a playlist is exactly private, I think it is useful just in case.
GET https://www.googleapis.com/youtube/v3/playlistItems?part=status&playlistId={PRIVATE_PLAYLIST_ID}&key={API_KEY}
{
"error": {
"errors": [
{
"domain": "youtube.playlistItem",
"reason": "playlistItemsNotAccessible",
"message": "The request is not properly authorized to retrieve the specified playlist.",
"locationType": "parameter",
"location": "playlistId"
}
],
"code": 403,
"message": "The request is not properly authorized to retrieve the specified playlist."
}
}

Resources