Skip to main content

Get User Feed

The getUserFeed API enables you to query a user’s personal feed posts alongside posts they’ve authored in public communities. This provides a comprehensive view of user activity across the platform.

Overview

Flexible Sources

Query personal posts, community posts, or both with configurable feed sources

Privacy Aware

Automatically respects user privacy settings and community visibility rules

API Overview

The new feed repository approach uses the getUserFeed method with configurable feed sources:
GET /api/v4/user-feeds/:userId

feed_repository.getUserFeed(
  userId: string,
  feedSources?: ('user' | 'community')[],  // default: ['user']
  dataTypes?: string[],                    // default: all types
  sortBy?: string,                         // default: 'lastCreated'
  includeDeleted?: boolean,                // default: false
  matchingOnlyParentPost?: boolean         // default: true
)

Parameters

ParameterTypeDescriptionDefaultOptions
userIdStringTarget user IDRequiredAny valid user ID
feedSourcesArraySource types for feed content['user']'user', 'community', ['user', 'community']
dataTypesArrayPost content types to includeAll typestext, image, video, file, audio, poll, liveStream, custom
sortByStringSort order for results'lastCreated''lastCreated', 'firstCreated'
includeDeletedBooleanInclude soft-deleted postsfalsetrue, false
includeMixedStructureBooleanInclude mixed media posts in filteringfalsetrue, false. When true, posts with mixed media types are included when filtering by dataTypes. See Query Posts - Mixed Media Filtering for details.
matchingOnlyParentPostBooleanInclude only parent posts (no replies)truetrue, false

Feed Source Types

Source TypeDescriptionVisibility
'user'Posts made directly to the user’s personal feedBased on user’s privacy settings
'community'Posts authored by the user in public communitiesPublic community posts only
['user', 'community']Combined feed showing both personal and community postsMerged in chronological order

Implementation Examples

  • iOS
  • Android
  • TypeScript
  • Flutter
import AmitySDK

class UserFeedManager {
    private let client: AmityClient
    
    init(client: AmityClient) {
        self.client = client
    }
    
    // Query user's personal feed only (default behavior)
    func getUserPersonalFeed(
        userId: String,
        sortBy: AmityPostQuerySortOption = .lastCreated
    ) -> AmityCollection<AmityPost> {
        
        let repository = AmityFeedRepository(client: client)
        
        return repository.getUserFeed(
            userId: userId,
            feedSources: ["user"],
            sortBy: sortBy,
            includeDeleted: false,
            matchingOnlyParentPost: true
        )
    }
    
    // Query user's community posts only
    func getUserCommunityPosts(
        userId: String,
        includeDeleted: Bool = false
    ) -> AmityCollection<AmityPost> {
        
        let repository = AmityFeedRepository(client: client)
        
        return repository.getUserFeed(
            userId: userId,
            feedSources: ["community"],
            sortBy: .lastCreated,
            includeDeleted: includeDeleted,
            matchingOnlyParentPost: true
        )
    }
    
    // Query combined feed (personal + community posts)
    func getUserCombinedFeed(
        userId: String,
        dataTypes: [AmityPostDataType] = []
    ) -> AmityCollection<AmityPost> {
        
        let repository = AmityFeedRepository(client: client)
        
        return repository.getUserFeed(
            userId: userId,
            feedSources: ["user", "community"],
            dataTypes: dataTypes.isEmpty ? nil : dataTypes,
            sortBy: .lastCreated,
            includeDeleted: false,
            matchingOnlyParentPost: true
        )
    }
    
    // Observe feed with community posts
    func observeUserCombinedFeed(
        userId: String,
        onUpdate: @escaping ([AmityPost]) -> Void,
        onError: @escaping (Error) -> Void
    ) -> AmityNotificationToken {
        
        let collection = getUserCombinedFeed(userId: userId)
        
        return collection.observe { result in
            switch result {
            case .success(let postsInfo):
                let posts = postsInfo.object
                onUpdate(posts)
                
            case .failure(let error):
                onError(error)
            }
        }
    }
}

Privacy and Visibility Rules

Public Communities Only: Only posts from public communities are included in user feeds - Posts from private communities are never shown - Community privacy changes affect visibility retroactively - Deleted communities remove all associated posts from user feeds
Privacy Settings Integration: User feed visibility respects profile privacy - Private profiles: Only followers can see the combined feed - Public profiles: Anyone can view community posts - Blocked users: See empty state with filter options still visible
Membership Status: Posts remain visible even after leaving communities - Left community: Posts remain if community is still public - Community becomes private: Posts are removed from user feed - Community deleted: All posts removed from user feed
Moderator Indicators: Special badges for community moderators - Moderator badge shown on posts in communities where user is a moderator - Badge visibility follows community’s current state - No retroactive badge removal when moderator status changes

Use Cases

User Profile Feeds

Display comprehensive user activity including personal and community posts with privacy controls

Community Discovery

Help users discover active community contributors through their post history

Content Aggregation

Aggregate user content from multiple sources for analytics and insights

Moderation Review

Review user activity across personal and community contexts for moderation decisions

Best Practices

  • Use specific feedSources instead of always querying both
  • Implement pagination for users with many posts
  • Cache frequently accessed user feeds
  • Dispose of live collections when no longer needed
  • Always respect user privacy settings
  • Handle blocked users appropriately
  • Provide clear UI indicators for private vs public content
  • Follow platform privacy guidelines
  • Show loading states during feed queries
  • Implement pull-to-refresh for real-time updates
  • Provide empty states for users with no content
  • Use skeleton screens for better perceived performance
  • Handle network connectivity issues gracefully
  • Implement retry mechanisms for failed queries
  • Provide meaningful error messages
  • Log errors for debugging without exposing sensitive information
Backward Compatibility: The default behavior (feedSources: ['user']) maintains existing functionality. Enable community posts by explicitly setting feedSources: ['user', 'community'].
Privacy Note: Community posts are only included from public communities. Private community content is never exposed through user feeds, ensuring user privacy and community security.