Wallet API

This endpoints discuss on how to query the wallet endpoint.

Endpoint Overview

The Wallet Balance Endpoint allows users to retrieve the balance of a specified wallet for a given token on a specified blockchain network. This functionality is crucial for users who need to monitor token balances across different networks.

Endpoint

POST /wallet/:chain/:address/:toknAddress/balance

Request Parameters

Body Parameters

  • address:

    • Type: String

    • Description: The address of the wallet whose balance is to be retrieved. This parameter is required.

  • tokenAddress:

    • Type: String

    • Description: The address of the token contract. This parameter is required.

  • chain:

    • Type: Number (optional)

    • Description: The blockchain network on which the token exists. Defaults to 1 (Ethereum) if not provided. Use 900 for Solana.

Request Example

Here is an example of how to structure the request:

GET /wallet/1/0xAddress/0xTokenAddress/balance
Content-Type: application/json

Response

The response from the endpoint will vary depending on the success or failure of the request.

Success Response

  • Status Code: 200 OK

  • Response Body:

{
  "status": true,
  "balance": "1000000000000000000" // Balance in the smallest unit of the token
}

Error Responses

  1. Missing Parameters

    • Status Code: 400 Bad Request

    • Response Body:

    {
      "error": "Missing parameters",
      "expecting": "tokenAddress or address"
    }
  2. Internal Server Error

    • Status Code: 500 Internal Server Error

    • Response Body:

    {
      "error": "An internal server error occurred"
    }

Additional Information

  • Ensure the address and tokenAddress provided are valid and correctly formatted.

  • The chain parameter is optional, and if not provided, the default network used will be Ethereum (chain = 1). Use 900 or 800 for Solana devent or mainnet.

Wallet Stats Endpoint Documentation

Overview

This endpoint allows you to retrieve the statistics of a user's wallet across different blockchain networks. It provides detailed information about the assets in the wallet, including tokens and NFTs, along with their net worth.

Endpoint

GET /wallet/:chain/:address/stats

Request Parameters

URL Parameters

  • chain:

    • Type: Number

    • Description: The network chain to query. The endpoint supports multiple chains:

      • 1: Ethereum Mainnet (default)

      • 56: Binance Smart Chain

      • 97: Binance Smart Chain Testnet

      • 800: Solana Mainnet

      • 900: Solana Devnet

      • 137: Polygon Mainnet

      • 8453: Base Mainnet

      • 42161: Arbitrum Mainnet

  • address:

    • Type: String

    • Description: The address of the user's wallet.

Response

The response will contain the assets in the wallet categorized by type (e.g., tokens, NFTs), the net worth of the wallet in USD, and the total number of assets.

Success Response

  • Status Code: 200 OK

  • Response Body:

{
  "status": true,
  "assets": {
    "token": [
      {
        "name": "Token Name",
        "symbol": "TOKEN",
        "quantity": 1000,
        "usd_value": 1500
      }
    ],
    "nft": [
      {
        "name": "NFT Name",
        "symbol": "NFT",
        "quantity": 1,
        "usd_value": 5000
      }
    ]
  },
  "networth": {
    "token": 1500,
    "nft": 5000
  },
  "total_assets": {
    "token": 1,
    "nft": 1
  }
}

Error Responses

  1. Missing Parameters

    • Status Code: 400 Bad Request

    • Response Body:

    {
      "error": "Missing parameters",
      "expecting": "userAddress"
    }
  2. Internal Server Error

    • Status Code: 500 Internal Server Error

    • Response Body:

    {
      "error": "An internal server error occurred"
    }

Example Request

GET /wallet/1/0xYourWalletAddress/stats

Example Response

{
  "status": true,
  "assets": {
    "token": [
      {
        "name": "TokenName",
        "symbol": "TKN",
        "quantity": 123.45,
        "usd_value": 678.90
      }
    ],
    "nft": [
      {
        "name": "NFTName",
        "symbol": "NFT",
        "quantity": 1,
        "usd_value": 5000
      }
    ]
  },
  "networth": {
    "token": 678.90,
    "nft": 5000
  },
  "total_assets": {
    "token": 1,
    "nft": 1
  }
}

Notes

  • The endpoint supports multiple chains, and the data retrieved will depend on the chain specified.

  • The networth field provides the total USD value of assets within the wallet.

  • The total_assets field counts the number of different types of assets (tokens and NFTs) in the wallet.

By utilizing the Wallet Endpoint, users can efficiently retrieve wallet balance and stats across different blockchain networks, enabling better management and monitoring of their assets within the TokenInfo.AI platform.

Last updated