Page cover

Wallet Aggregator: Managing Multiple Wallets

1.1 Wallet Aggregator Overview

Wallet Aggregator module provides functionality for managing multiple cryptocurrency wallets in one unified interface. It allows users to track, monitor, and manage various wallet accounts across multiple blockchain networks, streamlining the process of handling diverse assets. This guide provides API examples to assist developers in integrating and utilizing wallet management capabilities through the Wallet Aggregator’s REST API.


1.2 GET /wallets

Parameters:

  • user_id (string, required): Unique identifier of the user.

  • limit (integer, optional): The maximum number of wallets to return.

Request

curl -X GET "https://api.capsurelabs.com/wallets?user_id=12345&limit=10" -H "Authorization: Bearer <token>"

Response

{
  "status": "success",
  "wallets": [
    {
      "wallet_id": "1",
      "name": "Main Wallet",
      "balance": "3.5 ETH",
      "network": "Ethereum"
    },
    {
      "wallet_id": "2",
      "name": "Savings Wallet",
      "balance": "1.2 BTC",
      "network": "Bitcoin"
    }
  ]
}

1.3 POST /wallets/add

Parameters:

  • user_id (string, required): User's unique identifier.

  • wallet_address (string, required): Public address of the wallet.

  • network (string, required): Blockchain network (e.g., Ethereum, Bitcoin, Polygon).

Request

curl -X POST "https://api.capsurelabs.com/wallets/add" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
        "user_id": "12345",
        "wallet_address": "0xabc123...",
        "network": "Ethereum"
      }'

Response

{
  "status": "success",
  "message": "Wallet added successfully",
  "wallet_id": "3"
}

1.4 GET /wallets/{wallet_id}/balance

Parameters:

  • wallet_id (string, required): Unique identifier of the wallet.

Request

curl -X GET "https://api.capsurelabs.com/wallets/3/balance" -H "Authorization: Bearer <token>"

Response

{
  "status": "success",
  "balance": {
    "ETH": "2.3",
    "USD_value": "6700.45"
  }
}

1.5 POST /wallets/{wallet_id}/transfer

Parameters:

  • wallet_id (string, required): ID of the source wallet.

  • recipient_address (string, required): Public address of the recipient.

  • amount (string, required): Amount to transfer.

  • currency (string, required): Type of cryptocurrency (e.g., ETH, BTC).

Request

curl -X POST "https://api.capsurelabs.com/wallets/3/transfer" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
        "recipient_address": "0xdef456...",
        "amount": "0.5",
        "currency": "ETH"
      }'

Response

{
  "status": "success",
  "transaction_id": "txn_98765",
  "message": "Transfer initiated"
}

1.6 GET /wallets/sync

Parameters:

  • user_id (string, required): Unique identifier of the user.

Request

curl -X GET "https://api.capsurelabs.com/wallets/sync?user_id=12345" -H "Authorization: Bearer <token>"

Response

{
  "status": "success",
  "message": "Wallets synchronized successfully"
}

1.7 Aggregating Balances with JavaScript (Node.js)

const axios = require('axios');

// Set the user ID and authorization token
const userId = '12345';
const authToken = 'Bearer <token>';

// Fetch all wallets and calculate total balance in ETH
async function aggregateBalance() {
    try {
        const response = await axios.get(`https://api.capsurelabs.com/wallets?user_id=${userId}`, {
            headers: { Authorization: authToken }
        });
        
        const wallets = response.data.wallets;
        let totalBalance = 0;

        for (const wallet of wallets) {
            const balanceResponse = await axios.get(`https://api.capsurelabs.com/wallets/${wallet.wallet_id}/balance`, {
                headers: { Authorization: authToken }
            });
            
            totalBalance += parseFloat(balanceResponse.data.balance.ETH || 0);
        }

        console.log(`Total ETH balance: ${totalBalance}`);
    } catch (error) {
        console.error("Error fetching wallet balances:", error.message);
    }
}

aggregateBalance();

Postman Collection

{
  "info": {
    "name": "Wallet Aggregator API",
    "description": "API for managing multiple wallets",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "item": [
    {
      "name": "Get Wallet List",
      "request": {
        "method": "GET",
        "header": [
          { "key": "Authorization", "value": "Bearer <token>" }
        ],
        "url": {
          "raw": "https://api.capsurelabs.com/wallets?user_id=12345",
          "host": ["https://api.capsurelabs.com"],
          "path": ["wallets"],
          "query": [{ "key": "user_id", "value": "12345" }]
        }
      }
    }
  ]
}

Last updated