> For the complete documentation index, see [llms.txt](https://lionstudios.gitbook.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lionstudios.gitbook.io/readme/features/whoami-service.md).

# WhoAmI Service

### **Initialization**

Initialization runs automatically at startup.

During the first session, the service requests data from the **Location** and **Adjust APIs**. These requests may take several seconds, so wait for initialization to complete before using the returned data.

After each service completes its first successful request, its data is refreshed once per day. The refresh interval can be configured with:

`public int FetchRefresh = 86400;`

The refresh does not run while the app remains open.

Location data is also updated each session through the Global Config Handler for legal restriction checks.

***

## Usage

The following methods are available to use. Each return different information about the player.

### Retrieving Full Player Data

Use `WhoAmIService.GetDataAsync(bool useCache)` to retrieve the complete set of available WhoAmI data for a player.

```
WhoAmIData whoAmIData = await WhoAmIService.GetDataAsync(true);
```

Returned response:

```
{
  "LastSuccessfulFetch": 1762390275,
  "CustomId": "nakama_123",
  "DeviceId": "8605F947-5B71-588B-8E26-1AFFE2F90480",
  "AdjustInfo": {
    "AdId": "123",
    "AttributionInfo": {
      "Campaign": "test_campaign_roas"
    }
  },
  "LocationInfo": {
    "countryName": "United States",
    "countryCode": "US",
    "regionName": "Nevada",
    "regionCode": "NV"
  }
}
```

{% hint style="success" %}
Use `useCache` parameter value as `true` in most cases to return cached data immediately after the first successful fetch. Set it to `false` only when you need to bypass the cache and request fresh data from the APIs.
{% endhint %}

### Retrieving Cached Player Data

Use `WhoAmIService.GetDataCache` to retrieve the most recently saved WhoAmI data immediately.

```
WhoAmIData whoAmIData = WhoAmIService.GetDataCache();
```

This method is synchronous and does not wait for initialization or an API request to complete.

{% hint style="warning" %}
Some fields may be empty when initialization has not completed or no previous fetch has succeeded. Use this method only when incomplete data is acceptable or you know that cached data is available
{% endhint %}

### Retrieving Location Information

Use `WhoAmIService.GetLocationInfoAsync` when you only need the player's location.

```
LocationInfo locationInfo =
    await WhoAmIService.GetLocationInfoAsync(useCache: true);
```

Location data can become available before the complete WhoAmI request finishes because this method does not wait for Adjust data.

Example response:

```
{
  "countryName": "United States",
  "countryCode": "US",
  "regionName": "Nevada",
  "regionCode": "NV"
}
```

### Retrieving Adjust Information

Use `WhoAmIService.GetAdjustInfoAsync` to retrieve the player's Adjust ADID and attribution information.

```
AdjustInfo adjustInfo = await WhoAmIService.GetAdjustInfoAsync();
```

Example response:

```
{
  "AdjustInfo": {
    "AdId": "123",
    "AttributionInfo": {
      "Campaign": "test_campaign_roas"
    }
  }
}
```

{% hint style="warning" %}
Adjust attribution may take longer than other WhoAmI data to become available. This method does not apply a timeout. If Adjust cannot retrieve the data, an empty `AdjustInfo` object is returned.
{% endhint %}

### Retrieving a Persistent Player ID

Use `WhoAmIService.GetPersistentIdAsync` to retrieve an Adjust ADID associated with this user. This is persistent between app uninstalls so can be used for backend authorization.

Value is cached after first successful retrieval.

```
string playerId = await WhoAmIService.GetPersistentIdAsync();
```

In the Unity Editor, the device ID is returned instead.

To access the device ID directly, use:

```
string deviceId = whoAmIData.DeviceId;
```

### Retrieving the Current Platform

Use `WhoAmIService.GetPlatform` to retrieve the current runtime platform as a lowercase string.

Possible valuesa are "android", "ios", or null.

```
string platform = WhoAmIService.GetPlatform();
```

***

## Advanced Usage

#### Error Handling

WhoAmI automatically retries failed requests using exponential backoff, up to a maximum delay of 64 seconds.

Calls for location, Adjust data, or the persistent player ID will wait until the required data is available. No custom retry logic is needed—simply await the provided async method.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://lionstudios.gitbook.io/readme/features/whoami-service.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
