> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Pobierz tematy rozmów agenta

GET https://api.elevenlabs.io/v1/convai/agents/{agent_id}/topics

Zwraca wyniki najnowszego uruchomienia wykrywania tematów dla danego agenta.

Reference: https://elevenlabs.io/docs/eleven-agents/api-reference/conversations/topics/get

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Path parameters

- `agent_id` (string, required) — ID agenta

### Query parameters

- `page_size` (integer, optional) — Liczba grup tematów najwyższego poziomu do zwrócenia.
- `sort_by` (enum, optional) — Kolumna do rankingu tematów. Użyj conversations dla liczby rozmów, sentiment z sort_direction=asc dla najbardziej negatywnych tematów oraz frustration z sort_direction=desc dla tematów wywołujących największą frustrację. Tematy bez oceny zawsze trafiają na koniec rankingu.
  - Allowed values: `conversations`, `sentiment`, `success_rate`, `frustration`
- `sort_direction` (enum, optional) — Kierunek sortowania tematów.
  - Allowed values: `asc`, `desc`
- `from_unix_secs` (integer, optional) — Początek przedziału wyświetlania tematów. W połączeniu z to_unix_secs ukończone dzienne wykonania wykrywania tematów z tego zakresu są agregowane, więc przedział określa metryki i zestaw tematów. Wartość jest zaokrąglana w dół do początku dnia UTC, ponieważ wykonania obejmują całe dni UTC; aggregated_run_count podaje liczbę zsumowanych wykonań. Pomiń obie granice, aby pobrać jedno najnowsze wykonanie.
- `to_unix_secs` (integer, optional) — Koniec przedziału czasu, dla którego wyświetlane są tematy.
- `include_evaluation_criteria` (boolean, optional, default: true) — Uwzględnia podział oceny według kryteriów w metrykach każdego tematu. Przekaż false, aby go pominąć: stanowi większość danych, a ważony success_rate jest zwracany w obu przypadkach.
- `cursor` (string, optional) — Służy do pobrania następnej strony. Kursor jest zwracany w odpowiedzi.

## Response

### 200

Pomyślna odpowiedź

- `topics` (list of AgentTopicResponseModel, required)
- `window_start_unix_secs` (integer, required)
- `window_end_unix_secs` (integer, required)
- `aggregated_run_count` (integer, optional, default: 0) — Liczba dziennych uruchomień wykrywania tematów, dla których zsumowano zwrócone metryki.
- `has_more` (boolean, optional, default: false)
- `next_cursor` (string, optional)

## Errors

### 422 Topics Get Request Unprocessable Entity Error

Błąd walidacji

- `detail` (list of ValidationError, optional)

## Types

### AgentTopicResponseModel

- `topic_id` (string, required)
- `label` (string, required)
- `description` (string, required)
- `conversation_count` (integer, required)
- `parent_topic_id` (string, optional)
- `x_2d` (double, optional)
- `y_2d` (double, optional)
- `metrics` (TopicMetricsAggregate, optional)
- `success_rate` (double, optional) — Wskaźnik sukcesu dla kryteriów oceny tematu, ważony ocenionymi rozmowami. Zwracany niezależnie od include_evaluation_criteria.

### ValidationError

- `loc` (list of ValidationErrorLocItem, required)
- `msg` (string, required)
- `type` (string, required)

### TopicMetricsAggregate

- `conversation_count` (integer, optional, default: 0)
- `sentiment` (TopicSentimentAggregate, optional)
- `evaluation_criteria` (list of TopicEvaluationCriteriaAggregate, optional)

### ValidationErrorLocItem

- string
- integer

### TopicSentimentAggregate

- `sentiment` (NumericDistributionAggregate, optional)
- `frustration` (NumericDistributionAggregate, optional)
- `positive_count` (integer, optional, default: 0)
- `neutral_count` (integer, optional, default: 0)
- `negative_count` (integer, optional, default: 0)

### TopicEvaluationCriteriaAggregate

- `criteria_id` (string, required)
- `success_count` (integer, optional, default: 0)
- `failure_count` (integer, optional, default: 0)
- `unknown_count` (integer, optional, default: 0)

### NumericDistributionAggregate

- `count` (integer, optional, default: 0)
- `sum` (double, optional, default: 0)
- `min` (double, optional)
- `max` (double, optional)

## Examples

**Response**

```json
{
  "topics": [
    {
      "topic_id": "topic_id",
      "label": "label",
      "description": "description",
      "conversation_count": 1,
      "parent_topic_id": "parent_topic_id",
      "x_2d": 1.1,
      "y_2d": 1.1,
      "success_rate": 1.1
    }
  ],
  "window_start_unix_secs": 1,
  "window_end_unix_secs": 1,
  "aggregated_run_count": 1,
  "has_more": true,
  "next_cursor": "next_cursor"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/convai/agents/agent_id/topics"

querystring = {"cursor":"cursor","from_unix_secs":"1","include_evaluation_criteria":"true","page_size":"1","sort_by":"conversations","sort_direction":"asc","to_unix_secs":"1"}

response = requests.get(url, params=querystring)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/convai/agents/agent_id/topics?cursor=cursor&from_unix_secs=1&include_evaluation_criteria=true&page_size=1&sort_by=conversations&sort_direction=asc&to_unix_secs=1';
const options = {method: 'GET'};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/convai/agents/agent_id/topics?cursor=cursor&from_unix_secs=1&include_evaluation_criteria=true&page_size=1&sort_by=conversations&sort_direction=asc&to_unix_secs=1"

	req, _ := http.NewRequest("GET", url, nil)

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.elevenlabs.io/v1/convai/agents/agent_id/topics?cursor=cursor&from_unix_secs=1&include_evaluation_criteria=true&page_size=1&sort_by=conversations&sort_direction=asc&to_unix_secs=1")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api.elevenlabs.io/v1/convai/agents/agent_id/topics?cursor=cursor&from_unix_secs=1&include_evaluation_criteria=true&page_size=1&sort_by=conversations&sort_direction=asc&to_unix_secs=1")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/convai/agents/agent_id/topics?cursor=cursor&from_unix_secs=1&include_evaluation_criteria=true&page_size=1&sort_by=conversations&sort_direction=asc&to_unix_secs=1');

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/convai/agents/agent_id/topics?cursor=cursor&from_unix_secs=1&include_evaluation_criteria=true&page_size=1&sort_by=conversations&sort_direction=asc&to_unix_secs=1");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/convai/agents/agent_id/topics?cursor=cursor&from_unix_secs=1&include_evaluation_criteria=true&page_size=1&sort_by=conversations&sort_direction=asc&to_unix_secs=1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```