# User

## ProfileService API

Get the ProfileService object via a login session.

```kotlin
val profileService = session.profileService()
```

### **Set user nickname**

Updates the user's display name.

```kotlin
suspend fun setDisplayName(userId: String, newDisplayName: String)
```

**Input parameters:**

| Name           | Type   | Description      | Required |
| -------------- | ------ | ---------------- | -------- |
| userId         | String | User ID          | true     |
| newDisplayName | String | New display name | true     |

### **Set user avatar**

Updates the user's profile picture.

```kotlin
suspend fun updateAvatar(userId: String, newAvatarUri: Uri, fileName: String)
```

**Input parameter:**

| Name         | Type   | Description                 | Required |
| ------------ | ------ | --------------------------- | -------- |
| userId       | String | User ID                     | true     |
| newAvatarUri | String | New avatar uri              | true     |
| fileName     | String | Name of selected image file | true     |

### **Set user profile description**

Sets a self-introduction for the user's profile.

```kotlin
suspend fun setProfileBio(userId: String, bio: String)
```

**Input parameter:**

| Name   | Type   | Description         | Required |
| ------ | ------ | ------------------- | -------- |
| userId | string | User ID             | true     |
| bio    | string | Profile description | true     |

**Output parameter:** None

### **Retrieve user profile**

Get a user's profile data

```kotlin
suspend fun getProfile(userId: String): JsonDict
```

**Input parameter:**

| Name   | Type   | Description | Required |
| ------ | ------ | ----------- | -------- |
| userId | string | User ID     | true     |

**Output parameter:**

| Type     | Description                 | Required |
| -------- | --------------------------- | -------- |
| JsonDict | User profile key-value data | true     |

**JsonDict fields：**

| Name            | Type   | Description                    | Required |
| --------------- | ------ | ------------------------------ | -------- |
| displayname     | string | User nickname                  | true     |
| avatar\_url     | string | User profile image             | true     |
| bio             | string | User profile self-introduction | true     |
| wallet\_address | string | User wallet address            | true     |

***

## AccountDataService API

Get the AccountDataService object through a login session

```kotlin
val accountDataService = session.accountDataService()
```

### **Set user account data**

Sets custom data related to the user. `content` contains the complete data for the specified type.

```kotlin
suspend fun updateUserAccountData(type: String, content: Content)
```

**Input parameter:**

| Name    | Type    | Description                | Required |
| ------- | ------- | -------------------------- | -------- |
| type    | string  | Customized data type       | true     |
| content | Content | Content in key-value pairs | true     |

**Output parameter:** None

### **Retrieve user account data**

```kotlin
fun getUserAccountDataEvent(type: String): UserAccountDataEvent?
```

**Input parameter:**

| Name | Type   | Description                    | Required |
| ---- | ------ | ------------------------------ | -------- |
| type | string | Type of data you wish to query | true     |

**Output parameter:** `UserAccountDataEvent`

| Name    | Type    | Description     | Required |
| ------- | ------- | --------------- | -------- |
| type    | string  | Data type       | true     |
| content | Content | Key/value pairs | true     |

***

## UserService API

Get the UserService object via a login session.

<pre class="language-kotlin"><code class="lang-kotlin"><strong>val userService = session.userService()
</strong></code></pre>

### **Get the contact list**

Retrieve the list of your contacts.

```kotlin
suspend fun getContacts(): List<ContactInfo>
```

**Input parameters:** None

**Output parameter:**

<table><thead><tr><th width="151">Type</th><th width="313">Description</th><th>Required</th></tr></thead><tbody><tr><td>List</td><td>List of contact's information</td><td>true</td></tr></tbody></table>

`ContactInfo` details：

<table><thead><tr><th width="152">Name</th><th>Type</th><th width="197">Description</th><th>Required</th></tr></thead><tbody><tr><td>contactId</td><td>String</td><td>Contact ID</td><td>true</td></tr><tr><td>displayName</td><td>String</td><td>Contact name</td><td>false</td></tr><tr><td>avatarUrl</td><td>String</td><td>URL to the contact's avatar image</td><td>false</td></tr><tr><td>walletAddress</td><td>String</td><td>Contact's wallet address</td><td>false</td></tr><tr><td>tags</td><td>String array</td><td>Array of tags associated with the contact</td><td>false</td></tr></tbody></table>

### **Add a contact**

Add a user to your contact list.

```kotlin
suspend fun addContact(contactId: String, tags: List<String> = listOf())
```

**Input parameters:**

<table><thead><tr><th width="129">Name</th><th width="124">Type</th><th width="177">Description</th><th>Required</th></tr></thead><tbody><tr><td>contactId</td><td>String</td><td>Contact ID</td><td>true</td></tr><tr><td>tags</td><td>String array</td><td>Array of tags associated with the contact</td><td>false</td></tr></tbody></table>

**Output parameter:** None

### **Delete a contact**

Remove a user from your contact list.

```kotlin
suspend fun removeContact(contactId: String)
```

**Input parameters:**

| Name      | Type   | Description | Required |
| --------- | ------ | ----------- | -------- |
| contactId | String | Contact ID  | true     |

**Output parameter:** None
