> ## Documentation Index
> Fetch the complete documentation index at: https://social-b97141fb-feat-user-history-moderation-detail.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# User Profiles & Social Graph

> Build user profiles, follow/unfollow with connection requests, bidirectional blocking, and follower/following lists.

> [!NOTE]
>
> **SDK v7.x** · Last verified March 2026 · iOS · Android · Web · Flutter

> **Speed run — just the code**
>
> ```typescript theme={null}
> // 1. Follow a user
> await UserRepository.Relationship.follow('targetUserId');
>
> // 2. Unfollow
> await UserRepository.Relationship.unfollow('targetUserId');
>
> // 3. Accept a follow request
> await UserRepository.Relationship.acceptMyFollower('requesterId');
>
> // 4. Block a user
> await UserRepository.Relationship.blockUser('targetUserId');
>
> // 5. Query followers
> UserRepository.Relationship.getFollowers('userId', 'accepted',
>   ({ data }) => { /* render */ }
> );
> ```
>
> Full walkthrough below ↓

> [!TIP]
>
> **Platform note** — code samples below use TypeScript. Every method has an equivalent in the iOS (Swift), Android (Kotlin), and Flutter (Dart) SDKs — see the linked SDK reference in each step.

![Three user profile screens: Sarah's Journey wellness profile with streak stats and sleep chart, Alex\_Predictor sports profile with prediction accuracy and achievement badges, and Caroline Parker music genre selection onboarding](https://mintcdn.com/social-b97141fb-feat-user-history-moderation-detail/x8DjzIl7SM9fvUVd/images/use-cases/user-profile-hero.png?fit=max\&auto=format\&n=x8DjzIl7SM9fvUVd\&q=85\&s=fbd22914e2d9831b0eebb44366d0fd05)

User profiles — health tracker with activity feed, sports predictor with achievements, and music preference onboarding

A social graph connects your users to each other. This guide covers querying and displaying user profiles, building the follow/unfollow system with pending-request support, and implementing bidirectional blocking.

```mermaid theme={null}
graph TD
    A[User A] -->|follows| B[User B]
    B -->|accepts request| C[Connected]
    A -->|blocks| D[User C]
    D -.->|content hidden from| A
    C --> E[User A sees User B's posts]
    C --> F[User B sees follower count increase]

    classDef action fill:#e1f5fe,stroke:#0288d1,color:#01579b
    classDef decision fill:#fff8e1,stroke:#f9a825,color:#f57f17
    classDef process fill:#f3e5f5,stroke:#7b1fa2,color:#4a148c
    classDef outcome fill:#e8f5e9,stroke:#388e3c,color:#1b5e20

    class A action
    class B,D process
    class C,E,F outcome
```

## Data Model

```mermaid theme={null}
erDiagram
    USER {
        string userId PK
        string displayName
        string avatarUrl
        object metadata
        int followersCount
        int followingCount
        int flagCount
    }
    FOLLOW_RELATIONSHIP {
        string sourceUserId FK
        string targetUserId FK
        string status "pending | accepted"
    }
    BLOCK {
        string sourceUserId FK
        string targetUserId FK
    }
    USER ||--o{ FOLLOW_RELATIONSHIP : "has followers"
    USER ||--o{ FOLLOW_RELATIONSHIP : "is following"
    USER ||--o{ BLOCK : "blocks"
```

> [!NOTE]
>
> **Prerequisites**: SDK installed and authenticated. You'll need valid `userId` values for the current user and any target users.

> [!NOTE]
>
> **After completing this guide you'll have:**
>
> * User profile display with avatar, bio, and follower/following counts
> * Follow, unfollow, and connection-request flows working end-to-end
> * Bidirectional blocking implemented with proper feed filtering

***

## Quick Start: Follow a User

Use the relationship API to follow another user:

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

const { data: followStatus } = await UserRepository.Relationship.follow(userId);
// followStatus.status: 'accepted' | 'pending'
```

Full reference → [Follow / Unfollow User](/social-plus-sdk/social/user-relationship/following/follow-unfollow-user.md)

***

## Step-by-Step Implementation

**1. Get a user profile**

Query a user's profile to display their name, bio, avatar, and follower/following counts.

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

const unsubscribe = UserRepository.getUser(userId, ({ data: user, loading }) => {
  if (user) {
    console.log(user.displayName, user.description, user.avatarFileId);
  }
});
```

Full reference → [Get User Information](/social-plus-sdk/core-concepts/user-management/user-operations/get-user-information.md)

**2. Follow a user**

For public accounts, following is immediate. For accounts with privacy settings requiring approval, this sends a follow request.

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

const { data: followStatus } = await UserRepository.Relationship.follow(userId);
// followStatus.status: 'accepted' | 'pending'
```

Full reference → [Follow / Unfollow User](/social-plus-sdk/social/user-relationship/following/follow-unfollow-user.md)

**3. Unfollow a user**

Full reference → [Follow / Unfollow User](/social-plus-sdk/social/user-relationship/following/follow-unfollow-user.md)

**4. Handle follow requests (request-based following)**

When a user's account requires approval for follows, incoming requests land in a pending queue. Moderators or the target user can accept or decline.

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

const isAccepted = await UserRepository.Relationship.acceptMyFollower('userId');
```

Full reference → [Accept/Decline Follow Request](/social-plus-sdk/social/user-relationship/following/accept-decline-follow-request.md)

**5. Get connection status**

Check the relationship between two users before displaying follow/unfollow buttons. Status can be: `none`, `following`, `pending`, or `blocked`.

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

const unsubscriber = UserRepository.Relationship.getFollowInfo(
  'userId',
  ({ data: followInfo }) => {
    console.log('Followers:', followInfo.followerCount);
    console.log('Following:', followInfo.followingCount);
  },
);
```

Full reference → [Get Connection Status](/social-plus-sdk/social/user-relationship/following/get-connection-status.md)

**6. Get followers and following lists**

Query paginated lists of a user's followers and the users they follow.

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

const unsubscriber = UserRepository.Relationship.getFollowers(
  { userId: 'my-user-id' },
  ({ data: followers, onNextPage, hasNextPage }) => {
    if (followers) { /* render follower list */ }
  },
);
```

Full reference → [Get Follower / Following List](/social-plus-sdk/social/user-relationship/following/get-follower-following-list.md)

**7. Block and unblock a user**

Blocking is bidirectional — neither user can see the other's content or interact with them. You can also read both directions: the users you blocked, and the users who blocked you.

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

// Block — handle the per-network block limit
try {
  await UserRepository.Relationship.blockUser('userId');
} catch (error) {
  if (error?.code === Amity.ServerError.MAX_BLOCKED_USERS_REACHED) {
    showBlockedUserLimitReached();
  }
}

// Users the current user blocked
const blocked = await UserRepository.getAllBlockedUsers();

// Users who blocked the current user (reverse direction)
const blocking = await UserRepository.getAllBlockingUsers();
```

Full reference → [Block / Unblock User](/social-plus-sdk/social/user-relationship/blocking/block-unblock-user.md), [Manage Blocked Users](/social-plus-sdk/social/user-relationship/blocking/manage-blocked-users.md), [Users Who Blocked You](/social-plus-sdk/social/user-relationship/blocking/manage-blocking-users.md)

***

## Connect to Moderation & Analytics

> **User flagging**
>
> Users can flag other users for abuse or spam. Flagged users appear in the Admin Console for moderator review.
>
> → [Flag / Unflag User](/social-plus-sdk/core-concepts/user-management/user-operations/flag-unflag-user.md) · [Admin Console: User Insights](/analytics-and-moderation/console/user-and-content-management/user-insights.md)

> **User insights in Admin Console**
>
> View per-user analytics including post count, comment count, and activity history in **Admin Console → User Management → User Insights**.

> **Webhook: follow events**
>
> Receive `user.followed` and `follow.request.created` webhook events to build notification flows and sync social graph state to your backend.
>
> → [Webhook Events](/analytics-and-moderation/social+-apis-and-services/webhook-event.md)

***

## Common Mistakes

> [!WARNING]
>
> **Not handling the pending follow state** — When a user requires approval, `follow()` creates a pending request — not an immediate follow. Your UI must show "Requested" instead of "Following".
>
> ```typescript theme={null}
> // ❌ Bad — assumes instant follow
> await UserRepository.Relationship.follow('userId');
> setState('following'); // wrong!
>
> // ✅ Good — check the returned status
> const { data } = await UserRepository.Relationship.follow('userId');
> setState(data.status); // 'accepted' or 'pending'
> ```

> [!WARNING]
>
> **Blocking without unfollowing first** — Blocking a user does not automatically unfollow them. Call `unfollow` before `blockUser` to fully sever the relationship.

> [!WARNING]
>
> **Querying the full follower list on profile load** — Large accounts can have thousands of followers. Only fetch a count for the profile header, and paginate the full list on demand.

## Best Practices

> **Privacy**
>
> * Show follower counts as rounded numbers for large accounts ("1.2K") to avoid gaming dynamics
> * Never expose private account content before a follow request is accepted
> * Let users choose between public and request-based following in their account settings
> * When a user blocks another, immediately hide the blocked user's content from all feeds client-side

> **UX**
>
> * Show the connection status in a single CTA button: "Follow" → "Requested" → "Following"
> * Display mutual followers ("3 people you follow also follow this account") to drive trust
> * Add empty states for users with 0 followers/following — show suggestions instead of a blank list

> **Performance**
>
> * Cache the current user's following list locally for fast "is following" checks without a network call
> * Paginate follower/following lists — request 30 at a time
> * Observe user Live Objects sparingly — only subscribe when the profile screen is active

***

> [!TIP]
>
> **Dive deeper**: [User Relationships API Reference](/social-plus-sdk/social/user-relationship/overview.md) has full parameter tables, method signatures, and platform-specific details for every API used in this guide.

## Next Steps

> **[Your next step → User Search & People Discovery](/use-cases/social/user-search-and-people-discovery.md)**
>
> Profiles are live — now let users find each other with search, suggestions, and "People you may know".

Or explore related guides:

> **[Build a Social Feed](/use-cases/social/build-a-social-feed.md)**
>
> Show posts from followed users in a personalized feed

> **[Notifications & Engagement](/use-cases/social/notifications-and-engagement.md)**
>
> Notify users of new followers and follow requests

> **[Community Platform](/use-cases/social/community-platform.md)**
>
> Manage member roles within communities


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