> ## Documentation Index
> Fetch the complete documentation index at: /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.

```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 fetchedCommentId = comment.commentId;
}, onError: (error) {
  showError(error);
});

await subscription.cancel();
```

## Fetch One Comment

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

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

final fetchedCommentId = comment.commentId;
```

## 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.

```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) }
    )
```

## 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.md) instead of repeated single-comment calls.

## Related Topics

> **[Query Comments](/social-plus-sdk/social/content-management/comments/retrieval/query-comments.md)**
>
> Query top-level comments and reply threads.

> **[Get Latest Comment](/social-plus-sdk/social/content-management/comments/retrieval/get-latest-comment.md)**
>
> Fetch or derive the newest comment for a reference.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.