# Get Statistics Report

Reads a saved statistics report’s tag counts per period. Counts only contacts carrying each tag now, in its latest tagging period; tags removed from a contact again are not counted and empty periods are omitted. Deleted account tags appear in missingTagIds. granularity overrides the saved setting for this read only; over 2000 periods is refused.

## Input schema:

```json
{
  "type": "object",
  "properties": {
    "reportId": {
      "type": "integer",
      "description": "ID of the report, from search-statistics-reports",
      "minimum": 1
    },
    "granularity": {
      "type": [
        "null",
        "string"
      ],
      "description": "hour, day, month or year; omit for the one the report is saved with",
      "default": null,
      "enum": [
        "hour",
        "day",
        "month",
        "year"
      ]
    },
    "accountId": {
      "type": [
        "null",
        "integer"
      ],
      "description": "User ID of the account; omit for the account the access token works in",
      "default": null,
      "minimum": 1
    }
  },
  "required": [
    "reportId"
  ],
  "additionalProperties": false
}
```

## Output schema:

```json
{
  "type": "object",
  "required": [
    "accountId",
    "reportId",
    "name",
    "chart",
    "rangeFrom",
    "rangeTo",
    "notes",
    "missingTagIds",
    "statistics",
    "reportUrl"
  ],
  "properties": {
    "accountId": {
      "type": "integer"
    },
    "reportId": {
      "type": "integer"
    },
    "name": {
      "type": "string"
    },
    "chart": {
      "type": "string",
      "enum": [
        "progress",
        "continuous",
        "total"
      ]
    },
    "rangeFrom": {
      "type": "string"
    },
    "rangeTo": {
      "type": "string"
    },
    "notes": {
      "type": "string"
    },
    "missingTagIds": {
      "type": "array",
      "items": {
        "type": "integer"
      }
    },
    "statistics": {
      "type": "object",
      "required": [
        "granularity",
        "from",
        "to",
        "tags"
      ],
      "properties": {
        "granularity": {
          "type": "string"
        },
        "from": {
          "type": "integer"
        },
        "to": {
          "type": "integer"
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "tagId",
              "name",
              "tagged",
              "periods"
            ],
            "properties": {
              "tagId": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "tagged": {
                "type": "integer"
              },
              "periods": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "period",
                    "tagged"
                  ],
                  "properties": {
                    "period": {
                      "type": "string"
                    },
                    "tagged": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "reportUrl": {
      "type": "string"
    }
  }
}
```

