# Get User Information

In the social.plus SDK, a user is represented by an `AmityUser` object, which contains the user's unique `userId` and `displayName`. The `userId` is an immutable value that is assigned to a user when their account is created, and cannot be changed afterwards. This value serves as a unique identifier for the user within the SDK, and is used to perform actions such as sending messages or creating connections between users.

To retrieve an `AmityUser` object for a specific `userId`, you can use the `getUser` method provided by the `UserRepository`. This method accepts the `userId` as a parameter and returns a [Live Object](/social-plus-sdk/core-concepts/live-objects-collections.md) of `AmityUser`. The live object allows developers to observe changes to the user's properties in real-time, ensuring that their app remains up-to-date with the latest user information.

{% tabs %}
{% tab title="iOS" %}
{% embed url="<https://gist.github.com/amythee/622081ba01cf57a18b4b36db2707844c>" %}
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/amythee/7b46a1e7362137feef90aa1db36b4862>" %}
{% endtab %}

{% tab title="JavaScript" %}
Follow the below code to retrieve a user object:

```javascript
import { UserRepository } from '@amityco/js-sdk';

const liveObject = UserRepository.getUser('userId');
liveObject.on('dataUpdated', user => {
  // user is successfully fetched
});
```

**Get Single User**

The User Repository provides a method to get a single user. It returns a LiveObject which you can observe.

```javascript
userRepo.userForId('user123')
```

You can also use the code below to get one user:

```typescript
let liveUser = UserRepository.getUser("some-user-id")
userObject.on(“dataUpdated”, model => {
   // you can access user object as model here
  console.log(model.userId, model.displayName)
})
```

**Get All Users**

The User Repository provides a method to get a list of all users, which will be returned as a LiveCollection:

```javascript
userRepo.getAllUsers()
```

This method takes an optional `sortBy` parameter which must be a `UserSortingMethod` - these include `displayName`, `firstCreated`, and `lastCreated`:

```javascript
import { UserSortingMethod } from '@amityco/js-sdk'

userRepo.getAllUsers(UserSortingMethod.DisplayName)
```

{% endtab %}

{% tab title="TypeScript" %}
{% embed url="<https://gist.github.com/amythee/9184aa74c7fe1773a027e81e54465871>" %}
{% endtab %}

{% tab title="Flutter" %}
{% embed url="<https://gist.github.com/amythee/6a732f6953a3cc445c2510b798fd3692>" %}
{% endtab %}
{% endtabs %}

To retrieve multiple users, you can use `getUserByIds` method provided by `UserRepository`. This method accepts a collection of `userId` as a parameter and returns a [Live Collection](/social-plus-sdk/core-concepts/live-objects-collections.md) of`AmityUser`.

{% tabs %}
{% tab title="iOS" %}
The functionality isn't currently supported by this SDK.
{% endtab %}

{% tab title="Android" %}
{% embed url="<https://gist.github.com/354656ab49ab513390cbe298cf84c70e>" %}
{% endtab %}

{% tab title="Javascript" %}
The functionality isn't currently supported by this SDK.
{% endtab %}

{% tab title="TypeScript" %}
{% embed url="<https://gist.github.com/amythee/f962d6f3bdaf473928882a3f6ddf900c>" %}
{% endtab %}

{% tab title="Flutter" %}
The functionality isn't currently supported by this SDK.
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.social.plus/social-plus-sdk/core-concepts/user/get-user-information.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
