# Bot Statistics Data

This endpoint can be used to retrieve statistics data for a specific chatbot. The data you can retrieve with this API endpoint is identical to the data available in live [dashboards](https://docs.mylinkconnect.com/analytics/dashboards).

### Request

The following request will retrieve statistics data:

```bash
curl --location --request GET 
'https://publicapi.xenioo.com/analytics/statistics/<TYPES>/<GROUPMODE>/<DAYS>' \
--header 'Authorization: Bearer <BOT_AUTH_TOKEN>' \
--header 'Content-Type: application/json'
```

### Parameters

The following parameters are expected on the endpoint:

| Parameter | Description                                                                                                   |
| --------- | ------------------------------------------------------------------------------------------------------------- |
| TYPES     | A comma separated list of all the possible types of analytic endpoints available. See belo table and example. |
| GROUPMODE | The time group mode for the returned values. Sett below table for possible values                             |
| DAYS      | The amount of history days to return. Acceptable values go from 1 to 30 days of history.                      |

Supported types are as follows:

| Type                        | Code |
| --------------------------- | ---- |
| New User                    | 0    |
| Returning User              | 1    |
| Active User                 | 2    |
| Messages                    | 3    |
| Action Messages             | 4    |
| Fallback Reply              | 5    |
| NLP Detected                | 6    |
| NLP Missed                  | 7    |
| Conversation Length         | 8    |
| Time To Pick Up             | 9    |
| Takeover Rate               | 10   |
| Support Conversation Length | 11   |
| Goal Reached                | 12   |
| Incoming Message            | 13   |
| API Request                 | 14   |
| API Request Error           | 15   |
| Time To First Message       | 16   |
| Operator Message            | 17   |
| Tag Hit                     | 18   |

Time grouping modes can be instead one of the following:

| Value | Description             |
| ----- | ----------------------- |
| hour  | Group entries by hours  |
| day   | Group entries by days   |
| month | Group entries by months |
| year  | Group entries by years  |

### Response

If successful, the response will contain a detailed array of statistical data.

```javascript
[
   {
      "GroupLabel":"...",
      "BotName":"...",
      "ChannelName":"...",
      "EventLabel":"...",      
      "EventData":"...",
      "IsPreviousPeriod":false,
      "GoalId":"...",
      "GoalName":"...",
      "ReferenceValue":0,
   } 
]
```

### Response Codes

This endpoint will reply with the following standard HTTP codes.

| Code | Meaning                                                      |
| ---- | ------------------------------------------------------------ |
| 200  | Ok. The request has been successfully fulfilled.             |
| 404  | Not Found. The specified  account or bot has not been found. |
