> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://www.comet.com/docs/opik/llms.txt.

# Get a project's topics

GET http://localhost:5173/api/v1/private/topics

The project's topics over the window, the last topics.run.windowDays UTC days (default 30), today included: per topic its count, share, rank and a daily series, plus Other's daily series. Counts can be up to 5 minutes old. status is disabled when the workspace is not opted in to topics, collecting while the project has no topics yet, too_large when a ClickHouse read hit a rows, bytes or memory guard (a retry answers the same, so do not retry), and ready otherwise. Fields of other states are omitted.

Reference: https://www.comet.com/docs/opik/reference/rest-api/topics/get-project-topics

## Servers

- `http://localhost:5173/api` (Local server, default)
- `https://www.comet.com/opik/api` (Opik Cloud)

## Request

### Query parameters

- `project_id` (string, required)

## Response

### 200

The project's topics, or status too_large when a read hit a size guard

- `status` (enum, optional) — disabled: the workspace is not opted in to topics. collecting: the project has no topics yet. ready: topics with counts. too_large: the project has too many traces in the window to count; a retry answers the same
  - Allowed values: `disabled`, `collecting`, `ready`, `too_large`
- `today` (date, optional) — The UTC date of the request, the window's last day
- `window_from` (date, optional) — The window's first UTC day, inclusive
- `last_run_at` (datetime, optional) — When the project's last saved run (a discovery run or a nightly update) finished; omitted before the first one
- `attempt` (Attempt, optional) — collecting only: the project's newest run when it is running or failed; omitted when it saved or there is none. The runbook's 'Reading topics' section tells the collecting cases apart
- `vectors_in_window` (long, optional) — collecting only: traces with a vector in the window
- `min_vectors` (long, optional) — collecting only: traces with a vector the discovery run needs
- `total_traces` (long, optional) — ready only: traces with a topic in the window, Other included
- `labelled_from` (date, optional) — ready only: the first day in the window with a labelled trace; earlier days are 0 because nothing was labelled. Omitted when the window has none
- `topics` (list of TopicStats, optional) — The live topics in rank order; empty unless ready
- `other` (OtherStats, optional) — ready only: the traces per day with no topic, or with a topic that is no longer live. Add it to the topics' series for the project's total per day

## Errors

### 400 Bad Request Error

No project_id

- `code` (integer, optional)
- `message` (string, optional)
- `details` (string, optional)

### 401 Unauthorized Error

Unauthorized

- `code` (integer, optional)
- `message` (string, optional)
- `details` (string, optional)

### 403 Forbidden Error

Access forbidden

- `code` (integer, optional)
- `message` (string, optional)
- `details` (string, optional)

### 404 Not Found Error

The project is not in the workspace

- `code` (integer, optional)
- `message` (string, optional)
- `details` (string, optional)

### 429 Too Many Requests Error

Too many requests

- `code` (integer, optional)
- `message` (string, optional)
- `details` (string, optional)

### 501 Not Implemented Error

Topics are off

- `any`

### 503 Service Unavailable Error

ClickHouse is busy: a read hit its time guard or topics.read.budget; retry after Retry-After

- `code` (integer, optional)
- `message` (string, optional)
- `details` (string, optional)

## Types

### Attempt

collecting only: the project's newest run when it is running or failed; omitted when it saved or there is none. The runbook's 'Reading topics' section tells the collecting cases apart

- `status` (enum, optional) — running: the run started and has not ended. failed: it ended without saving
  - Allowed values: `running`, `failed`

### TopicStats

The live topics in rank order; empty unless ready

- `id` (string, optional) — The topic id, the value the traces filter uses
- `name` (string, optional) — The topic's name
- `definition` (string, optional) — What the topic's traces are about
- `born` (date, optional) — The UTC date the topic was made: for a discovery run's topics, the day the run started
- `is_new` (boolean, optional) — Born after the project's discovery run, in the last 7 days
- `count` (long, optional) — Traces of the topic in the window
- `share` (double, optional) — count / total_traces, from 0 to 1, not rounded
- `rank` (integer, optional) — 1-based: topics by count, most first, then the earlier born, then the id
- `series` (list of DayCount, optional) — One entry per day of the window, oldest first, today last

### OtherStats

ready only: the traces per day with no topic, or with a topic that is no longer live. Add it to the topics' series for the project's total per day

- `series` (list of DayCount, optional) — One entry per day of the window, oldest first, today last

### DayCount

One entry per day of the window, oldest first, today last

- `day` (date, optional) — A UTC date
- `count` (long, optional) — Traces created on the day

## Examples

**Response**

```json
{
  "status": "disabled",
  "today": "2023-01-15",
  "window_from": "2023-01-15",
  "last_run_at": "2024-01-15T09:30:00Z",
  "attempt": {
    "status": "running"
  },
  "vectors_in_window": 1,
  "min_vectors": 1,
  "total_traces": 1,
  "labelled_from": "2023-01-15",
  "topics": [
    {
      "id": "string",
      "name": "string",
      "definition": "string",
      "born": "2023-01-15",
      "is_new": true,
      "count": 1,
      "share": 1.1,
      "rank": 1,
      "series": [
        {
          "day": "2023-01-15",
          "count": 1
        }
      ]
    }
  ],
  "other": {
    "series": [
      {
        "day": "2023-01-15",
        "count": 1
      }
    ]
  }
}
```

**SDK Code**

```python
import requests

url = "http://localhost:5173/api/v1/private/topics"

querystring = {"project_id":"project_id"}

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

print(response.json())
```

```javascript
const url = 'http://localhost:5173/api/v1/private/topics?project_id=project_id';
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 := "http://localhost:5173/api/v1/private/topics?project_id=project_id"

	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("http://localhost:5173/api/v1/private/topics?project_id=project_id")

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

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("http://localhost:5173/api/v1/private/topics?project_id=project_id")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'http://localhost:5173/api/v1/private/topics?project_id=project_id');

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

```csharp
using RestSharp;

var client = new RestClient("http://localhost:5173/api/v1/private/topics?project_id=project_id");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "http://localhost:5173/api/v1/private/topics?project_id=project_id")! 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()
```