> For the complete documentation index, see [llms.txt](https://ryan-44.gitbook.io/portrait/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ryan-44.gitbook.io/portrait/portrait-sdk/portrait-class/read/getportrait.md).

# getPortrait()

The `getPortrait()` function is used to get a user's or collective's Portrait object, which contains the user's or collective's Portrait data. The `portraitObject` is fetched from IPFS and Arweave concurrently to ensure the quickest resolving possible.

### Syntax

```typescript
getPortrait(identity: Identity): Promise<PortraitObject>
```

#### Parameters

* `identity` - A required parameter of type `Identity`. `Identity` is of type:
  * `UserPortraitAddress` - Ethereum address
  * `UserPortraitENSName` - ENS name
  * `CollectivePortraitName` - Collective Portrait Name (a-z, 0-9, min. 3 chars, max. 64 chars.)

#### Return Value

* This function returns a `Promise` that resolves with a `PortraitObject` if the user or collective has a Portrait. If the user or collective does not have a Portrait, the function returns a `Promise` that resolves with `null`.

#### Usage

This function is useful in situations where you need to retrieve the Portrait data for a given user or collective. The function takes an identity as input, which can be either an Ethereum address, an ENS name, or a Collective Portrait name. The function determines the type of the input identity and retrieves the Portrait object accordingly.

The function uses the `getPortraitHash()` method internally to retrieve the hash of the user's or collective's Portrait. Once the hash is retrieved, the function calls the `fetchPortrait()` function to retrieve the Portrait object from IPFS.

#### Example

```typescript
import { Portrait } from 'portrait-sdk';

const portrait = new Portrait();

const identity = 'vitalik.eth'; // ENS name

portrait.getPortrait(identity)
  .then((portraitObject) => {
    if (portraitObject) {
      console.log(`The Portrait data for ${identity} is`, portraitObject);
    } else {
      console.log(`${identity} does not have a Portrait`);
    }
  })
  .catch((error) => {
    console.error(error);
  });
```

In this example, the `getPortrait()` function is used to retrieve the Portrait object for the given ENS name. If the user has a Portrait, the function logs the Portrait object to the console. If the user does not have a Portrait, the function logs a message indicating that the user does not have a Portrait.
