Source: https://dinakar-rewind.docs.pageloop.ai/api-reference/listening/getlisteninggenres

# Genre breakdown

GET `https://api.rewind.rest/v1/listening/genres`

Returns a genre breakdown over time, grouped by period and designed for stacked bar charts.

## Authorization

#### Authorization (header, string, required)

API key. Read keys (rw\_live\_...) access GET endpoints. Admin keys (rw\_admin\_...) access all endpoints.

## Query Parameters

#### date (query, string)

Single day (YYYY-MM-DD). Overrides from/to.

#### from (query, string)

Range start, inclusive (ISO 8601)

#### to (query, string)

Range end, inclusive (ISO 8601)

#### group\_by (query, enum (string)) — allowed: week, month, year

#### limit (query, integer)

Max genres to return (rest grouped as "Other")

#### compare\_to (query, enum (string)) — allowed: previous\_year

When set to `previous_year`, returns a `compare` array with the same shape as `data` but for the window shifted back one year. Requires `from` + `to` or `date` to be set; ignored otherwise.

## Response

#### 200

Genre breakdown by period

#### data (array of object, required)

#### properties

#### period (string, required)

#### genres (object, required)

#### total (number, required)

#### compare (array of object)

#### properties

#### period (string, required)

#### genres (object, required)

#### total (number, required)

#### 401

Unauthorized

#### error (string, required)

#### status (integer, required)

#### Request

```bash cURL
curl -X GET 'https://api.rewind.rest/v1/listening/genres' \
  -H 'Authorization: Bearer <token>'
```

```javascript JavaScript
const res = await fetch('https://api.rewind.rest/v1/listening/genres', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer <token>',
  },
});
const data = await res.json();
```

```python Python
import requests

res = requests.get(
    'https://api.rewind.rest/v1/listening/genres',
    headers={'Authorization': 'Bearer <token>'}
)
data = res.json()
```

#### Response

```json 200
{
  "data": [
    {
      "period": "2025-01",
      "genres": {
        "Rock": 245,
        "Hip-Hop": 112,
        "Electronic": 87,
        "Other": 89
      },
      "total": 637
    }
  ],
  "compare": [
    {
      "period": "2025-01",
      "genres": {
        "Rock": 245,
        "Hip-Hop": 112,
        "Electronic": 87,
        "Other": 89
      },
      "total": 637
    }
  ]
}
```

```json 401
{
  "error": "Not found",
  "status": 404
}
```
