Skip to content

Latest commit

 

History

History
89 lines (63 loc) · 6.43 KB

File metadata and controls

89 lines (63 loc) · 6.43 KB

UserBalances

(userBalances)

Overview

Available Operations

getBalance

Return user's balance of specified currency

Example Usage

import { RaribleProtocolMcp } from "@rarible/protocol-mcp";

const raribleProtocolMcp = new RaribleProtocolMcp({
  apiKeyAuth: process.env["RARIBLE_API_KEY"] ?? "",
});

async function run() {
  const result = await raribleProtocolMcp.userBalances.getBalance({
    currencyId: "ETHEREUM:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    owner: "ETHEREUM:0x4765273c477c2dc484da4f1984639e943adccfeb",
  });

  // Handle the result
  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { RaribleProtocolMcpCore } from "@rarible/protocol-mcp/core.js";
import { userBalancesGetBalance } from "@rarible/protocol-mcp/funcs/userBalancesGetBalance.js";

// Use `RaribleProtocolMcpCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const raribleProtocolMcp = new RaribleProtocolMcpCore({
  apiKeyAuth: process.env["RARIBLE_API_KEY"] ?? "",
});

async function run() {
  const res = await userBalancesGetBalance(raribleProtocolMcp, {
    currencyId: "ETHEREUM:0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    owner: "ETHEREUM:0x4765273c477c2dc484da4f1984639e943adccfeb",
  });

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

  const { value: result } = res;

  // Handle the result
  console.log(result);
}

run();

Parameters

Parameter Type Required Description
request operations.GetBalanceRequest ✔️ 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.

Response

Promise<models.Balance>

Errors

Error Type Status Code Content Type
errors.UnionApiErrorBadRequest 400 application/json
errors.UnionApiErrorEntityNotFound 404 application/json
errors.UnionApiErrorServerError 500 application/json
errors.APIError 4XX, 5XX */*