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

# Ejemplos de Analytics para Wallet

Un caso de uso común es ver la cantidad de wallets integrados con su proyecto. Contamos con varios endpoints que pueden usarse para rastrear y reportar datos detallados como dispositivo, país y más, para que pueda identificar con precisión a sus usuarios.

<Note>
  Reemplace las variables PROJECT\_ID y SECRET\_API\_ACCESS\_KEY con el ID de su proyecto y el token secreto de Sequence Builder.
</Note>

## Obtener wallets por intervalo de tiempo para un project ID

Aquí puede pasar un rango de fechas específico junto con el parámetro dateInterval para obtener los wallets dentro de un intervalo de tiempo. Los endpoints pueden usar "DAY", "WEEK" o "MONTH" como opciones posibles.

<CodeGroup>
  ```sh cURL
  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
  // 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>

## Obtener wallets por país

También puede obtener wallets por país para ver desde dónde se conectan sus usuarios.

<CodeGroup>
  ```sh cURL
  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
  // 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>

## Obtener wallets por dispositivo

Adicionalmente, puede consultar por dispositivo para obtener un resumen agregado de desde dónde se están autenticando sus usuarios.

<CodeGroup>
  ```sh cURL
  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
  // 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>

## Obtener transacciones por wallets

Por último, puede obtener la cantidad de transacciones por wallets; estos pueden consultarse como total o por un intervalo de tiempo fijo.

### Total

<CodeGroup>
  ```sh cURL
  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
  // 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>

### Intervalo de tiempo

<CodeGroup>
  ```sh cURL
  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
  // 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>

## Esquema

Todos los endpoints de analytics de wallet siguen un esquema de solicitud similar

* Solicitud: POST
* Content-Type: application/json
* Cuerpo (en JSON):
  * `projectId` (uint64) -- projectID de su proyecto, puede encontrarlo en la URL del proyecto en Builder.
  * `startDate` (timestamp) -- fecha de inicio de la consulta en formato YYYY--MM--DD
  * `endDate` (timestamp) -- fecha de fin de la consulta en formato YYYY--MM--DD
  * `dateInterval` (string) -- intervalo de fechas para la consulta, opciones: "DAY", "WEEK" o "MONTH"
* Respuesta (en JSON):
  * `walletStats` (walletStats\[])
    * `value` (uint64) -- cantidad de wallets que cumplen con la consulta
    * `label` (string) -- etiqueta asociada al endpoint correspondiente
