> ## Documentation Index
> Fetch the complete documentation index at: https://developers.scoutworks.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Events in Excel

> Pull your events into Excel with Power Query. Refresh with one click. No code to write.

This recipe loads your events into an Excel table with **Power Query**. It works in Excel for Microsoft 365 and Excel 2016 or later on Windows, and in Excel for Microsoft 365 on Mac.

## Quick version: the first 200 events

<Steps>
  <Step title="Start a web query">
    Choose **Data → Get Data → From Other Sources → From Web**. Choose **Advanced**.
  </Step>

  <Step title="Enter the address">
    In **URL parts**, enter:

    ```text theme={null}
    https://api-demo.scoutworks.app/api/v1/events?limit=200
    ```
  </Step>

  <Step title="Add the key">
    In **HTTP request header parameters**, type `Authorization` in the first box. In the second box, type `Bearer ` followed by the [sandbox key](/guides/sandbox):

    ```text theme={null}
    Bearer sw_live_473adcc6c7236916021f0f24559db36576a53bab071d0f0c08a025adb510b6ab
    ```

    Choose **OK**.
  </Step>

  <Step title="Choose Anonymous">
    If Excel asks how to connect, choose **Anonymous**, then **Connect**. The key in the header does the signing in.
  </Step>

  <Step title="Turn the list into a table">
    In the Power Query editor, select **data: List**, then **To Table**, then the expand button in the column header. Choose the columns you want. Choose **Close & Load**.
  </Step>
</Steps>

To refresh, choose **Data → Refresh All**.

## Full version: every event, every page

A list comes back 200 rows at a time. To load all of them, paste this into a blank query. Choose **Data → Get Data → From Other Sources → Blank Query**, then **Advanced Editor**.

```text Power Query (M) theme={null}
let
    ApiKey = "sw_live_473adcc6c7236916021f0f24559db36576a53bab071d0f0c08a025adb510b6ab",
    GetPage = (cursor as nullable text) =>
        Json.Document(
            Web.Contents(
                "https://api-demo.scoutworks.app/api/v1/events",
                [
                    Query = if cursor = null then [limit = "200"] else [limit = "200", cursor = cursor],
                    Headers = [Authorization = "Bearer " & ApiKey]
                ]
            )
        ),
    Pages = List.Generate(
        () => GetPage(null),
        each _ <> null,
        each if [nextCursor] = null then null else GetPage([nextCursor]),
        each [data]
    ),
    Events = List.Combine(Pages),
    Table = Table.FromRecords(
        Events,
        {"title", "type", "startsAt", "endsAt", "location", "hosted", "attendeeCount"},
        MissingField.UseNull
    )
in
    Table
```

Choose **Done**, then **Close & Load**.

## Switch to your group

Change `api-demo.scoutworks.app` to `api.scoutworks.app`, and replace the sandbox key with your own. Your key needs the `events:read` scope.

<Warning>
  Excel saves the key inside the workbook. Anyone with a copy of the file can read it. Keep the workbook private, and create a key with only the scope it needs. If the file is shared by mistake, revoke the key in Scoutworks.
</Warning>

## Other lists

Change the address in `Web.Contents` and the column names in `Table.FromRecords`:

| List         | Address                                               | Scope               |
| ------------ | ----------------------------------------------------- | ------------------- |
| Members      | `https://api-demo.scoutworks.app/api/v1/members`      | `members:read`      |
| Badges       | `https://api-demo.scoutworks.app/api/v1/badges`       | `badges:read`       |
| Waiting list | `https://api-demo.scoutworks.app/api/v1/waiting-list` | `waiting-list:read` |

The [API reference](/api-reference/introduction) lists every field.
