Skip to main content
Version: Next

Code Examples for checking account balance

All examples use JSON requests and check the local wallet balance (which is the default when the walletType is omitted).

Pick your preferred language.

With OkHttp 3
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.12.13</version>
</dependency>
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
String json = """
{
"method": "Balance",
"userdata": {
"username": "api_username",
"password": "api_key"
},
"walletType": "Local"
}
""";
RequestBody body = RequestBody.create(mediaType, json);
Request request = new Request.Builder()
.url("https://comms.egosms.co/api/v1/json/")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();