# Analytics

Analytics are always related to a project. This means that all endpoints have the same root:

&#x20;`https:://app.inspector.dev`**`/api/apps/:id`**

## Get Hosts

<mark style="color:green;">`POST`</mark> `https://app.inspector.dev/api/apps/:id/hosts`

The list of hosts (servers) where the application runs on.

#### Path Parameters

| Name | Type   | Description  |
| ---- | ------ | ------------ |
| id   | string | Project's ID |

#### Headers

| Name           | Type   | Description |
| -------------- | ------ | ----------- |
| Authentication | string | API key     |

#### Request Body

| Name   | Type   | Description                                                                                                                                                                                                                                   |
| ------ | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filter | object | <p>This object should contains "<strong>start</strong>" and "<strong>end</strong>" dates (ISO8601) to define the period you would analyze.<br><br>You can also provide the <strong>types</strong> field as an array of transaction types.</p> |

{% tabs %}
{% tab title="200 " %}

```json
[
    {
        "hostname": "server-useast-2",
        "transactions": 2320,
        "memory_peak": 25,
        "median": 168.3
    },
    {
        "hostname": "server-useast-1",
        "transactions": 2320,
        "memory_peak": 25,
        "median": 168.3
    }
]
```

{% endtab %}
{% endtabs %}

## Types

<mark style="color:green;">`POST`</mark> `/users`

The list of transaction types the application runs (request, command, job, etc).

**Headers**

| Name          | Value              |
| ------------- | ------------------ |
| Content-Type  | `application/json` |
| Authorization | `Bearer <token>`   |

**Request Body**

| Name   | Type   | Description                                                                                                   |
| ------ | ------ | ------------------------------------------------------------------------------------------------------------- |
| filter | object | This object should contains "**start**" and "**end**" dates (ISO8601) to define the period you would analyze. |

**Response**

{% tabs %}
{% tab title="200" %}

```json
[
    {
        "type": "request",
        "transactions": 2320,
        "memory_peak": 9,
        "median": 36.3
    },
    {
        "type": "command",
        "transactions": 532,
        "memory_peak": 25,
        "median": 168.3
    }
]
```

{% endtab %}

{% tab title="400" %}

```json
{
  "error": "Invalid request"
}
```

{% endtab %}
{% endtabs %}

## Performance

<mark style="color:green;">`POST`</mark> `https://app.inspector.dev/api/apps/:id/performance`

#### Path Parameters

| Name | Type    | Description  |
| ---- | ------- | ------------ |
| id   | integer | Project's ID |

#### Headers

| Name           | Type   | Description |
| -------------- | ------ | ----------- |
| Authentication | string | API key     |

#### Request Body

| Name   | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ------ | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filter | object | <p>This object should contains "<strong>start</strong>" and "<strong>end</strong>" dates (ISO 8601) to define the period you would analyze. <br><br>You can attach the "<strong>hosts</strong>" field as an array of hostnames to filter your performance report by servers.<br><br>You can include the "<strong>query\_string</strong>" parameter to filter by transactions name.</p><p></p><p>Furthermore you can include the <strong>group\_hash</strong> field to get insights for a specific process.</p> |

{% tabs %}
{% tab title="200 " %}

```json
[
    {
        "type": "request",
        "performance": [
            {
                "date": "2020-10-10 12:54",
                "count": 4,
                "p50": 5.37,
                "p95": 6.56,
                "memory_average": 4.52
            },
            {
                "date": "2020-10-10 13:54",
                "count": 4,
                "p50": 5.37,
                "p95": 6.56,
                "memory_average": 4.52
            }
        ]
    },
    
    {
        "type": "command",
        "performance": [
            {
                "date": "2020-10-10 12:54",
                "count": 4,
                "p50": 5.37,
                "p95": 6.56,
                "memory_average": 3.77
            },
            {
                "date": "2020-10-10 13:54",
                "count": 4,
                "p50": 5.37,
                "p95": 6.56,
                "memory_average": 3.77
            }
        ]
    }
]
```

{% endtab %}
{% endtabs %}

## Errors

<mark style="color:blue;">`GET`</mark> `https://app.inspector.dev/api/projects/:id/errors`

Retrieve the list of the error detected in the given application.

#### Path Parameters

| Name | Type    | Description  |
| ---- | ------- | ------------ |
| id   | integer | Project's ID |

#### Headers

| Name           | Type   | Description |
| -------------- | ------ | ----------- |
| Authentication | string | API Key     |

{% tabs %}
{% tab title="200 " %}

```json
[
    {
        "id": 24,
        "message": "First Exception detected",
        "handled": true,
        "muted": false,
        "class": "Exception",
        "file": "C:\\xampp\\htdocs\\crongenius\\vendor\\inspector-apm\\inspector-laravel\\src\\Commands\\TestCommand.php",
        "line": 71,
        "hash": "287366827414d79f8f4775c5a99e0d05",
        "last_seen_at": "2020-10-09 14:05:41",
        "created_at": "2020-10-08 14:48:55",
        "histogram_day": {
            "2020-10-15 07:00": 0,
            "2020-10-15 08:00": 1,
            "2020-10-15 09:00": 1,
            "2020-10-15 10:00": 7,
            "2020-10-15 11:00": 0,
            "2020-10-15 12:00": 0,
            "2020-10-15 13:00": 1,
            "2020-10-15 14:00": 1,
            "2020-10-15 15:00": 3,
            "2020-10-15 16:00": 0,
            "2020-10-15 17:00": 0,
            "2020-10-15 18:00": 21,
            "2020-10-15 19:00": 6,
            "2020-10-15 20:00": 0,
            "2020-10-15 21:00": 0,
            "2020-10-15 22:00": 16,
            "2020-10-15 23:00": 0,
            "2020-10-16 00:00": 0,
            "2020-10-16 01:00": 0,
            "2020-10-16 02:00": 0,
            "2020-10-16 03:00": 0,
            "2020-10-16 04:00": 0,
            "2020-10-16 05:00": 0,
            "2020-10-16 06:00": 0,
            "2020-10-16 07:00": 0
        },
        "histogram_month": {
            "2020-09-16 07:00": 0,
            "2020-09-17 07:00": 0,
            "2020-09-18 07:00": 0,
            "2020-09-19 07:00": 0,
            "2020-09-20 07:00": 0,
            "2020-09-21 07:00": 0,
            "2020-09-22 07:00": 0,
            "2020-09-23 07:00": 0,
            "2020-09-24 07:00": 5,
            "2020-09-25 07:00": 0,
            "2020-09-26 07:00": 0,
            "2020-09-27 07:00": 0,
            "2020-09-28 07:00": 0,
            "2020-09-29 07:00": 0,
            "2020-09-30 07:00": 0,
            "2020-10-01 07:00": 0,
            "2020-10-02 07:00": 21,
            "2020-10-03 07:00": 8,
            "2020-10-04 07:00": 0,
            "2020-10-05 07:00": 0,
            "2020-10-06 07:00": 0,
            "2020-10-07 07:00": 0,
            "2020-10-08 07:00": 0,
            "2020-10-09 07:00": 4,
            "2020-10-10 07:00": 0,
            "2020-10-11 07:00": 0,
            "2020-10-12 07:00": 4,
            "2020-10-13 07:00": 0,
            "2020-10-14 07:00": 0,
            "2020-10-15 07:00": 2,
            "2020-10-16 07:00": 127
        },
        "histogram_hour": {
            "2020-10-16 06:36": 0,
            "2020-10-16 06:38": 0,
            "2020-10-16 06:40": 0,
            "2020-10-16 06:42": 0,
            "2020-10-16 06:44": 0,
            "2020-10-16 06:46": 0,
            "2020-10-16 06:48": 4,
            "2020-10-16 06:50": 27,
            "2020-10-16 06:52": 25,
            "2020-10-16 06:54": 0,
            "2020-10-16 06:56": 3,
            "2020-10-16 06:58": 0,
            "2020-10-16 07:00": 0,
            "2020-10-16 07:02": 5,
            "2020-10-16 07:04": 6,
            "2020-10-16 07:06": 6,
            "2020-10-16 07:08": 0,
            "2020-10-16 07:10": 0,
            "2020-10-16 07:12": 0,
            "2020-10-16 07:14": 0,
            "2020-10-16 07:16": 0,
            "2020-10-16 07:18": 19,
            "2020-10-16 07:20": 0,
            "2020-10-16 07:22": 0,
            "2020-10-16 07:24": 0,
            "2020-10-16 07:26": 0,
            "2020-10-16 07:28": 0,
            "2020-10-16 07:30": 0,
            "2020-10-16 07:32": 5,
            "2020-10-16 07:34": 30,
            "2020-10-16 07:36": 0
        },
        "total": 4
    }
]
```

{% endtab %}
{% endtabs %}

## Errors Trend

<mark style="color:blue;">`GET`</mark> `https://app.inspector.dev/api/apps/:id/errors/trend`

Retrieve the daily errors trend inthe last 30 days.

#### Path Parameters

| Name | Type    | Description  |
| ---- | ------- | ------------ |
| id   | integer | Project's ID |

#### Headers

| Name           | Type   | Description |
| -------------- | ------ | ----------- |
| Authentication | string | API key     |

{% tabs %}
{% tab title="200 " %}

```json
[
  {
    "date": 1617494400000,
    "num": 0
  },
  {
    "date": 1617580800000,
    "num": 0
  },
  {
    "date": 1617667200000,
    "num": 0
  },
  {
    "date": 1617753600000,
    "num": 0
  },
  {
    "date": 1617840000000,
    "num": 0
  },
  {
    "date": 1617926400000,
    "num": 1
  },
  {
    "date": 1618012800000,
    "num": 0
  },
  {
    "date": 1618099200000,
    "num": 0
  },
  {
    "date": 1618185600000,
    "num": 0
  },
  {
    "date": 1618272000000,
    "num": 0
  },
  {
    "date": 1618358400000,
    "num": 0
  },
  {
    "date": 1618444800000,
    "num": 0
  },
  {
    "date": 1618531200000,
    "num": 0
  },
  {
    "date": 1618617600000,
    "num": 0
  },
  {
    "date": 1618704000000,
    "num": 0
  },
  {
    "date": 1618790400000,
    "num": 0
  },
  {
    "date": 1618876800000,
    "num": 0
  },
  {
    "date": 1618963200000,
    "num": 0
  },
  {
    "date": 1619049600000,
    "num": 0
  },
  {
    "date": 1619136000000,
    "num": 0
  },
  {
    "date": 1619222400000,
    "num": 0
  },
  {
    "date": 1619308800000,
    "num": 0
  },
  {
    "date": 1619395200000,
    "num": 0
  },
  {
    "date": 1619481600000,
    "num": 0
  },
  {
    "date": 1619568000000,
    "num": 0
  },
  {
    "date": 1619654400000,
    "num": 0
  },
  {
    "date": 1619740800000,
    "num": 0
  },
  {
    "date": 1619827200000,
    "num": 0
  },
  {
    "date": 1619913600000,
    "num": 0
  },
  {
    "date": 1620000000000,
    "num": 0
  },
  {
    "date": 1620086400000,
    "num": 0
  }
]
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.inspector.dev/rest-api/analytics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
