# Invoice statistics

## Overview

Returns overall statistics for your invoices.

## Request

```bash
curl -X POST https://api.bitsby.app/statistics/invoices \
  -H "Authorization: Token MSvL2ltaDZdWVjmZURURMVWhqSJLT2NURjhL2Fla1Z1T1IxQTltKs1T3Ay" \
  -F "startDate=2000-01-01" \
  -F "endDate=2030-01-01"
```

## Request parameters

| Parameter   | Data type | Description                                     | Example    | Required? |
| ----------- | --------- | ----------------------------------------------- | ---------- | --------- |
| `startDate` | String    | Start date of invoice creation, in Y-m-d format | 2000-01-01 | no        |
| `endDate`   | String    | End date of invoice creation, in Y-m-d format   | 2030-01-01 | no        |

## Response example

```json
{
    "result": "success",
    "data": {
        "invoicesTotalNum": 51,
        "invoicesPaidNum": 24,
        "invoicesTotalUSD": 335.03,
        "invoicesByProjects": {
            "9deea1e2-0c08-41a3-bdc2-a34eada3892d": 335.03
        },
        "invoicesByCurrencies": {
            "USD": 335.03
        },
        "invoicesByMonths": {
            "March-2024": 42,
            "February-2024": 293.03
        },
        "invoicesByDate": {
            "2024-03-04": {
                "date": 1709510400000,
                "value": 21
            },
            "2024-03-03": {
                "date": 1709424000000,
                "value": 10
            },
            "2024-03-01": {
                "date": 1709251200000,
                "value": 11
            },
            "2024-02-27": {
                "date": 1708992000000,
                "value": 12
            },
            "2024-02-26": {
                "date": 1708905600000,
                "value": 281.03
            }
        }
    }
}
```

## Response parameters

| Parameter              | Description                                              |
| ---------------------- | -------------------------------------------------------- |
| `invoicesTotalNum`     | Total number of invoices                                 |
| `invoicesPaidNum`      | Number of paid invoices (with the Paid status)           |
| `invoicesTotalUSD`     | Total of all paid invoices in USD                        |
| `invoicesByProjects`   | Total of all paid invoices by project, in USD            |
| `invoicesByCurrencies` | Total of all paid invoices by currency                   |
| `invoicesByMonths`     | Total of all paid invoices by month, in USD              |
| `invoicesByDate`       | Total of all paid invoices by day, in USD                |
| `invoicesByDate.date`  | Date as a Unix timestamp, in milliseconds                |
| `invoicesByDate.value` | Total of all paid invoices for the specific date, in USD |
