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

# Wallet Analytics Examples

A common use case is to see the number of wallets that are integrated with your project. We have a variety of endpoints that can be used for tracking and reporting fine-grained data such as device, country, and more so you can precisely identify

<Note>
  Replace the PROJECT\_ID and SECRET\_API\_ACCESS\_KEY variables with your project ID and
  secret token from Sequence Builder.
</Note>

## Fetch wallets for a time interval for a project ID

Here we can pass a specific date range along with the dateInterval parameter in order to get wallets within a time interval. The endpoints can use "DAY", "WEEK" or "MONTH" as possible options.

<CodeGroup>
  ```sh cURL theme={null}
  curl 'https://api.sequence.build/rpc/Analytics/WalletsDaily' \
    -H 'accept: */*' \
    -H 'authorization: BEARER <SECRET_API_ACCESS_KEY>' \
    -H 'content-type: application/json' \
    --data-raw '{"filter":{"projectId":<PROJECT_ID>,"startDate":"2024-04-23","endDate":"2024-05-23", "dateInterval":"DAY"}}'
  ```

  ```ts TypeScript theme={null}
  // Works in both a Webapp (browser) or Node.js by importing cross-fetch:
  // import fetch from "cross-fetch";

  (async () => {
    const res = await fetch("https://api.sequence.build/rpc/Analytics/WalletsDaily", {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        filter: {
          projectId: 4859,
          startDate: "2024-01-23",
          endDate: "2024-05-23",
          dateInterval: "DAY"
        }
      })
    });
    console.log("res", await res.json());
  })();
  ```
</CodeGroup>

## Fetch wallets by Country

You can also fetch wallets by country to see where your users are logged in from.

<CodeGroup>
  ```sh cURL theme={null}
  curl 'https://api.sequence.build/rpc/Analytics/WalletsByCountry' \
    -H 'accept: */*' \
    -H 'authorization: BEARER <SECRET_API_ACCESS_KEY>' \
    -H 'content-type: application/json' \
    --data-raw '{"filter":{"projectId":<PROJECT_ID>,"startDate":"2024-04-23","endDate":"2024-05-23", "dateInterval":"DAY"}}'
  ```

  ```ts TypeScript theme={null}
  // Works in both a Webapp (browser) or Node.js by importing cross-fetch:
  // import fetch from "cross-fetch";

  (async () => {
    const res = await fetch("https://api.sequence.build/rpc/Analytics/WalletsByCountry", {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        filter: {
          projectId: 4859,
          startDate: "2024-01-23",
          endDate: "2024-05-23",
          dateInterval: "DAY"
        }
      })
    });
    console.log("res", await res.json());
  })();
  ```
</CodeGroup>

## Fetch wallets by Device

Additionally, you may want to query by device to get an aggregrated snapshot of where your users are authenticating from.

<CodeGroup>
  ```sh cURL theme={null}
  curl 'https://api.sequence.build/rpc/Analytics/WalletsByDevice' \
    -H 'accept: */*' \
    -H 'authorization: BEARER <SECRET_API_ACCESS_KEY>' \
    -H 'content-type: application/json' \
    --data-raw '{"filter":{"projectId":<PROJECT_ID>,"startDate":"2024-04-23","endDate":"2024-05-23", "dateInterval":"DAY"}}'
  ```

  ```ts TypeScript theme={null}
  // Works in both a Webapp (browser) or Node.js by importing cross-fetch:
  // import fetch from "cross-fetch";

  (async () => {
    const res = await fetch("https://api.sequence.build/rpc/Analytics/WalletsByDevice", {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        filter: {
          projectId: 4859,
          startDate: "2024-01-23",
          endDate: "2024-05-23",
          dateInterval: "DAY"
        }
      })
    });
    console.log("res", await res.json());
  })();
  ```
</CodeGroup>

## Fetch transactions by wallets

Lastly, you may want to fetch the number of transactions by wallets - these can used either by total or a fixed time interval.

### Total

<CodeGroup>
  ```sh cURL theme={null}
  curl 'https://api.sequence.build/rpc/Analytics/WalletsTxnSentTotal' \
    -H 'accept: */*' \
    -H 'authorization: BEARER <SECRET_API_ACCESS_KEY>' \
    -H 'content-type: application/json' \
    --data-raw '{"filter":{"projectId":<PROJECT_ID>,"startDate":"2024-04-23","endDate":"2024-05-23"}}'
  ```

  ```ts TypeScript theme={null}
  // Works in both a Webapp (browser) or Node.js by importing cross-fetch:
  // import fetch from "cross-fetch";

  (async () => {
    const res = await fetch(
      "https://api.sequence.build/rpc/Analytics/WalletsTxnSentTotal",
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          filter: {
            projectId: 4859,
            startDate: "2024-01-23",
            endDate: "2024-05-23",
            dateInterval: "DAY"
          }
        })
      }
    );
    console.log("res", await res.json());
  })();
  ```
</CodeGroup>

### Time Interval

<CodeGroup>
  ```sh cURL theme={null}
  curl 'https://api.sequence.build/rpc/Analytics/WalletsTxnSentDaily' \
    -H 'accept: */*' \
    -H 'authorization: BEARER <SECRET_API_ACCESS_KEY>' \
    -H 'content-type: application/json' \
    --data-raw '{"filter":{"projectId":<PROJECT_ID>,"startDate":"2024-04-23","endDate":"2024-05-23", "dateInterval":"DAY"}}'
  ```

  ```ts TypeScript theme={null}
  // Works in both a Webapp (browser) or Node.js by importing cross-fetch:
  // import fetch from "cross-fetch";

  (async () => {
    const res = await fetch(
      "https://api.sequence.build/rpc/Analytics/WalletsTxnSentDaily",
      {
        method: "POST",
        headers: {
          "Content-Type": "application/json"
        },
        body: JSON.stringify({
          filter: {
            projectId: 4859,
            startDate: "2024-01-23",
            endDate: "2024-05-23",
            dateInterval: "DAY"
          }
        })
      }
    );
    console.log("res", await res.json());
  })();
  ```
</CodeGroup>

## Schema

All wallet analytic endpoints follow a similar request schema

* Request: POST
* Content-Type: application/json
* ボディ（JSON形式）：
  * `projectId` (uint64) -- projectID of your project, can be found in the URL of the Builder project.
  * `startDate` (timestamp) -- starting date of the query in YYYY--MM--DD format
  * `endDate` (timestamp) -- ending date of the query in YYYY--MM--DD format
  * `dateInterval` (string) -- date interval for the query, options are "DAY", "WEEK", or "MONTH"
* Response (in JSON):
  * `walletStats` (walletStats\[])
    * `value` (uint64) -- # of wallets matching the query
    * `label` (string) -- label associated with the corresponding endpoint
