# Sentiment Per Topic

Returns sentiment breakdown by topic for a specific entity, including positive/negative/neutral counts and percentages per topic.

## Request

```
GET /v1/sentiment/per-topic
```

### Query Parameters

All [common filters](/getting-started/filtering.md) are supported, plus:

| Parameter   | Type              | Required | Default     | Description            |
| ----------- | ----------------- | -------- | ----------- | ---------------------- |
| `entity`    | string            | No       | Your brand  | Entity name to analyze |
| `startDate` | string (ISO 8601) | No       | 30 days ago | Start of date range    |
| `endDate`   | string (ISO 8601) | No       | Today       | End of date range      |
| `providers` | string\[]         | No       | All         | Filter by AI provider  |
| `topicIds`  | string\[]         | No       | All         | Filter by topic        |
| `countries` | string\[]         | No       | All         | Filter by country code |

## Response

### Success (200 OK)

```json
[
  {
    "entity": "Acme",
    "topics": [
      {
        "topic": "Industrial Automation",
        "totalMentions": 342,
        "distinctPrompts": 89,
        "positiveCount": 245,
        "negativeCount": 34,
        "neutralCount": 63,
        "positivePercentage": 71.6,
        "negativePercentage": 9.9,
        "neutralPercentage": 18.4,
        "sentimentScore": 80.8
      },
      {
        "topic": "Cloud Analytics",
        "totalMentions": 156,
        "distinctPrompts": 42,
        "positiveCount": 98,
        "negativeCount": 28,
        "neutralCount": 30,
        "positivePercentage": 62.8,
        "negativePercentage": 17.9,
        "neutralPercentage": 19.2,
        "sentimentScore": 72.4
      }
    ]
  }
]
```

### Fields

| Field                         | Type    | Description                                    |
| ----------------------------- | ------- | ---------------------------------------------- |
| `entity`                      | string  | Entity name                                    |
| `topics`                      | array   | Sentiment data per topic                       |
| `topics[].topic`              | string  | Topic name                                     |
| `topics[].totalMentions`      | integer | Total mentions in this topic                   |
| `topics[].distinctPrompts`    | integer | Number of unique prompts                       |
| `topics[].positiveCount`      | integer | Mentions with positive sentiment               |
| `topics[].negativeCount`      | integer | Mentions with negative sentiment               |
| `topics[].neutralCount`       | integer | Mentions with neutral sentiment                |
| `topics[].positivePercentage` | number  | Percentage of positive mentions                |
| `topics[].negativePercentage` | number  | Percentage of negative mentions                |
| `topics[].neutralPercentage`  | number  | Percentage of neutral mentions                 |
| `topics[].sentimentScore`     | number  | Overall sentiment score for this topic (0-100) |

## Examples

### curl

```bash
curl "https://app.limy.ai/api/v1/sentiment/per-topic?\
entity=Acme" \
  -H "X-API-Key: YOUR_API_KEY"
```

### Python

```python
response = requests.get(
    f"https://app.limy.ai/api/v1/sentiment/per-topic",
    headers={"X-API-Key": API_KEY},
    params={"entity": "Acme"}
)

for item in response.json():
    for topic in item['topics']:
        print(f"{topic['topic']}: score={topic['sentimentScore']}, "
              f"+{topic['positivePercentage']}% / -{topic['negativePercentage']}%")
```

### JavaScript

```javascript
const response = await fetch(
  `https://app.limy.ai/api/v1/sentiment/per-topic?entity=Acme`,
  { headers: { 'X-API-Key': API_KEY } }
);

const results = await response.json();
results[0].topics.forEach(t =>
  console.log(`${t.topic}: ${t.sentimentScore}/100 (${t.positivePercentage}% positive)`)
);
```


---

# 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://api-reference.limy.ai/analytics/overview-1/per-topic.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.
