The social.plus SDK provides powerful post querying functionality that enables flexible content discovery and filtering. Query posts from communities, user feeds, or across the entire platform with customizable search criteria and real-time results.

Live Collection

Query results are returned as live collections with real-time updates

Flexible Filtering

Filter by post type, target, deletion status, and custom criteria

Query Parameters

ParameterTypeRequiredDescription
targetIdStringYesID of the community or user respectively. Use community ID for community posts or user ID for user feed posts.
targetTypeEnumYesType of the target, either a particular community (community) or a user feed (user).
typesArrayNoAvailable post types: video, image, file, liveStream, poll, and custom. If not specified, returns all post types for the target.
tagsArrayNoFilter posts by specific tags. When specified, only posts containing these tags will be returned. Useful for content categorization and topic-based filtering.
includeDeletedBooleanNoDeletion filter. When true, retrieves both deleted and non-deleted posts. When false (default), only non-deleted posts are returned. Excludes all deleted posts (both soft and hard deleted) not owned by the logged-in user. Community moderators can see soft-deleted posts in community feeds, while users can see their own soft-deleted posts in their user feeds.
sortByEnumNoSort order for results. lastCreated (default) shows most recently created posts first, firstCreated shows earliest created posts first.
feedTypeEnumNoType of the feed filter. Possible values: published, reviewing, declined. See Feed Types for details.

Feed Types

var token: AmityNotificationToken?

func postQueryExample() {
    // In this example, we will query posts to build user's media gallery.
    // This gallery shows the feed; specifically "image" and "video".
    //
    // 1. Create AmityPostQueryOptions
    // For this use-case:
    // - Search all the "image" and "video" posts
    // - Belong to a user, for example "steven".
    // - Only non-deleted posts.
    // - Sorted by last created.
    let options = AmityPostQueryOptions(
        targetType: .user,
        targetId: "steven",
        sortBy: .lastCreated,
        deletedOption: .notDeleted,
        filterPostTypes: ["image", "video"]
    )
    // 2. query the posts, and handle the results via the live collection.
    token = postRepository.getPosts(options).observe { collection, changes, error in
        // Observe the live collection changes here.
    }
}

Parameter Usage Examples

Common Use Cases

Community Feed

Display all posts in a community with real-time updates and customizable filtering options.

User Profile

Show a user’s post history with privacy controls and content type filtering.

Media Gallery

Create image and video galleries by filtering posts with media attachments.

Best Practices