# Use the Site Reputation SDK

## Querying Site Reputation

The **Site Reputation SDK** enables you to warn or guard your users from accessing low reputation websites. The `getSiteReputation` function of the SDK returns a `SiteReputation` structure with attributes you can use to form a decision on whether to block access to a site or display a warning to your users.

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

```typescript
// const client = new SudoSiteReputationClient({...})

import {
  SiteReputation
} from '@sudoplatform/sudo-site-reputation'

let siteReputation: SiteReputation
try {
  siteReputation = client.getSiteReputation('https://sudoplatform.com')
  console.log(siteReputation.reputationStatus)
} catch (error) {
  // implement error handling
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
var client: SudoSiteReputationClient!

let uri = "http://www.wikipedia.com"
let result = try await instance.getSiteReputation(url: uri)
switch result.status {
case .notMalicious:
    break
case .malicious:
    break
case .unkown:
    break
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
// val client: SudoSiteReputationClient

launch {
    try {
        val siteReputation = withContext(Dispatchers.IO) {
            client.getSiteReputation(
                url = "http://somedodgyhost.com/somewhere"
            )
        }
        if (badSite.status == SudoSiteReputation.MaliciousState.MALICIOUS) {
           System.out.println("This page is bad mkay")
        } 
    } catch (e: SudoSiteReputationException) {
        // Handle/notify user of exception
    }
}
```

{% endtab %}
{% endtabs %}

## SiteReputation Interface

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

```typescript
/**
 * The state of knowledge of a site's reputation.
 */
export type ReputationStatus = 'NOTMALICIOUS' | 'MALICIOUS' | 'UNKNOWN'

/**
 * The response of a given url's site reputation.
 */
export interface SiteReputation {
  /** Returns `MALICIOUS` if malicious, `NOTMALICIOUS` if not, and `UNKNOWN` if unable to be determined. */
  reputationStatus: ReputationStatus
}

```

{% endtab %}

{% tab title="Swift" %}

```swift
public struct SiteReputation {
    
    /// Search status
     public enum ReputationStatus {
         // URI not in dataset as not malicious
         case notMalicious
         // URI found in dataset as malicious
         case malicious
         // URI not found in the dataset
         case unkown
    }

    /// The returned result of the lookup for the site. If .success you can expect the other properties to be non nil.
    public let status: ReputationStatus
}
```

{% endtab %}

{% tab title="Kotlin" %}

<pre class="language-kotlin"><code class="lang-kotlin">public data class SiteReputation(
    /** status of the search */
    val status: ReputationStatus,
) : Parcelable {

    enum class ReputationStatus {
        /** site is <a data-footnote-ref href="#user-content-fn-1">known</a> to be malicious */
        MALICIOUS,
        /** site is not known to be malicious */
        NOTMALICIOUS,
        /** no site data available to make a determination */
        UNKNOWN
    }
}
</code></pre>

{% endtab %}
{% endtabs %}

[^1]:
