> For the complete documentation index, see [llms.txt](https://dev.vulos.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.vulos.io/reference/identity-javascript-sdk/the-base-package/profile/profileapi.md).

# ProfileApi

{% hint style="info" %}
This class implements [`BaseApi`](/reference/identity-javascript-sdk/the-base-package/authentication/baseapi.md).
{% endhint %}

{% hint style="warning" %}
You need the [`profile:read`](/identity/scopes-and-claims.md#profile-read) scope to access this API.
{% endhint %}

{% hint style="info" %}
This is a JavaScript implementation of the [Profile API](/reference/profile-api.md).
{% endhint %}

{% hint style="info" %}
For ease of use we recommend using the [`User`](/reference/identity-javascript-sdk/the-base-package/authentication/user.md) object for interaction instead.
{% endhint %}

## Interfaces

### `OrganizationProfileInfoWithId`

```typescript
interface OrganizationProfileInfoWithId implements OrganizationProfileInfo {
    id: number
}
```

### `OrganizationProfileInfo`

```typescript
interface OrganizationProfileInfo {
    name: string,
    address?: string,
    city?: string,
    country?: string,
    state?: string,
    website?: string,
    verified?: boolean,
    uniqueId?: string,
    zipCode?: string
}
```

### `ProfileInfo`

```javascript
interface ProfileInfo {
    firstName?: string,
    lastName?: string,
    country?: { 
        alpha2: string,
        name: string
    },
    email?: {
        value: string,
        confirmed: boolean
    },
    kycVerified?: boolean,
    state?: string,
    profilePicture?: string
}
```

## Methods

### `constructor(user, endpoint)`

Create a Profile API object.

* `user` should be an instance of the [`User`](/reference/identity-javascript-sdk/the-base-package/authentication/user.md) object.
* `endpoint` should be the Vulos Identity endpoint.

```javascript
const profileApi = new ProfileApi(user, endpoint)
```

### `async info(id)`

Get an user's public profile by the user's ID.

The result implements the [`ProfileInfo`](#undefined) interface.

{% hint style="info" %}
This method's response has the `profile:info` [cache](/reference/identity-javascript-sdk/the-base-package/cache.md#addpolicy-key-lifespan) prefix.
{% endhint %}

```javascript
const userProfile = await profileApi.info(userId)
```

### `async organization(id)`

Get an organization's public profile by the organization's ID.

The result implements the [`OrganizationProfileInfo`](#organizationinfo) interface.

{% hint style="info" %}
This method's response has the `profile:organization` [cache](/reference/identity-javascript-sdk/the-base-package/cache.md#addpolicy-key-lifespan) prefix.
{% endhint %}

```javascript
const organizationProfile = await profileApi.organization(organizationId)
```

### `async organizationSearch(search, amount, offset)`

Search for an organization by name using a string.

* `search` is the string we are searching with in the organization's name;
* `amount` is the maximal amount of elements that can be returned (absolute maximal is `100`, default is `10`), this argument is optional;
* `offset` is the amount of organizations that will get skipped in the result (default is `0`), this argument is optional;

The result implements the [`OrganizationProfileInfoWithId`](#organizationprofileinfowithid) interface.

{% hint style="info" %}
This method's response has the `profile:organization:search` [cache](/reference/identity-javascript-sdk/the-base-package/cache.md#addpolicy-key-lifespan) prefix.
{% endhint %}

```javascript
const [bestMatch] = await profileApi.organizationSearch('Example')

// ... or

let pageIndex = 0
const organizationsPerPage = 5

const nextPage = async () => {
    const organizations = await profileApi.organizationSearch(
        'Example',
         organizationsPerPage,
         organizationsPerPage * pageIndex)
     pageIndex++
     return organizations
 }
 
let currentPage

while(currentPage = await nextPage()) {
    // do something with the current page
}

```
