> ## Documentation Index
> Fetch the complete documentation index at: https://learn.social.plus/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Comment

> Retrieve a comment by ID and observe updates where the SDK exposes live objects or streams.

Use a comment ID when your app needs to open a thread, refresh a detail view, or inspect a comment after creation. TypeScript, iOS, Android, and Flutter all expose single-comment retrieval; the live update shape differs by platform.

## Comment Fields

The comment model names vary by SDK, but these are the fields most apps read after retrieval.

| Concept           | TypeScript                     | iOS                             | Android                                  | Flutter                        |
| ----------------- | ------------------------------ | ------------------------------- | ---------------------------------------- | ------------------------------ |
| Comment ID        | `commentId`                    | `commentId`                     | `getCommentId()`                         | `commentId`                    |
| Parent comment    | `parentId`                     | `parentId`                      | `getParentId()`                          | `parentId`                     |
| Reference         | `referenceId`, `referenceType` | `referenceId`, `referenceType`  | `getReference()`                         | `referenceId`, `referenceType` |
| Data              | `data`                         | `data`                          | `getData()`                              | `data`                         |
| Image attachments | `attachments`                  | `attachments`                   | `getAttachments()`                       | `attachments`                  |
| Reply count       | `childrenNumber`               | `childrenNumber`                | `getChildCount()`                        | `childrenNumber`               |
| Reactions         | `reactionCount`, `myReactions` | `reactionsCount`, `myReactions` | `getReactionCount()`, `getMyReactions()` | `reactionCount`, `myReactions` |
| Deleted state     | `isDeleted`                    | `isDeleted`                     | `isDeleted()`                            | `isDeleted`                    |

## Parameters

| Operation                     | Parameter    | Required | Description                                       |
| ----------------------------- | ------------ | -------- | ------------------------------------------------- |
| Observe a comment             | `commentId`  | Yes      | Comment ID to observe as a live object or stream. |
| Fetch one comment             | `commentId`  | Yes      | Comment ID to fetch once on Flutter.              |
| Fetch multiple comments by ID | `commentIds` | Yes      | Comment IDs to fetch on TypeScript and Android.   |

## Observe a Comment

Observe a single comment when a detail view or thread preview should stay current after edits, deletes, or reactions.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { CommentRepository } from "@amityco/ts-sdk";

  const unsubscribe = CommentRepository.getComment(
    commentId,
    ({ data: comment, loading, error }) => {
      if (loading) return;

      if (error) {
        handleError(error);
        return;
      }

      if (comment) {
        renderResults(comment);
      }
    },
  );
  ```

  ```swift iOS theme={null}
  var token: AmityNotificationToken?

  token = commentRepository
      .getComment(withId: "comment-id")
      .observe { liveObject, error in
          if let error {
              handleError(error)
              return
          }

          guard let comment = liveObject.snapshot else { return }
          showSuccessMessage(comment.commentId)
      }
  ```

  ```kotlin Android theme={null}
  import com.amity.socialcloud.sdk.api.core.ExperimentalAmityApi

  @OptIn(ExperimentalAmityApi::class)
  fun observeComment(commentId: String) {
      AmitySocialClient.newCommentRepository()
          .getComment(commentId = commentId)
          .subscribe(
              { comment -> showSuccessMessage(comment.getCommentId()) },
              { error -> handleGeneralError(error) }
          )
  }

  observeComment(commentId)
  ```

  ```dart Flutter theme={null}
  final commentStream = AmitySocialClient.newCommentRepository()
      .live
      .getComment(commentId);

  final subscription = commentStream.listen((comment) {
    final latestCommentId = comment.commentId;
  }, onError: (error) {
    showError(error);
  });

  await subscription.cancel();
  ```
</CodeGroup>

## Fetch One Comment

Flutter also exposes a direct one-shot fetch for comment detail screens.

<CodeGroup>
  ```dart Flutter theme={null}
  final comment = await AmitySocialClient.newCommentRepository()
      .getComment(commentId: commentId);

  final fetchedCommentId = comment.commentId;
  ```
</CodeGroup>

## Fetch Multiple Comments by ID

Batch lookup is available in TypeScript and Android. Use query APIs when you need a paged collection for a post, story, or custom content item.

<CodeGroup>
  ```typescript TypeScript theme={null}
  import { CommentRepository } from "@amityco/ts-sdk";

  const { data: comments } = await CommentRepository.getCommentByIds([
    commentId,
    "another-comment-id",
  ]);

  renderResults(comments);
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newCommentRepository()
      .getCommentByIds(commentIds = setOf(commentId, "another-comment-id"))
      .subscribe(
          { comments -> showSuccessMessage(comments.size) },
          { error -> handleGeneralError(error) }
      )
  ```
</CodeGroup>

## Notes

* Dispose of live observers or stream subscriptions when the screen is no longer active.
* Android `getComment(...)` is annotated with `ExperimentalAmityApi`; opt in at the call site or enclosing scope.
* If the user needs a list of comments under a reference, use [Query Comments](/social-plus-sdk/social/content-management/comments/retrieval/query-comments) instead of repeated single-comment calls.

## Related Topics

<CardGroup cols={2}>
  <Card title="Query Comments" href="/social-plus-sdk/social/content-management/comments/retrieval/query-comments" icon="search">
    Query top-level comments and reply threads.
  </Card>

  <Card title="Get Latest Comment" href="/social-plus-sdk/social/content-management/comments/retrieval/get-latest-comment" icon="clock">
    Fetch or derive the newest comment for a reference.
  </Card>
</CardGroup>
