--- title: "Yt::CommentThread and Yt::Comment" h2: "Comments" ---

Yt::CommentThread represents a YouTube comment thread. Initialize using its YouTube ID:

{% include doc.html instance="CommentThread#initialize" %}{% include example.html object='thread = Yt::CommentThread' method='new' params=' id: "z121srzx5oqiyrbce23nevcwrpqfenix004"' %}
{% include example.html result='#<Yt::CommentThread @id=z121srzx5oqiyrbce23nevcwrpqfenix004>' %}
{% include doc.html instance="CommentThread#canonical_url" %}{% include example.html object='thread' method='top_level_comment.text_display' %}
{% include example.html result='"A public comment"' %}

Authentication

Most methods of Yt::CommentThread retrieve public data from YouTube (e.g.: the top level comment).
To use these methods (marked with   below), you only need to generate an API key and configure:

{% highlight ruby %} Yt.configuration.api_key = "" ## use your API key thread = Yt::CommentThread.new id: 'z121srzx5oqiyrbce23nevcwrpqfenix004' ## use any ID thread.top_level_comment.text_display # => "A public comment" {% endhighlight %}

List of Yt::CommentThread data methods

{% include dt.html title="CommentThread’s snippet" label="success" auth="any authentication works" %}
{% include doc.html instance="CommentThread#id" %}{% include example.html object='thread' method='id' result='"z121srzx5oqiyrbce23nevcwrpqfenix004"' %}
{% include doc.html instance="CommentThread#channel_id" %}{% include example.html object='thread' method='channel_id' result='nil' %}
{% include doc.html instance="CommentThread#video_id" %}{% include example.html object='thread' method='video_id' result='"gknzFj_0vvY"' %}
{% include doc.html instance="CommentThread#top_level_comment" %}{% include example.html object='thread' method='top_level_comment' result='<Yt::Comment @id=z121srzx5...>' %}
{% include dt.html title="CommentThread’s comments" label="success" auth="any authentication works" %}
{% include doc.html instance="CommentThread#comments" %}{% include example.html object='thread' method='comments' %}
{% include example.html result='#<Yt::Relation [#<Yt::Comment @id=z1...>, #<Yt::Comment @id=z2...>, ...]>' %}

List of Yt::Comment data methods

{% include dt.html title="Comment’s snippet" label="success" auth="any authentication works" %}
{% include doc.html instance="Comment#id" %}{% include example.html object='comment' method='id' result='"z121srzx5oqiyrbce23nevcwrpqfenix004"' %}
{% include doc.html instance="Comment#text_display" %}{% include example.html object='comment' method='text_display' result='"A public comment"' %}
{% include doc.html instance="Comment#author_display_name" %}{% include example.html object='comment' method='author_display_name' result='"Yt Test"' %}
{% include doc.html instance="Comment#author_profile_image_url" %}{% include example.html object='comment' method='author_profile_image_url' result='"https://yt3.ggpht.com/-lC#w"' %}
{% include doc.html instance="Comment#author_channel_url" %}{% include example.html object='comment' method='author_channel_url' result='"http://www.youtube.com/channel/UCwCnUcLc..."' %}
{% include doc.html instance="Comment#author_channel_id" %}{% include example.html object='comment' method='author_channel_id' result='"UCwCnUcLcb9-eSrHa_RQGkQQ"' %}