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

# Global Feed

> Query the chronological global feed and refresh it on Android.

Global feed returns a paginated collection of posts for the current user's global feed surface. Use data type filters when your UI only needs a subset of post types, such as an image or video feed.

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

  let loadNextPage: (() => void) | undefined;
  let canLoadMore = false;

  const unsubscribe = FeedRepository.getGlobalFeed(
    {
      dataTypes: ['image', 'video'],
      includeMixedStructure: true,
      limit: 20,
    },
    ({ data: posts, onNextPage, hasNextPage, loading, error }) => {
      if (loading) return;
      if (error) {
        handleError(error);
        return;
      }

      renderResults(posts);
      loadNextPage = onNextPage;
      canLoadMore = hasNextPage;
    },
  );

  function loadMoreGlobalFeed() {
    if (canLoadMore) {
      loadNextPage?.();
    }
  }

  unsubscribe();
  ```

  ```swift iOS theme={null}
  token = feedRepository
      .getGlobalFeed(dataTypes: Set(["image", "video"]), includeMixedStructure: true)
      .observe { collection, error in
          if let error {
              handleError(error)
              return
          }

          showSuccessMessage(collection.snapshots.count)
      }
  ```

  ```kotlin Android theme={null}
  AmitySocialClient.newFeedRepository()
      .getGlobalFeed()
      .dataTypes(listOf(AmityPost.DataType.IMAGE, AmityPost.DataType.VIDEO))
      .includeMixedStructure(includeMixedStructure = true)
      .build()
      .query()
      .subscribe(
          { pagingData: PagingData<AmityPost> -> showSuccessMessage(pagingData) },
          { error -> handleGeneralError(error) }
      )
  ```

  ```dart Flutter theme={null}
  final page = await AmitySocialClient.newFeedRepository()
      .getGlobalFeed()
      .types([AmityDataType.IMAGE, AmityDataType.VIDEO])
      .getPagingData(limit: 20);

  final posts = page.data;
  showError(posts.length);
  ```
</CodeGroup>

<Info>
  The global feed shows at most the 20 most recent posts per user or community. Older posts from the same source are not included.
</Info>

## Parameters

| Parameter                            | Platforms  | Required | Description                                                                    |
| ------------------------------------ | ---------- | -------- | ------------------------------------------------------------------------------ |
| `dataTypes`                          | All        | No       | Filter the global feed to specific post content types where supported.         |
| `includeMixedStructure`              | All        | No       | Include mixed-structure posts alongside the requested data type filters.       |
| `limit`, `onNextPage`, `hasNextPage` | TypeScript | No       | Control page size and load additional pages from the live collection callback. |
| `invalidateCache`                    | Android    | No       | Skip cached paging data for deliberate refresh flows.                          |

## Android cache invalidation

Android feed builders expose `invalidateCache(true)`. Use it for deliberate refresh flows, such as pull-to-refresh, when the first page should not reuse the existing paging cache.

<CodeGroup>
  ```kotlin Android theme={null}
  AmitySocialClient.newFeedRepository()
      .getGlobalFeed()
      .invalidateCache(invalidateCache = true)
      .build()
      .query()
      .subscribe(
          { pagingData: PagingData<AmityPost> -> showSuccessMessage(pagingData) },
          { error -> handleGeneralError(error) }
      )
  ```
</CodeGroup>

<Note>
  `invalidateCache` is an Android feed-query option in the current SDK surface reviewed for this page.
</Note>

## Related Topics

<CardGroup cols={3}>
  <Card title="Global Feed UIKit" icon="mobile" href="/uikit/components/social/feeds#global-feed-component">
    Render the chronological global feed with the prebuilt UIKit component.
  </Card>

  <Card title="Custom-Ranking Global Feed" icon="star" href="/social-plus-sdk/social/discovery-engagement/feed/custom-ranking">
    The same content, ordered by engagement instead of by time.
  </Card>

  <Card title="Query Posts" icon="newspaper" href="/social-plus-sdk/social/content-management/posts/retrieval/query-posts">
    Query user and community post collections with more filters.
  </Card>
</CardGroup>
