Balance Inquiry with the SDK
Follow these steps to install the SDK, authenticate, and query your balance.
Before you start, you need an API username and password. See the Quickstart if you have not created them yet.
1. Install the SDK
<dependency>
<groupId>com.pahappa.systems</groupId>
<artifactId>comms-sdk</artifactId>
<version>1.0.2</version>
</dependency>
pnpm add @pahappalimited/comms-sdk
# or: npm install @pahappalimited/comms-sdk
# or: yarn add @pahappalimited/comms-sdk
cargo add comms_sdk
implementation 'com.pahappa.systems:comms-sdk:1.0.2'
go get github.com/Pahappa-LTD/comms-go-sdk
pip install comms-sdk
dart pub add comms_sdk
# or, for Flutter projects:
flutter pub add comms_sdk
composer require pahappa-limited/comms-sdk
gem install comms_sdk
dotnet add package CommsSdk
Most commands above install the latest release. A version is pinned only where the build tool requires one (Maven and Gradle). For the current version of every SDK, see the SDK Downloads page.
2. Authenticate
import com.pahappa.systems.commssdk.v1.CommsSDK;
String apiUsername = "api_username";
String apiKey = "api_key";
CommsSDK sdk = CommsSDK.authenticate(apiUsername, apiKey);
const { CommsSDK } = require('@pahappalimited/comms-sdk');
const apiUsername = "api_username";
const apiKey = "api_key";
const sdk = CommsSDK.authenticate(apiUsername, apiKey);
use comms_sdk::CommsSDK;
let api_username = "api_username";
let api_key = "api_key";
let sdk = CommsSDK::authenticate(api_username, api_key)?;
import com.pahappa.systems.commssdk.v1.CommsSDK
val apiUsername = "api_username"
val apiKey = "api_key"
val sdk = CommsSDK.authenticate(apiUsername, apiKey)
import v1 "github.com/Pahappa-LTD/comms-go-sdk/v1"
apiUsername := "api_username"
apiKey := "api_key"
sdk := v1.CommsSDK.Authenticate(apiUsername, apiKey)
from comms_sdk import CommsSDK
api_username = "api_username"
api_key = "api_key"
sdk = CommsSDK.authenticate(api_username, api_key)
import 'package:comms_sdk/comms_sdk.dart';
const apiUsername = "api_username";
const apiKey = "api_key";
final sdk = await CommsSDK.authenticate(apiUsername, apiKey);
use PahappaLimited\CommsSDK\v1\CommsSDK;
$apiUsername = "api_username";
$apiKey = "api_key";
$sdk = CommsSDK::authenticate($apiUsername, $apiKey);
require 'comms_sdk'
api_username = "api_username"
api_key = "api_key"
sdk = CommsSDK.authenticate(api_username, api_key)
using Comms;
string apiUsername = "api_username";
string apiKey = "api_key";
var sdk = CommsSDK.Authenticate(apiUsername, apiKey);
The SDK targets the live server by default. If you are using sandbox credentials, switch environments before you authenticate:
| Language | Call |
|---|---|
| Java, Kotlin, JS / TS, Dart | CommsSDK.useSandBox() |
| Rust, PHP | CommsSDK::use_sandbox() |
| Python, Ruby | CommsSDK.use_sandbox() |
| Go | v1.CommsSDK.UseSandBox() |
| C# | CommsSDK.UseSandBox() |
Call useLiveServer / use_live_server to switch back. Sandbox credentials do not work against the live server, and vice versa.
3. Query balance
There are two ways to read your balance:
getBalancereturns the balance as a number.queryBalancereturns anApiResponsewith the full result, includingstatusandbalance.
Both default to the local wallet. To query the international wallet instead, pass a WalletType — every language's tab below shows how.
import com.pahappa.systems.commssdk.v1.models.ApiResponse;
import com.pahappa.systems.commssdk.v1.models.WalletType;
// just the balance (local wallet)
double balance = sdk.getBalance();
System.out.println("Balance: " + balance);
// full API response instead of a number
ApiResponse balanceQuery = sdk.queryBalance();
System.out.println(balanceQuery.status + " and balance: " + balanceQuery.balance);
// a specific wallet's balance
double internationalBalance = sdk.getBalance(WalletType.INTERNATIONAL);
System.out.println("International balance: " + internationalBalance);
const { WalletType } = require('@pahappalimited/comms-sdk');
// just the balance (local wallet)
const balance = await sdk.getBalance();
console.log("Balance: " + balance);
// full API response instead of a number
const balanceQuery = await sdk.queryBalance();
console.log(balanceQuery.status + " and balance: " + balanceQuery.balance);
// a specific wallet's balance
const internationalBalance = await sdk.getBalance(WalletType.INTERNATIONAL);
console.log("International balance: " + internationalBalance);
use comms_sdk::WalletType;
// just the balance (local wallet)
let balance = sdk.get_balance().unwrap();
println!("Balance: {}", balance);
// full API response instead of a number
let balance_query = sdk.query_balance().unwrap();
println!("{:?} and balance: {:?}", balance_query.status, balance_query.balance);
// a specific wallet's balance
let international_balance = sdk.get_balance_full(Some(WalletType::International)).unwrap();
println!("International balance: {}", international_balance);
import com.pahappa.systems.commssdk.v1.models.WalletType
// just the balance (local wallet)
val balance = sdk.getBalance()
println("Balance: $balance")
// full API response instead of a number
val balanceQuery = sdk.queryBalance()
println(balanceQuery.status.toString() + " and balance: " + balanceQuery.balance)
// a specific wallet's balance
val internationalBalance = sdk.getBalance(WalletType.INTERNATIONAL)
println("International balance: $internationalBalance")
import "github.com/Pahappa-LTD/comms-go-sdk/v1/models"
// just the balance (local wallet)
balance, _ := sdk.GetBalance()
fmt.Printf("Balance: %v\n", balance)
// full API response instead of a number
balanceQuery, _ := sdk.QueryBalance()
fmt.Printf("%v and balance: %v\n", balanceQuery.Status, balanceQuery.Balance)
// a specific wallet's balance — Go has no overloading, so the
// wallet-type-taking variants use a "Full" suffix
internationalBalance, _ := sdk.GetBalanceFull(models.International)
fmt.Printf("International balance: %v\n", internationalBalance)
from comms_sdk.v1.models import WalletType
# just the balance (local wallet)
balance = sdk.get_balance()
print("Balance: " + str(balance))
# full API response instead of a number
balance_query = sdk.query_balance()
print(str(balance_query.status) + " and balance: " + str(balance_query.balance))
# a specific wallet's balance
international_balance = sdk.get_balance(wallet_type=WalletType.INTERNATIONAL)
print("International balance: " + str(international_balance))
// just the balance (local wallet)
final balance = await sdk.getBalance();
print("Balance: $balance");
// full API response instead of a number
final balanceQuery = await sdk.queryBalance();
print("${balanceQuery.status} and balance: ${balanceQuery.balance}");
// a specific wallet's balance
final internationalBalance = await sdk.getBalance(walletType: WalletType.international);
print("International balance: $internationalBalance");
use PahappaLimited\CommsSDK\v1\models\WalletType;
// just the balance (local wallet)
$balance = $sdk->getBalance();
echo "Balance: " . $balance . "\n";
// full API response instead of a number
$balanceQuery = $sdk->queryBalance();
echo $balanceQuery->status . " and balance: " . $balanceQuery->balance . "\n";
// a specific wallet's balance
$internationalBalance = $sdk->getBalance(WalletType::INTERNATIONAL);
echo "International balance: " . $internationalBalance . "\n";
# just the balance (local wallet)
balance = sdk.get_balance
puts "Balance: #{balance}"
# full API response instead of a number
balance_query = sdk.query_balance
puts "#{balance_query.status} and balance: #{balance_query.balance}"
# a specific wallet's balance
international_balance = sdk.get_balance(wallet_type: CommsSdk::V1::WalletType::INTERNATIONAL)
puts "International balance: #{international_balance}"
using Comms.Models;
// just the balance (local wallet)
double balance = sdk.GetBalance();
Console.WriteLine("Balance: " + balance);
// full API response instead of a number
var balanceQuery = sdk.QueryBalance();
Console.WriteLine(balanceQuery.Status + " and balance: " + balanceQuery.Balance);
// a specific wallet's balance
double internationalBalance = sdk.GetBalance(WalletType.International);
Console.WriteLine("International balance: " + internationalBalance);
For query-based methods, the returned object is of type ApiResponse. See ApiResponse.
Next steps
- API Reference — the underlying JSON request and response.
- SDK & Model Reference — every function, enum, and model.
- Error Handling — what to do when a request fails.