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

# Trending & Recommended Communities

> Fetch trending and recommended communities with the SDK discovery APIs.

Use the SDK discovery APIs to fetch trending and recommended community lists. These methods call the social.plus backend discovery endpoints and return community collections or lists, depending on platform.

> [card] Trending Communities
>
> Fetch communities from the trending endpoint

> [card] Recommended Communities
>
> Fetch communities from the recommended endpoint

> [!NOTE]
>
> The ranking logic is owned by the backend service. The client SDK exposes methods to request and render the returned communities.

## Parameters

| Operation | Parameter | Required | Platforms | Description |
| - | - | - | - | - |
| Trending communities | `includeDiscoverablePrivateCommunity` | No | TypeScript, iOS, Android | Include discoverable private communities where supported. |
| Trending communities | `limit` | No | TypeScript | Limit the returned collection size. |
| Recommended communities | `includeDiscoverablePrivateCommunity` | No | TypeScript, iOS, Android | Include discoverable private communities where supported. |
| Recommended communities | `limit` | No | TypeScript | Limit the returned collection size. |

## Trending Communities

The `getTrendingCommunities()` method fetches communities from the trending endpoint. TypeScript exposes a Live Collection with pagination options, iOS exposes a Live Collection, Android returns a `Flowable<List<AmityCommunity>>`, and Flutter returns a `Future<List<AmityCommunity>>`.

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

func observeTrendingCommunities() {
    token = communityRepository.getTrendingCommunities(
        includeDiscoverablePrivateCommunity: true
    ).observe { collection, error in
        for community in collection.snapshots {
            // For example, to handle each community in the list.
        }
    }
}
```

```kotlin Android theme={null}
fun queryTrendingCommunities() {
    AmitySocialClient.newCommunityRepository()
        .getTrendingCommunities(includeDiscoverablePrivateCommunity = true)
        .doOnNext { communities: List<AmityCommunity> ->
            // Render trending communities.
        }
        .doOnError { error ->
            // Handle error.
        }
        .subscribe()
}
```

```typescript TypeScript theme={null}
import { CommunityRepository } from '@amityco/ts-sdk';

const unsubscriber = CommunityRepository.getTrendingCommunities(
  { limit: 5, includeDiscoverablePrivateCommunity: true },
  ({ data: communities, loading, error }) => {
    if (error) {
      // Handle error.
    }
    if (loading) {
      // Show loading state.
    }
    if (communities) {
      // Render trending communities.
    }
  },
);
```

```dart Flutter theme={null}
void getTrendingCommunities() {
  AmitySocialClient.newCommunityRepository()
      .getTrendingCommunities()
      .then((List<AmityCommunity> communities) {
        // Render trending communities.
      })
      .onError((error, stackTrace) {
        // Handle error.
      });
}
```

## Recommended Communities

The `getRecommendedCommunities()` method fetches communities from the recommended endpoint. Use it when your discovery UI needs a backend-curated list instead of a filter-based query.

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

func observeRecommendedCommunities() {
    token = communityRepository.getRecommendedCommunities(
        includeDiscoverablePrivateCommunity: true
    ).observe { collection, error in
        for community in collection.snapshots {
            // For example, to handle each community in the list.
        }
    }
}
```

```kotlin Android theme={null}
fun queryRecommendedCommunities() {
    AmitySocialClient.newCommunityRepository()
        .getRecommendedCommunities(includeDiscoverablePrivateCommunity = true)
        .doOnNext { communities: List<AmityCommunity> ->
            // Render recommended communities.
        }
        .doOnError { error ->
            // Handle error.
        }
        .subscribe()
}
```

```typescript TypeScript theme={null}
import { CommunityRepository } from '@amityco/ts-sdk';

const unsubscriber = CommunityRepository.getRecommendedCommunities(
  { limit: 5, includeDiscoverablePrivateCommunity: true },
  ({ data: communities, loading, error }) => {
    if (error) {
      // Handle error.
    }
    if (loading) {
      // Show loading state.
    }
    if (communities) {
      // Render recommended communities.
    }
  },
);
```

```dart Flutter theme={null}
void getRecommendedCommunities() {
  AmitySocialClient.newCommunityRepository()
      .getRecommendedCommunities()
      .then((List<AmityCommunity> communities) {
        // Render recommended communities.
      })
      .onError((error, stackTrace) {
        // Handle error.
      });
}
```

## Best Practices

> [!TIP]
>
> **Recommendation Refresh**: Refresh trending and recommended communities intentionally, such as when the user opens the discovery surface or pulls to refresh.

### User Experience Guidelines

1. **Loading States**: Show skeleton screens during discovery data fetching
2. **Empty States**: Provide fallback content when no recommendations are available
3. **Action Feedback**: Give immediate feedback when users join discovered communities

### Performance Optimization

1. **Pagination**: Use TypeScript pagination options when building longer discovery feeds
2. **Image Optimization**: Preload community avatars for smooth scrolling
3. **Background Updates**: Refresh discovery data in the background

## Related Topics

> [card] [Query Communities](/social-plus-sdk/social/communities-spaces/discovery/query-communities.md)
>
> Advanced community search and filtering capabilities

> [card] [Join Community](../membership/join-leave-community)
>
> Implement community membership actions from discovery

> [card] [Community Categories](/social-plus-sdk/social/communities-spaces/organization/community-categories.md)
>
> Learn about community organization for better recommendations

> [card] [Get Community Details](/social-plus-sdk/social/communities-spaces/discovery/get-community.md)
>
> Display detailed community information before joining


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