# Get an analytics time series

> Source: https://truto.one/docs/api-reference/admin/analytics/timeseries/

`GET /analytics/timeseries`

Resource: **Analytics**

## Query parameters

- **`environment_id`** _(string, required)_
  The environment to report on. The caller must belong to it.
- **`metric`** _(string, required)_
- **`from`** _(string)_
  Defaults to 30 days before `to`.
- **`to`** _(string)_
  Defaults to today.
- **`granularity`** _(string)_
  `hour` covers at most 7 days, for a metric with hourly data (see `GET /analytics/metrics`).
  Allowed: `day`, `hour`
- **`group_by`** _(string)_
- **`filter`** _(object)_

## Response body

- **`environment_id`** _(string)_
- **`metric`** _(string)_
- **`unit`** _(string)_
- **`kind`** _(string)_
- **`granularity`** _(string)_
- **`from`** _(string)_
- **`to`** _(string)_
- **`buckets`** _(array<string>)_
- **`series`** _(array<object>)_
  - **`key`** _(string)_
  - **`values`** _(array<number>)_
  - **`total`** _(number)_

## Code examples

### curl

```bash
curl -X GET 'https://api.truto.one/analytics/timeseries' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json'
```

### JavaScript

```javascript
const response = await fetch('https://api.truto.one/analytics/timeseries', {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/analytics/timeseries"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
}

response = requests.get(url, headers=headers, params=params)
print(response.json())
```
