# get\_\_aistats\_daily

`GET /aistats/daily`

*Get Daily AI Statistics*

Get daily aggregated AI statistics for LLM usage, including token counts, API calls, policy violations, and performance metrics.

#### Parameters <a href="#get__aistats_daily-parameters" id="get__aistats_daily-parameters"></a>

| Name             | In    | Type         | Required | Description                                                                                                 |
| ---------------- | ----- | ------------ | -------- | ----------------------------------------------------------------------------------------------------------- |
| startDate        | query | string(date) | false    | Start date (ISO format)                                                                                     |
| endDate          | query | string(date) | false    | End date (ISO format)                                                                                       |
| repoId           | query | string       | false    | Repository ID filter (comma-separated for multiple values)                                                  |
| aiLlmId          | query | string       | false    | AI LLM ID filter (comma-separated for multiple values)                                                      |
| repoAiApiKeyId   | query | string       | false    | Repository AI API Key ID filter (comma-separated for multiple values)                                       |
| hosts            | query | string       | false    | Host filter (comma-separated for multiple values)                                                           |
| llmType          | query | string       | false    | LLM type filter (comma-separated for multiple values, e.g., "OPENAI", "ANTHROPIC")                          |
| llmModel         | query | string       | false    | LLM model filter (comma-separated for multiple values, e.g., "gpt-4", "claude-3")                           |
| userUuid         | query | string       | false    | User ID filter (comma-separated for multiple values). Restricts stats to the given user(s).                 |
| conversationUuid | query | string       | false    | Conversation ID filter (comma-separated for multiple values). Restricts stats to the given conversation(s). |

#### TypeScript Client Library

```typescript
// Using the Flashback TypeScript client
import { FlashbackClient } from '@flashbacktech/flashbackclient';

const client = new FlashbackClient({
  accessToken: 'your-access-token'
});

// Get daily AI statistics with optional filters
try {
  const result = await client.getAiStatsDaily({
    startDate: new Date('2024-01-01'),
    endDate: new Date('2024-01-31'),
    repoId: ['repo-id-1', 'repo-id-2'],
    aiLlmId: ['llm-id-1'],
    repoAiApiKeyId: ['api-key-id-1'],
    hosts: ['host1.example.com', 'host2.example.com'],
    llmType: ['OPENAI', 'ANTHROPIC'],
    llmModel: ['gpt-4', 'claude-3'],
    userUuid: ['user-uuid-1'],           // optional: filter by user ID(s)
    conversationUuid: ['conv-uuid-1']     // optional: filter by conversation ID(s)
  });
  console.log('Daily AI statistics:', result);
} catch (error) {
  console.error('Failed to retrieve daily AI statistics:', error);
}
```

#### Code Samples

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

```shell
# You can also use wget
curl -X GET "https://backend.flashback.tech/aistats/daily?startDate=2024-01-01T00:00:00.000Z&endDate=2024-01-31T23:59:59.999Z&repoId=repo-id-1,repo-id-2" \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}'
```

{% endtab %}

{% tab title="HTTP" %}

```http
GET https://backend.flashback.tech/aistats/daily?startDate=2024-01-01T00:00:00.000Z&endDate=2024-01-31T23:59:59.999Z HTTP/1.1
Host: backend.flashback.tech
Accept: application/json
Authorization: Bearer {access-token}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const headers = {
  'Accept':'application/json',
  'Authorization':'Bearer {access-token}'
};

const queryParams = new URLSearchParams({
  startDate: '2024-01-01T00:00:00.000Z',
  endDate: '2024-01-31T23:59:59.999Z',
  repoId: 'repo-id-1,repo-id-2'
});

fetch(`https://backend.flashback.tech/aistats/daily?${queryParams.toString()}`,
{
  method: 'GET',
  headers: headers
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'rest-client'
require 'json'

headers = {
  'Accept' => 'application/json',
  'Authorization' => 'Bearer {access-token}'
}

result = RestClient.get 'https://backend.flashback.tech/aistats/daily',
  params: {
    startDate: '2024-01-01T00:00:00.000Z',
    endDate: '2024-01-31T23:59:59.999Z',
    repoId: 'repo-id-1,repo-id-2'
  }, headers: headers

p JSON.parse(result)
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
headers = {
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}'
}

params = {
  'startDate': '2024-01-01T00:00:00.000Z',
  'endDate': '2024-01-31T23:59:59.999Z',
  'repoId': 'repo-id-1,repo-id-2'
}

r = requests.get('https://backend.flashback.tech/aistats/daily', headers=headers, params=params)

print(r.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

require 'vendor/autoload.php';

$headers = array(
    'Accept' => 'application/json',
    'Authorization' => 'Bearer {access-token}',
);

$client = new \GuzzleHttp\Client();

$queryParams = array(
    'startDate' => '2024-01-01T00:00:00.000Z',
    'endDate' => '2024-01-31T23:59:59.999Z',
    'repoId' => 'repo-id-1,repo-id-2'
);

try {
    $response = $client->request('GET','https://backend.flashback.tech/aistats/daily', array(
        'headers' => $headers,
        'query' => $queryParams,
       )
    );
    print_r($response->getBody()->getContents());
 }
 catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // handle exception or api errors.
    print_r($e->getMessage());
 }

 // ...
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URLEncoder;
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;

String baseUrl = "https://backend.flashback.tech/aistats/daily";
String queryString = "startDate=2024-01-01T00:00:00.000Z&endDate=2024-01-31T23:59:59.999Z&repoId=repo-id-1,repo-id-2";
URL obj = new URL(baseUrl + "?" + queryString);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Accept", "application/json");
con.setRequestProperty("Authorization", "Bearer {access-token}");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
       "bytes"
       "net/http"
       "net/url"
)

func main() {

    headers := map[string][]string{
        "Accept": []string{"application/json"},
        "Authorization": []string{"Bearer {access-token}"},
    }

    params := url.Values{}
    params.Add("startDate", "2024-01-01T00:00:00.000Z")
    params.Add("endDate", "2024-01-31T23:59:59.999Z")
    params.Add("repoId", "repo-id-1,repo-id-2")

    req, err := http.NewRequest("GET", "https://backend.flashback.tech/aistats/daily?" + params.Encode(), nil)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
```

{% endtab %}
{% endtabs %}

> Example responses

> 200 Response

```json
{
  "success": true,
  "data": [
    {
      "timestamp": 1704067200,
      "repoId": "repo-id-1",
      "aiLlmId": "llm-id-1",
      "repoAiApiKeyId": "api-key-id-1",
      "tokensIn": "1500",
      "tokensOut": "800",
      "llmTokensIn": "1500",
      "llmTokensOut": "800",
      "activeConversations": 5,
      "apiCalls": 25,
      "policyViolations": 2,
      "numAlerts": 1,
      "numBlocks": 0,
      "numSeverityLow": 0,
      "numSeverityMedium": 1,
      "numSeverityHigh": 1,
      "latency_ms": 250,
      "llmType": "openai",
      "llmModel": "gpt-4",
      "host": "api.openai.com",
      "userUuid": "user-uuid-1",
      "conversationUuid": "conv-uuid-1"
    }
  ]
}
```

#### Responses <a href="#get__aistats_daily-responses" id="get__aistats_daily-responses"></a>

| Status | Meaning                                                                    | Description                | Schema |
| ------ | -------------------------------------------------------------------------- | -------------------------- | ------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)                    | Daily AI statistics        | Inline |
| 400    | [Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)           | Invalid request parameters | Inline |
| 404    | [Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)             | User not found             | Inline |
| 500    | [Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1) | Internal server error      | Inline |

#### Response Schema <a href="#get__aistats_daily-responseschema" id="get__aistats_daily-responseschema"></a>

Status Code **200**

| Name                   | Type      | Required | Restrictions | Description                                             |
| ---------------------- | --------- | -------- | ------------ | ------------------------------------------------------- |
| » success              | boolean   | true     | none         | Indicates if the request was successful                 |
| » data                 | \[object] | true     | none         | Array of daily AI statistics records                    |
| »» timestamp           | integer   | true     | none         | Unix timestamp (seconds) for the statistics record      |
| »» repoId              | string    | true     | none         | Repository ID                                           |
| »» aiLlmId             | string    | true     | none         | AI LLM ID                                               |
| »» repoAiApiKeyId      | string    | true     | none         | Repository AI API Key ID                                |
| »» tokensIn            | string    | true     | none         | Total input tokens (as string to handle large numbers)  |
| »» tokensOut           | string    | true     | none         | Total output tokens (as string to handle large numbers) |
| »» llmTokensIn         | string    | true     | none         | LLM input tokens (as string to handle large numbers)    |
| »» llmTokensOut        | string    | true     | none         | LLM output tokens (as string to handle large numbers)   |
| »» activeConversations | integer   | true     | none         | Number of active conversations                          |
| »» apiCalls            | integer   | true     | none         | Number of API calls                                     |
| »» policyViolations    | integer   | true     | none         | Number of policy violations                             |
| »» numAlerts           | integer   | true     | none         | Number of alerts triggered                              |
| »» numBlocks           | integer   | true     | none         | Number of blocked requests                              |
| »» numSeverityLow      | integer   | true     | none         | Number of policy violations with LOW severity           |
| »» numSeverityMedium   | integer   | true     | none         | Number of policy violations with MEDIUM severity        |
| »» numSeverityHigh     | integer   | true     | none         | Number of policy violations with HIGH severity          |
| »» latency\_ms         | number    | true     | none         | Average latency in milliseconds                         |
| »» llmType             | string    | true     | none         | Type of LLM provider (e.g., "openai", "anthropic")      |
| »» llmModel            | string    | true     | none         | LLM model name (e.g., "gpt-4", "claude-3")              |
| »» host                | string    | true     | none         | Host/domain of the LLM API endpoint                     |
| »» userUuid            | string    | true     | none         | User ID associated with the statistics record           |
| »» conversationUuid    | string    | true     | none         | Conversation ID associated with the statistics record   |

Status Code **400**

| Name      | Type    | Required | Restrictions | Description                      |
| --------- | ------- | -------- | ------------ | -------------------------------- |
| » success | boolean | true     | none         | Always false for error responses |
| » message | string  | true     | none         | Error message                    |

Status Code **404**

| Name      | Type    | Required | Restrictions | Description                      |
| --------- | ------- | -------- | ------------ | -------------------------------- |
| » success | boolean | true     | none         | Always false for error responses |
| » message | string  | true     | none         | Error message                    |

Status Code **500**

| Name      | Type    | Required | Restrictions | Description                      |
| --------- | ------- | -------- | ------------ | -------------------------------- |
| » success | boolean | true     | none         | Always false for error responses |
| » message | string  | true     | none         | Error message                    |


---

# 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.flashback.tech/support-reference/platform-api-reference/statistics/get__aistats_daily.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.
