> For the complete documentation index, see [llms.txt](https://docs.sudoplatform.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sudoplatform.com/guides/digital-account-protection/data-holder-analysis.md).

# Data Holder Analysis

An analysis result contains a structured privacy analysis for a specific data holder. Analysis results are generated automatically as data holders are discovered.

Each analysis result summarizes how a data holder collects, retains, and shares user data based on their publicly available privacy policy and other documents.

### Listing Analysis Results <a href="#listing-analysis-results" id="listing-analysis-results"></a>

To retrieve all analysis results associated with a specific virtual presence, use the `listAnalysisResults` method. Results are paginated.

A call to `listAnalysisResults` returns a `ListOutput` object containing a list of matching `items` and a `nextToken` to support pagination. If no results are found, the result will contain empty items. Always check the value of the returned `nextToken` since there are more results to retrieve when `nextToken` is defined.

{% tabs %}
{% tab title="Typescript" %}

```typescript
try {
  let nextToken: string | undefined = undefined
  do {
    const listOutput = await privacyInteractionClient.listAnalysisResults({
      virtualPresenceId: 'virtual-presence-id',
      limit: 20,
      nextToken,
    })

    for (const analysisResult of listOutput.items) {
      console.log(analysisResult.dataHolderIdentifier, analysisResult.status)
    }

    nextToken = listOutput.nextToken
  } while (nextToken !== undefined)
} catch (error) {
  // Handle/notify user of errors
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
do {
    var nextToken: String?
    repeat {
        let listOutput = try await privacyInteractionClient.listAnalysisResults(
            withInput: ListAnalysisResultsInput(
                virtualPresenceId: "virtual-presence-id",
                limit: 20,
                nextToken: nextToken
            )
        )

        for analysisResult in listOutput.items {
            print(analysisResult.dataHolderIdentifier, analysisResult.status)
        }

        nextToken = listOutput.nextToken
    } while nextToken != nil
} catch {
    // Handle/notify user of errors
}

```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
launch {
    try {
        var nextToken: String? = null
        do {
            val listOutput = withContext(Dispatchers.IO) {
                privacyInteractionClient.listAnalysisResults(
                    ListAnalysisResultsInput(
                        virtualPresenceId = "virtual-presence-id",
                        limit = 20,
                        nextToken = nextToken,
                    ),
                )
            }
            for (analysisResult in listOutput.items) {
                println("${analysisResult.dataHolderIdentifier} ${analysisResult.status}")
            }
            nextToken = listOutput.nextToken
        } while (nextToken != null)
    } catch (e: AnalysisResultException) {
        // Handle/notify user of errors
    }
}

```

{% endtab %}
{% endtabs %}

**Input Parameters:**

| Parameter           | Type   | Required | Description                                                          |
| ------------------- | ------ | -------- | -------------------------------------------------------------------- |
| `virtualPresenceId` | string | Yes      | The identifier of the virtual presence to list analysis results for. |
| `limit`             | number | No       | Maximum number of items to return. Will be defaulted if omitted.     |
| `nextToken`         | string | No       | A pagination token from a previous call.                             |

### Retrieving an Analysis Result <a href="#retrieving-an-analysis-result" id="retrieving-an-analysis-result"></a>

To retrieve a full analysis result by its unique identifier, use the `getAnalysisResult` method. This returns the analysis result if it exists, or `undefined` if not found. Analysis result identifiers will be provided in subscription update notifications, or can be retrieved from the `listAnalysisResults` method.

{% tabs %}
{% tab title="Typescript" %}

```typescript
try {
  const analysisResult = await privacyInteractionClient.getAnalysisResult(
    analysisResultId,
  )
  if (analysisResult) {
    console.log(analysisResult.status)
    if (analysisResult.data) {
      console.log('Privacy score:', analysisResult.data.privacyScore?.score)
      console.log('Summary:', analysisResult.data.privacySummary.bulletPoints)
    }
  }
} catch (error) {
  // Handle/notify user of errors
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
do {
    if let analysisResult = try await privacyInteractionClient.getAnalysisResult(withId: analysisResultId) {
        print(analysisResult.status)
        if let data = analysisResult.data {
            print("Privacy score:", data.privacyScore?.score ?? "n/a")
            print("Summary:", data.privacySummary.bulletPoints)
        }
    }
} catch {
    // Handle/notify user of errors
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
launch {
    try {
        val analysisResult = withContext(Dispatchers.IO) {
            privacyInteractionClient.getAnalysisResult(analysisResultId)
        }
        if (analysisResult != null) {
            println(analysisResult.status)
            val data = analysisResult.data
            if (data != null) {
                println("Privacy score: ${data.privacyScore?.score}")
                println("Summary: ${data.privacySummary.bulletPoints}")
            }
        }
    } catch (e: AnalysisResultException) {
        // Handle/notify user of errors
    }
}
```

{% endtab %}
{% endtabs %}

The `data` field is populated when the analysis result status is `COMPLETE` or `PARTIAL`. For other statuses, `data` will be undefined.

#### Analysis Result Object

| Property               | Type                            | Description                                                                                                                                           |
| ---------------------- | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                   | string                          | Unique identifier for the analysis result.                                                                                                            |
| `owner`                | string                          | Unique identifier of the user.                                                                                                                        |
| `virtualPresenceId`    | string                          | The virtual presence this analysis is associated with.                                                                                                |
| `dataHolderIdentifier` | string                          | The data holder domain this analysis is about.                                                                                                        |
| `status`               | AnalysisResultStatus            | Current status of the analysis. See [Analysis Status](#analysis-result-status).                                                                       |
| `lastAnalyzedAt`       | Date                            | When the analysis was last performed.                                                                                                                 |
| `data`                 | AnalysisResultData \| undefined | Structured analysis data, populated when status is `COMPLETE` or `PARTIAL`. See [Analysis Data](/guides/digital-account-protection/analysis-data.md). |
| `version`              | number                          | Entity version, increments on update.                                                                                                                 |
| `createdAt`            | Date                            | When the analysis result was created.                                                                                                                 |
| `updatedAt`            | Date                            | When the analysis result was last updated.                                                                                                            |

#### Subscribing to Analysis Result Updates

To receive real-time notifications when analysis results are created, change status or are updated, see [Subscriptions](https://docs.sudoplatform.com/~/revisions/U8P5YQbTWlABRqHUlUfP/guides/privacy-interaction/subscriptions).
