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

> Retrieve one post as a live object, or fetch a known set of post IDs where the SDK supports batch lookup.

Use post retrieval when your app already knows the post ID. Single-post retrieval returns a live object or stream on every SDK. Batch lookup is available on TypeScript, iOS, and Android.

## Parameters

| Operation            | Parameter | Required | Description                                                       |
| -------------------- | --------- | -------- | ----------------------------------------------------------------- |
| Single post          | `postId`  | Yes      | Unique post ID to observe or fetch.                               |
| Multiple posts by ID | `postIds` | Yes      | List or set of post IDs to fetch on TypeScript, iOS, and Android. |

## Single Post

Observe a single post when a detail screen should update as post data, counters, or moderation state changes.

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

  const unsubscribe = PostRepository.getPost(
    postId,
    ({ data: post, loading, error }) => {
      if (loading) return;
      if (error) {
        handleError(error);
        return;
      }
      if (post) {
        renderResults(post);
      }
    },
  );
  ```

  ```kotlin Android theme={null}
  postRepository.getPost(postId)
      .subscribe(
          { post -> showSuccessMessage(post.getPostId()) },
          { error -> handleGeneralError(error) }
      )
  ```

  ```swift iOS theme={null}
  let postRepository = AmityPostRepository()
  var token: AmityNotificationToken?

  token = postRepository.getPost(withId: "post-id").observe { liveObject, error in
      guard let post = liveObject.snapshot else { return }
      showSuccessMessage(post.postId)
  }
  ```

  ```dart Flutter theme={null}
  final subscription = AmitySocialClient.newPostRepository()
      .live
      .getPost(postId)
      .listen((AmityPost post) {
        final id = post.postId;
      });

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

## Multiple Posts by ID

Fetch a known set of post IDs when your app already has exact IDs and does not need a paged feed query.

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

  const { data: posts } = await PostRepository.getPostByIds([
    postId,
    "another-post-id",
  ]);
  ```

  ```kotlin Android theme={null}
  postRepository.getPostByIds(setOf(postId, "another-post-id"))
      .subscribe(
          { posts -> showSuccessMessage(posts.size) },
          { error -> handleGeneralError(error) }
      )
  ```

  ```swift iOS theme={null}
  let postRepository = AmityPostRepository()
  var token: AmityNotificationToken?

  token = postRepository.getPosts(postIds: ["post-id", "another-post-id"]).observe { collection, error in
      showSuccessMessage(collection.snapshots.count)
  }
  ```
</CodeGroup>

<Info>
  The current Flutter public post repository exposes single-post retrieval through `live.getPost(postId)` and the deprecated `getPost(postId)` future, but it does not expose a public batch get-by-IDs method.
</Info>

## Notes

* Keep the unsubscriber or notification token so you can dispose the live object when the screen is destroyed.
* Use query APIs when you need a feed, pagination, filtering, or real-time collection updates.
* Batch lookup skips invalid IDs on iOS collection results; handle an empty collection as a valid outcome.

## Related Topics

<CardGroup cols={3}>
  <Card title="Query Posts" icon="filter" href="./query-posts">
    Query posts by feed target, post type, review status, or tags.
  </Card>

  <Card title="Viewing Content" icon="eye" href="./viewing-content">
    Render post data and child media safely.
  </Card>

  <Card title="Post Overview" icon="newspaper" href="../overview">
    Review post structure and post data types.
  </Card>
</CardGroup>
