> For the complete documentation index, see [llms.txt](https://everyday-digital.gitbook.io/falkor-dev-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://everyday-digital.gitbook.io/falkor-dev-docs/analytics/realtime.md).

# Realtime

The Realtime endpoint allows viewing analytics of real-time users and interactions with a maximum 7 day range. This end point allows real-time analytics to be viewed for Apps, Stories, Pathways OR Streams. &#x20;

## Available Realtime Endpoints

`v1/analytics/realtime/apps`\
Get real-time analytics for an app or a list of apps.

`v1/analytics/realtime/pathways`\
Get real-time analytics for a pathways or a list of pathways.

`v1/analytics/realtime/streams`\
Get real-time analytics for a stream or a list of streams.

`v1/analytics/realtime/stories`\
Get real-time analytics for a story or a list of stories.

## Parameters

There are two optional parameter on the real-time endpoints. The items parameter allows you to filter items based on the name or ID of the item. If the item parameter is not provided the endpoint will return the latest 10 items.

For range this option allows you to select a predefined range from 0 - 7.<br>

<table><thead><tr><th width="171.4726418261161"></th><th></th></tr></thead><tbody><tr><td><strong>Key</strong></td><td><strong>Type</strong></td></tr><tr><td><strong>items</strong></td><td><strong>Array Strings</strong><br>Name or ID of the items to filter.</td></tr><tr><td><strong>range</strong></td><td><strong>Int</strong><br>The range option to use. Defaults to 1.</td></tr></tbody></table>

### Range Options

|               |               |
| ------------- | ------------- |
| **0**         | The Last Hour |
| **1 Default** | Last 24 Hours |
| **2**         | Last 2 Days   |
| **3**         | Last 3 Days   |
| **4**         | Last 4 Days   |
| **5**         | Last 5 Days   |
| **6**         | Last 6 Days   |
| **7**         | Last 7 Days   |

## Examples

### Get Latest 10 Pathways

The example below makes a call to the `realtime/pathways` endpoint without a items parameter.

```
curl -X POST \
  v1/analytics/realtime/pathways \
  -H 'Authorization: Basic <Your Base64 Encoded Token>'\
```

### Get a Single App

The example below makes a call to the `realtime/apps` endpoint with a single item in the items parameter.

```
curl -X POST \
  v1/analytics/realtime/apps \
  -H 'Authorization: Basic <Your Base64 Encoded Token>'\
  -d '{
    "items" : ["Learning App"] 
  }'
```

### Get 2 Specific Stories

The example below makes a call to the `realtime/stories` endpoint with an items parameter set to two stories.&#x20;

```
curl -X POST \
  v1/analytics/realtime/stories \
  -H 'Authorization: Basic <Your Base64 Encoded Token>'\
  -d '{
    "items" : ["Story A","Story B"] 
  }'
```

## Success Response

Whichever `realtime` endpoint you are using a successful response will return an array of items with each item containing a context item (app, pathway, stream or story) and corresponding `realtime` data. The example below shows a successful response when using the `realtime/apps` endpoint.

```
{
    "status": "success",
    "data": [
        {
            "app": {
                "name": "Falkor",
                "version": "2.10.1",
                "type": "app",
                "ID": "io.falkor.demo"
            },
            "realtime": [
                {
                    "range": [
                        "2022-02-18T10:49:40+02:00",
                        "2022-02-19T10:49:40+02:00"
                    ],
                    "sessions": 1375,
                    "interactions": 4567
                },
                {
                    "range": [
                        "2022-02-19T10:49:40+02:00",
                        "2022-02-20T10:49:40+02:00"
                    ],
                    "sessions": 1266,
                    "interactions": 3984
                },
                ...etc
            ]
        },
        {
            "app": {
                "name": "The Everyday App",
                "version": "2.10.1",
                "type": "app",
                "ID": "io.falkor.theeverydayapp"
            },
            "realtime": [
                {
                    "range": [
                        "2022-02-18T10:49:40+02:00",
                        "2022-02-19T10:49:40+02:00"
                    ],
                    "sessions": 310,
                    "interactions": 645
                },
                {
                    "range": [
                        "2022-02-19T10:49:40+02:00",
                        "2022-02-20T10:49:40+02:00"
                    ],
                    "sessions": 157,
                    "interactions": 320
                },
                ...etc
            ]
        },
        ...etc
    ],
    "hash": "a936c922af60b3849d2c44b93c1ae37b",
    "response_time": 0.22345805168151855
}
```
