Skip to content

Latest commit

 

History

History
519 lines (401 loc) · 38.5 KB

File metadata and controls

519 lines (401 loc) · 38.5 KB

LookingGlass

(metrics.lookingGlass)

Overview

Available Operations

getNftHoldersByContractAddress

Get list of NFT holders and number of NFTs held by contract address.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.metrics.lookingGlass.getNftHoldersByContractAddress({
    pageSize: 10,
    address: "0x7a420AEFF902AAa2c85a190D7B91Ce8BEFffFE14",
  });

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { metricsLookingGlassGetNftHoldersByContractAddress } from "@avalabs/avacloud-sdk/funcs/metricsLookingGlassGetNftHoldersByContractAddress.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await metricsLookingGlassGetNftHoldersByContractAddress(avaCloudSDK, {
    pageSize: 10,
    address: "0x7a420AEFF902AAa2c85a190D7B91Ce8BEFffFE14",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetNftHoldersByContractAddressRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.
options.serverURL string An optional server URL to use.

Response

Promise<operations.GetNftHoldersByContractAddressResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

getAddressesByBalanceOverTime

Get list of addresses and their latest balances that have held more than a certain threshold of a given token during the specified time frame.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.metrics.lookingGlass.getAddressesByBalanceOverTime({
    threshold: "1000000",
    startTimestamp: 1689541049,
    endTimestamp: 1689800249,
    pageSize: 10,
    address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
  });

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { metricsLookingGlassGetAddressesByBalanceOverTime } from "@avalabs/avacloud-sdk/funcs/metricsLookingGlassGetAddressesByBalanceOverTime.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await metricsLookingGlassGetAddressesByBalanceOverTime(avaCloudSDK, {
    threshold: "1000000",
    startTimestamp: 1689541049,
    endTimestamp: 1689800249,
    pageSize: 10,
    address: "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetAddressesByBalanceOverTimeRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.
options.serverURL string An optional server URL to use.

Response

Promise<operations.GetAddressesByBalanceOverTimeResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

getAddressesByBtcbBridged

Get list of addresses and their net bridged amounts that have bridged more than a certain threshold.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.metrics.lookingGlass.getAddressesByBtcbBridged({
    threshold: "1000000",
    pageSize: 10,
  });

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { metricsLookingGlassGetAddressesByBtcbBridged } from "@avalabs/avacloud-sdk/funcs/metricsLookingGlassGetAddressesByBtcbBridged.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await metricsLookingGlassGetAddressesByBtcbBridged(avaCloudSDK, {
    threshold: "1000000",
    pageSize: 10,
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetAddressesByBtcbBridgedRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.
options.serverURL string An optional server URL to use.

Response

Promise<operations.GetAddressesByBtcbBridgedResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

getValidatorsByDateRange

Get list of addresses and AddValidatorTx timestamps set to receive awards for validation periods during the specified time frame.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.metrics.lookingGlass.getValidatorsByDateRange({
    startTimestamp: 1689541049,
    endTimestamp: 1689800249,
    pageSize: 10,
    subnetId: "11111111111111111111111111111111LpoYY",
    network: "mainnet",
  });

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { metricsLookingGlassGetValidatorsByDateRange } from "@avalabs/avacloud-sdk/funcs/metricsLookingGlassGetValidatorsByDateRange.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await metricsLookingGlassGetValidatorsByDateRange(avaCloudSDK, {
    startTimestamp: 1689541049,
    endTimestamp: 1689800249,
    pageSize: 10,
    subnetId: "11111111111111111111111111111111LpoYY",
    network: "mainnet",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.GetValidatorsByDateRangeRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.
options.serverURL string An optional server URL to use.

Response

Promise<operations.GetValidatorsByDateRangeResponse>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*

compositeQuery

Composite query to get list of addresses from multiple subqueries.

Example Usage

import { AvaCloudSDK } from "@avalabs/avacloud-sdk";

const avaCloudSDK = new AvaCloudSDK({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const result = await avaCloudSDK.metrics.lookingGlass.compositeQuery({
    queries: [
      {
        id: "<id>",
        type: "LatestBalanceStarsArena",
        params: {
          minBalance: "<value>",
          subjectAddress: "<value>",
        },
      },
    ],
    operator: "OR",
  });

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Standalone function

The standalone function version of this method:

import { AvaCloudSDKCore } from "@avalabs/avacloud-sdk/core.js";
import { metricsLookingGlassCompositeQuery } from "@avalabs/avacloud-sdk/funcs/metricsLookingGlassCompositeQuery.js";

// Use `AvaCloudSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const avaCloudSDK = new AvaCloudSDKCore({
  apiKey: "<YOUR_API_KEY_HERE>",
  chainId: "43114",
  network: "mainnet",
});

async function run() {
  const res = await metricsLookingGlassCompositeQuery(avaCloudSDK, {
    queries: [
      {
        id: "<id>",
        type: "AnyTimeStarsArenaBalance",
        params: {
          firstDate: "<value>",
          lastDate: "<value>",
          minBalance: "<value>",
          subjectAddress: "<value>",
        },
      },
    ],
    operator: "OR",
  });

  if (!res.ok) {
    throw res.error;
  }

  const { value: result } = res;

  for await (const page of result) {
    // Handle the page
    console.log(page);
  }
}

run();

Parameters

Parameter Type Required Description
request components.CompositeQueryRequestDto ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.
options.serverURL string An optional server URL to use.

Response

Promise<operations.CompositeQueryV2Response>

Errors

Error Type Status Code Content Type
errors.BadRequest 400 application/json
errors.Unauthorized 401 application/json
errors.Forbidden 403 application/json
errors.NotFound 404 application/json
errors.TooManyRequests 429 application/json
errors.InternalServerError 500 application/json
errors.BadGateway 502 application/json
errors.ServiceUnavailable 503 application/json
errors.SDKError 4XX, 5XX */*