> ## Documentation Index
> Fetch the complete documentation index at: https://api.docs.flare.io/llms.txt
> Use this file to discover all available pages before exploring further.

# List Events Within a Tenant

Browsing events within a tenant is exposed through the
[List Tenant Events <Icon icon="code" size={16} />](/api-reference/v4/endpoints/current-tenant-feed)
API.

This guide explains how to use the tenant feed API perform a full export
of all results.

## Paging

The tenant feed endpoint uses parameters that match the
[Flare standard paging pattern <Icon icon="book" size={16} />](/concepts/paging).

## Fetching new results in future executions

It is possible to save the `next` in a database and use it to resume fetching new results in the future.
However, it is important that future requests use **exactly** the same parameters for everything else but `next`.

## Getting the full data of results

For performance reasons, feed results only contain the bare minimum.
To get the full data, an API call must be made per result to the
[Retrieve Event <Icon icon="code" size={16} />](/api-reference/v2/endpoints/activities/get-activities-)
endpoint.

## Available Endpoints

### List events for a tenant

If you're looking to export the events of a tenant, refer to the
[List Tenant Events <Icon icon="code" size={16} />](/api-reference/v4/endpoints/current-tenant-feed)
endpoint.

```python theme={null}
# (incomplete example)

for resp in api_client.scroll(
    method="POST",
    url="/firework/v4/events/tenant/_search",
    json={
        "from": last_from,
    },
):
    ...
```

### List events for a single identifier

If you're looking to export the events of a single identifier, refer to the
[List Identifier Events <Icon icon="code" size={16} />](/api-reference/v4/endpoints/identifier-feed)
endpoint.

```python theme={null}
# (incomplete example)

# ID of the identifier for which we want to list the events.
identifier_id: int = 12345

for resp in api_client.scroll(
    method="POST",
    url=f"/firework/v4/events/identifiers/{identifier_id}/_search",
    json={
        "from": last_from,
    },
):
    ...
```

### List events for an identifier group

If you're looking to export the events of an entire identifier group, refer to the [List Identifier Group's Events <Icon icon="code" size={16} />](/api-reference/v4/endpoints/identifier-group-feed) endpoint.

```python theme={null}
# (incomplete example)

# ID of the identifier group for which we want to list the events.
identifier_group_id: int = 12345

for resp in api_client.scroll(
    method="POST",
    url=f"/firework/v4/events/identifier_groups/{identifier_group_id}/_search",
    json={
        "from": last_from,
    },
):
    ...
```

## End-to-End Examples

These are end-to-end examples in various programming languages.

<AccordionGroup>
  <Accordion title="Python SDK Example">
    ```python theme={null}
    from flareio import FlareApiClient
    from flareio.ratelimit import Limiter


    api_client = FlareApiClient.from_env()

    limiter_search = Limiter.from_seconds(1)
    limiter_default = Limiter.from_seconds(0.25)

    last_from: str | None = None
    fetched_pages: int = 0

    for resp in api_client.scroll(
        method="POST",
        url="/firework/v4/events/tenant/_search",
        json={
            "from": last_from,
        },
    ):
        limiter_search.tick()

        resp_data: dict = resp.json()

        fetched_pages += 1
        num_results: int = len(resp_data["items"])
        print(f"Fetched page {fetched_pages} with {num_results} results...")

        # Save the last "next" value.
        last_from = resp_data.get("next") or last_from

        # (Optional): Get the full data
        for item in resp_data["items"]:
            limiter_default.tick()

            event_response = api_client.get(
                url="/firework/v2/activities/",
                params={
                    "uid": item["metadata"]["uid"],
                },
            )

            full_data = event_response.json()
            print(f"Here is the full data of the event: {full_data}")

    print(f"The next execution could resume using {last_from=}.")
    ```
  </Accordion>
</AccordionGroup>
