# Wallet API

### 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:

```http
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**:

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

#### Error Responses

1. **Missing Parameters**

   * **Status Code**: `400 Bad Request`
   * **Response Body**:

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

   * **Status Code**: `500 Internal Server Error`
   * **Response Body**:

   ```json
   {
     "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**:

```json
{
  "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**:

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

   * **Status Code**: `500 Internal Server Error`
   * **Response Body**:

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

#### Example Request

```http
GET /wallet/1/0xYourWalletAddress/stats
```

#### Example Response

```json
{
  "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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://coat.gitbook.io/tokeninfo.ai/wallet-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
