specify recipient Youtube api v3 insert comment - youtube-api

On youtube when I tap Reply button under a non top level comment, the recipient user gets mentioned at the start of the message #Philip .... How can I replicate this behavior with an api v3? My main goal is to notify the reply owner.
I've tried specifying parentId, but it looks like only top level comment can be passed into this property.
Also I've tried specifying #Philip and #CHANNEL_ID at the message start - it doesn't creates a link.
I've inspected commenting in Chrome, and it sends "create_comment_reply" request, which seems like private api😞

Mentions are only for replies to comments in a top-level comment.
Youtube Data API v3 only supports replies to top-level comment. One cannot currently comment to a comment to top-level comment using the API.
In the docs for parameters for comments/list, they note that:
Note: YouTube currently supports replies only for top-level comments. However, replies to replies may be supported in the future.
When comments are supported for comments to top-level comments, it may be possible to perform mentions.

Related

Is there a way to access the comments I make on YouTube through the API?

I'm trying to retrieve the comments I've made on YouTube to turn them into Markdown files, but I can't find a way to do it filtering by user in the API documentation.
I thought it would be possible since the Google account has a link for it but when using the parameter "channelID" in the API to list comments as it says in the documentation, it gives back a 400 error.
You are looking for the comments your channel posted, however when using CommentThreads: list with channelId=YOUR_CHANNEL_ID you are listing comments people wrote on your channel, as described the documentation:
channelId
string
The channelId parameter instructs the API to return comment threads containing comments about the specified channel. (The response will not include comments left on videos that the channel uploaded.)
One more time YouTube Data API v3 AFAIK doesn't provide this basic feature.
You have two possibilities:
Use Google TakeOut (make sure to export Comments in YouTube and YouTube Music)
Web-scrap the webpage you provided

Can I use the Youtube API to write comments?

Can I use the Youtube API to write comments? If yes, please provide an example request.
As per the documentation, there are two endpoints that you can use: Comments and CommentThreads, depending on whether your comment is a reply to an existing one, or, otherwise, is a top-level comment (i.e. one that starts a new thread). The reference docs also provide examples attached.

Youtube Data API v3: commentThread call doesn't give replies for some comment threads

I have a problem with commentThread API call. Here is one specific case: comment id: z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k
https://www.googleapis.com/youtube/v3/commentThreads?id=z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k&part=snippet%2C+replies&key={YOUR_DEVELOPER_KEY}&alt=json&order=time
There are 44 replies for now.
But if you use video_id (not comment id like we did above. Link: https://www.googleapis.com/youtube/v3/commentThreads?videoId=Ui-ulCWmpOU&maxResults=100&pageToken=ChYQp7fipbfsxgIYkNGqiobjxQIgACgDEhQIABCQ0aqKhuPFAhiMqqKive-5AhgCIKwC&part=snippet%2C+replies&key={YOUR_DEVELOPER_KEY}&alt=json&order=time) and come across the comment (you may have to use pageToken to iterate over pages) you will see this:
(Screenshot: https://www.dropbox.com/s/d4bf9tk51eaw7dr/Screenshot%202015-07-21%2021.08.31.png?dl=0)
As you noticed; there is 39 replies (comments) which is not true. And even if we have replies; there is no replies section. Am I missing something?
Two questions: Why number of replies don't match? Why that commentThread doesn't have replies even it has 39 replies?
Notes: As part I am using 'snippet, replies'. I don't get any API error (like throttle or limit violation)
From the commentThreads documentation:
The commentThread resource does not necessarily contain all replies to
a comment, and you need to use the comments.list method if you want to
retrieve all replies for a particular comment.
Use the comments.list call instead and specify the commentThread's ID for the parentId.
When I do the following call:
https://www.googleapis.com/youtube/v3/comments?part=snippet,id&parentId=z13ocxipdz3hwxqqe04cgbuadtmnhhmybyc0k&key=[API_KEY_HERE]&order=time&maxResults=50
I get all (44) of the responses to the comment thread you mentioned.
To address your questions:
Why number of replies don't match?
If I had to guess, I'd say it might be due to how the API differentiates between comments and comment threads (where it considers replies to other replies in a thread as opposed to them being associated with the video itself). Since the documentation says that the commentThread resource might not contain all replies to a comment, I think this is still working as intended. At any rate, in the future it's generally better to just go with the higher number of replies reported, since it's more likely that the API is missing some results than reporting extra results. Also, remember that you should be using comments.list if you want all of the replies to a certain comment thread.
Why that commentThread doesn't have replies even it has 39 replies?
To be honest, I'm not sure if it's a YouTube thing or a G+ thing. When I looked at some of the other comment threads that had replies, I was able to see them via the API call when video ID is specified. However, as Daniel mentioned, you can't actually see the replies for the thread you specified on the video itself (but you can see them when you go to that user's G+ page). It's possible that user did something to their G+ settings regarding comments on their shared posts, which is why they aren't showing up on the video itself and thus not showing up in the commentThreads list request. It's hard to say unless you talked to someone who's familiar with G+/YouTube integration.
While I wasn't able to answer your questions definitely, I was able to find some useful info that may give you some clarity and direction.
With regard to the specific case outlined in your question: the user "authorDisplayName": "Tammy L." commented on the video "videoId": "Ui-ulCWmpOU" on 11/16/2013, and received replies between 11/16/2013 and 11/18/2013. According to Tammy L.'s record on Google+, there are 44 replies to her initial comment from this date:
Although, according to the record on YouTube, it appears that there are 42 replies to her comment, which doesn't match either value returned from your API calls. Even more bizarre, Google won't display the comments when I click on "View all 42 replies":
It seems that the commentId call provides the correct number of replies made to Tammy L.'s initial comment, which is consistent with the number of replies shown on her Google+ account. Perhaps the issues with the videoId call (including the fact that this call doesn't provide replies) are attributable to the changes Google implemented around the time that Tammy L. made her initial comment (November 2013), although I'm not totally sure.

How to get comment content from Youtube Activity List Comment type

In Youtube API v3, the activity list endpoint returns many activities for various type. Surprisingly the contentDetails return very little information. In terms of comment type, it seems to return only what you have commented to, but no comment identifier nor the actual comment content.
Is there a good way to identify what the user has commented with reference to the exact comment activity?
V3 is still incomplete, some snippet.types like comment aren't available as of now but should be added before api v2 is phased out on 20th April 2015.youtube's v3 migration blog
we use this endpoint
https://www.googleapis.com/youtube/v3/activities?part=snippet,id,contentDetails&mine=true
and parameters to retrieve user's
recommendation, likes, upload, subscription, bulletin
while the full list should be
bulletin, channelItem, comment, favorite, like, playlistItem, recommendation,
social, subscription, upload
comments don't come in this list as of now.
but to get all comments on a particular video you can use their deprecated v2 api endpoint for now
http://gdata.youtube.com/feeds/api/videos/VIDEO_ID/comments

How to get links in comments from the YouTube api following the move to Google+ comments

In the new YouTube Google + comments system how can I retrieve comments that contain links.
For example if someone posts a link to another youtube video as follows:
http://www.youtube.com/watch?v=AZNHuFjnmUo
This gets converted to a link by the google plus system. The title of the video is shown as the text rather that the url. i.e. The html shown within the comments is this:
Francis HATES Google+
However the api for that comment only returns the title of the video which is pretty useless seeing as I want to get the link too. I am guessing that the system converts the url into an <a> tag which is stored in the database but then the api strips out the html when its requested so it only returns the videos title.
I have posted a defect here:
https://code.google.com/p/gdata-issues/issues/detail?id=5500
But that bug list seems to have very little activity going on in terms of responses to issues.
So is there another way to get the data I need?
What you can do while this bug remains is to extract the comment id and use it in the Google+ API with an activities.get request. This will return the full post with all links.
A bit cumbersome since it needs one request for each comment you want to check, but it seems to be the only way while the bug remains.
To take an example from the video you linked in the issue:
This YouTube comment returned by the API includes a YouTube link:
http://gdata.youtube.com/feeds/api/videos/rgkDKeSc-1o
/comments/z12hvvcgxznkufyo304ci1iqlnandzxjpes
You can use the z... ID in a request to the Google+ API:
https://developers.google.com/apis-explorer/#p/plus/v1/plus.activities.get?activityId=z12hvvcgxznkufyo304ci1iqlnandzxjpes
Which includes the full post including links.

Resources