# Helpers

## $app

{% hint style="info" %}
Only available in the UI context.
{% endhint %}

```typescript
$ui.register((ctx) => {

    $app.getVersion() // "3.7.0"
    $app.getVersionName() // "Gold"
    
    // Invalidate certain queries to cause the client to refetch them automatically
    // Find the query keys here: https://github.com/5rahim/seanime/blob/main/internal/events/endpoints.go
    $app.invalidateClientQuery([])
    
    $app.getClientIds() // Returns the client IDs
    $app.getClientPlatform("id") // Returns the platform, "web", "denshi"

})
```

## Client Helpers

### getClientIds

`$app.getClientIds()`

Returns the IDs of the UI clients currently connected to Seanime.

This is useful for APIs that accept a `clientId`, such as torrent/debrid streaming when you want to target a specific client.

**Example:**

```typescript
const clientIds = $app.getClientIds()

for (const clientId of clientIds) {
    console.log(clientId, $app.getClientPlatform(clientId))
}
```

### getClientPlatform

`$app.getClientPlatform(clientId)`

Returns the platform for a connected client.

Typical values are `"web"` and `"denshi"`. If the client is unknown, Seanime returns an empty string.

**Parameters:**

* `clientId`: String - A client ID returned by `$app.getClientIds()`

**Example:**

```typescript
const denshiClientIds = $app
    .getClientIds()
    .filter((clientId) => $app.getClientPlatform(clientId) === "denshi")

console.log(denshiClientIds)
```


---

# Agent Instructions: 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:

```
GET https://seanime.gitbook.io/seanime-extensions/plugins/apis/helpers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
