> For the complete documentation index, see [llms.txt](https://developers.flipsnack.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.flipsnack.com/api-reference/api-method-collection.getstats.md).

# collection.getStats

**Note:** Requests must be made to **<https://api.flipsnack.com/v1>**.

## Request parameters <a href="#request_params" id="request_params"></a>

| Name                      | Type    | Description                                                                                                                                                                                                                                                                                                                                          |
| ------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| apiKey (required)         | string  | The API key provided for your user. If it is not specified, the request will return the error code "30 - Missing mandatory parameter". If the key is incorrect the request returns the error code "41 - Invalid credentials".                                                                                                                        |
| signature (required)      | string  | The signature must be calculated by you and added to the request. See [How to sign a request](/how-to-sign-a-request.md) for more information. If the parameter is missing the request will return the error code "30 - Missing mandatory parameter". If the signature is incorrect the request will return the error code "44 - Invalid signature". |
| action (required)         | string  | The API method that should be called. In this case the value should be *collection.getStats*. If it is not specified, the request will return the error code "30 - Missing mandatory parameter".                                                                                                                                                     |
| collectionHash (required) | string  | The hash of the flipbook for which you want to get statistics. If you do not specify a flipbook hash, then the request will return the error code "30 - Missing mandatory parameter".                                                                                                                                                                |
| startDate                 | string  | The start date for statistics interval. Date format must be: YYYY-MM-DD                                                                                                                                                                                                                                                                              |
| endDate                   | string  | The end date for statistics interval. Date format must be: YYYY-MM-DD                                                                                                                                                                                                                                                                                |
| includePageStats          | boolean | <p>If set to true an array with statistics for each page will be returned.</p><p></p><p>Default: false.</p>                                                                                                                                                                                                                                          |

## Response parameters <a href="#response_params" id="response_params"></a>

| Name               | Type   | Description                                                                                                                                                                                                                                                                                                              |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| impressions        | number | The number of impressions of the flipbook. Impressions are counted each time the player is loaded.                                                                                                                                                                                                                       |
| views              | number | The number of views of the flipbook. Views are counted each time a user interacts with the player.                                                                                                                                                                                                                       |
| time\_spent        | number | The total time spent is measured in seconds and shows how much time people spend viewing the flipbook.                                                                                                                                                                                                                   |
| likes (DEPRECATED) | number | The number of likes your flipbook has received on Flipsnack.                                                                                                                                                                                                                                                             |
| downloads          | number | The number of times your documents were downloaded from the flipbook.                                                                                                                                                                                                                                                    |
| pages              | array  | <p>This array will be returned only if the <strong>includePageStats</strong> is set to <strong>true</strong> and the request <strong>format</strong> is <strong>json</strong>.<br><br>This will be an array/list of properties containing: page (page index), time\_spent (in seconds), clicks, views for each page.</p> |

## Error codes <a href="#error_codes" id="error_codes"></a>

For complete list of error codes and messages go to [API status codes](/api-status-codes.md) section.

## Examples <a href="#example" id="example"></a>

### Request

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

<pre class="language-bash"><code class="lang-bash"><strong># GET   
</strong>curl -X GET \
     -G \
     https://api.flipsnack.com/v1/ \
     -d action=collection.getStats \
     -d apiKey=&#x3C;YOUR-API-KEY> \
     -d collectionHash=d3m0h45h \
     -d signature=&#x3C;YOUR-REQUEST-SIGNATURE>
     
</code></pre>

{% endtab %}

{% tab title="HTML" %}

```html
<form method="get" action="https://api.flipsnack.com/v1/">
    <input type="hidden" name="action" value="collection.getStats">
    <input type="hidden" name="apiKey" value="<YOUR-API-KEY>">
    <input type="hidden" name="collectionHash">
    <input type="hidden" name="signature" value="<YOUR-REQUEST-SIGNATURE>">
    <button type="submit">Submit</button>
</form>
```

{% endtab %}
{% endtabs %}

### Response

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

```json
{
    "code": 20,
    "status": "OK",
    "data": {
        "impressions": 723,
        "views": 1240,
        "time_spent": 53,
        "downloads": 4,
        "pages": [
            {
                "page": 1,
                "time_spent": 127443,
                "clicks": 392,
                "views": 4529
            },
            {
                "page": 2,
                "time_spent": 89382,
                "clicks": 171,
                "views": 4130
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://developers.flipsnack.com/api-reference/api-method-collection.getstats.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
