---
title: "Histogram"
method: GET
path: "/topics/{topicId}/statistics/histogram"
tags: ["Statistics"]
---

# Histogram

`GET /topics/{topicId}/statistics/histogram`

## Request

- Base URL: `https://api.youscan.io/api/external`
- URL: `https://api.youscan.io/api/external/topics/{topicId}/statistics/histogram`
- Auth: one of:
  - API key in header `X-API-KEY`
  - API key in query parameter `apiKey`
- TypeScript: <https://skmtc.dev/youscan/apis/youscan-api/docs/topics/:topicId/statistics/histogram/get.ts> (a function with typed inputs; its response is checked against the schema)

Mentions count, authors count, engagement, and optionally sentiment per date interval for a period. When `interval` is `day`, the requested period must be less than 3 months.

## Path parameters

- `topicId` integer, required

## Query parameters

- `from` string, date
- `to` string, date
- `interval` 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year'
- `sentiment` boolean
- `country` string[]
- `excludeCountry` string[]
- `sourceTypes` SourceTypeFilter[]
- `excludeSourceTypes` SourceTypeFilter[]
- `sources` string[]
- `excludeSources` string[]
- `tags` integer[]
- `excludeTag` integer[]
- `subcategories` integer[]
- `excludeSubcategory` integer[]

## Response `200`

Histogram data.

- object
  - `dates` object[]
    - `key` string, date-time: Start of the interval.
    - `count` integer
    - `authorsCount` integer
    - `engagement` integer
    - `sentiment` object: Present when the `sentiment` parameter is `true`.
      - `positive` integer
      - `neutral` integer
      - `negative` integer
  - `authorsCount` integer: Total unique authors for the period.
  - `engagement` integer: Total engagement for the period.
  - `totalCount` integer

## Other responses

- `400`: The request is invalid.
- `401`: The API key is missing or invalid.

---

[API](https://skmtc.dev/youscan/apis/youscan-api.md) - [All operations](https://skmtc.dev/youscan/apis/youscan-api/llms.txt) - [OpenAPI document](https://skmtc.dev/youscan/apis/youscan-api/revisions/f5bef260f153?raw)
