Balance Function

General

The Balance API function allows you to get the balance of all available currencies for a specified wallet.

Function

List <Balance> Balance(
string signature,
integer apiKeyID,
long integer nonce,
string walletID);

Parameters

Argument Type Description Example
signature string This parameter consists of a SHA256 hashed line of text formed by concatenating using ":" as a delimiter for the parameters list in alphabetical order and the APIKeyPassword at the end. Detailed instructions can be found in the Authorization scheme section. "5950F9BDA723ECDF9859AD205412BB44...
...E0DAB16630CA4462490DE64B02305F8D"
apiKeyID integer The API Key ID user wishes to perform an API call. "123456"
nonce long integer Variable parameter, so that an attacker intercepting traffic could not repeat the operation by sending the same request. Read more about nonce here. "123456789101112"
walletID wallet ID string The wallet user wishes to query with enabled API access. "WZ123456789"

Return Value

A general JSON Response containing a Balance structure.

Response Sample

  [
    {
      "CurrencyCode": "EUR",
      "TotalAvailable": 0.0
    },
    {
      "CurrencyCode": "GBP",
      "TotalAvailable": 1.36
    }
  ]

Error Handling

This function can throw only Authentication and Security exceptions.

Code Samples

Sample in PHP
             <?php
 	$apiPassword = "YourApiPassword";
 	$apiKeyID = "YourApiKey";
 	$okWallet = "#prefixAccount#123456789";
 	$apiURL = "https://api.weezzo.com/v2/";
 	$methodName = "Balance";
 
 	//Incoming parameters
 	$parameters = array(
 		'walletID' => $okWallet,
 		'apiKeyID' => $apiKeyID,
 		'nonce' => time(),
 	);
 
 	//1. Sort the parameter values by their name (in alphabetical order)
 	ksort($parameters);
 
 	//2. Form a string from the parameter values, using ":" as a delimiter, add API password at the end of this line using the same ":" delimiter
 	$data = implode(":", $parameters) . ":" . $apiPassword;
 	//3. Generate signature and add it to parameters
 	$parameters["signature"] = hash('sha256', $data);
 
 	//4. Encode parameters and send it to the server
 	$url = $apiURL . $methodName . "?" . http_build_query($parameters);
 
 	echo file_get_contents($url);
Sample in C#
             
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Net;
 using System.Text;
 using System.Threading.Tasks;
 using System.Web; //Add reference to System.Web
 
 namespace TestAPI
 {
     class Program
     {
 	      static void Main(string[] args)
         {
             string apiPassword = "YourApiPassword";
             string apiKeyID = "YourApiKey";
             string okWallet = "#prefixAccount#123456789";
             string apiURL = @"https://api.weezzo.com/v2/";
             string methodName = "Balance";
 
             long nonce = DateTime.UtcNow.Ticks;
 
             //Incoming parameters
             Dictionary<string, string> parameters = new Dictionary<string, string>();
             parameters["walletID"] = okWallet;
             parameters["apiKeyID"] = apiKeyID;
             parameters["nonce"] = nonce.ToString();
 
             //1. Sort the parameter values by their name (in alphabetical order)
             parameters = parameters.OrderBy(x => x.Key).ToDictionary(x => x.Key, y => y.Value);
             //2. Form a string from the parameter values, using ":" as a delimiter, add API password at the end of this line using the same ":" delimiter
             string data = string.Join(":", parameters.Values) + ":" + apiPassword;
             //3. Generate signature and add it to parameters
             parameters["signature"] = GetSHA256Hash(data);
 
             //4. Encode parameters and send it to the server
             string url = apiURL + methodName + "?" + string.Join("&", parameters.Select(c => HttpUtility.UrlEncode(c.Key) + "=" + HttpUtility.UrlEncode(c.Value)));
             string result = null;
             using (WebClient wc = new WebClient())
             {
                result = wc.DownloadString(url);
             }
             Console.WriteLine(result);
             Console.ReadLine();
         }
 
         internal static string GetSHA256Hash(string input)
         {
             using (var sha256 = System.Security.Cryptography.SHA256.Create())
             {
                 var arr = System.Text.Encoding.ASCII.GetBytes(input);
                 arr = sha256.ComputeHash(arr);
                 return BitConverter.ToString(arr).Replace("-", "");
             }
         }
     }
 }
Sample in Python
            import time
import collections
from hashlib import sha256
from urllib import request, parse
apiPassword = "YourApiPassword"
apiKeyID = "YourApiKey"
okWallet = "#prefixAccount#123456789"
apiURL = "https://api.weezzo.com/v2/"
methodName = "Balance"
#Incoming parameters
parameters = {
'walletID': okWallet,
'apiKeyID': apiKeyID,
'nonce': int(time.time())
}
#1. Sort the parameter values by their name (in alphabetical order)
parameters = collections.OrderedDict(sorted(parameters.items()))
#2. Form a string from the parameter values, using ":" as a delimiter, add API password at the end of this line using the same ":" delimiter
data = ":".join(str(value) for value in parameters.values()) + ":" + apiPassword
#3. Generate signature and add it to parameters
parameters['signature'] = sha256(data.encode('utf-8')).hexdigest()
#4. Encode parameters and send it to the server
url = apiURL + methodName + "?" + parse.urlencode(parameters)
with request.urlopen(url) as url:
data = url.read()
print(data)
Sample in NodeJS
             var https = require('https');
 var crypto = require('crypto');
 
 var apiPassword = "YourApiPassword";
 var apiKeyID = "YourApiKey";
 var okWallet = "#prefixAccount#123456789";
 var apiURL = "https://api.weezzo.com/v2/";
 var methodName = "Balance";
 
 //Incoming parameters
 var parameters = {
    walletID: okWallet,
    apiKeyID: apiKeyID,
    nonce: Math.floor(new Date().getTime() / 1000)
 }
 
 //1. Sort the parameter values by their name (in alphabetical order)
 var parameters_sorted = {}
 var values = new Array();
 
 Object.keys(parameters)
 	.sort()
 	.forEach(function(v, i) {
 		parameters_sorted[v] = parameters[v]
 		values.push(parameters[v]);
 	});
 
 //2. Form a string from the parameter values, using ":" as a delimiter, add API password at the end of this line using the same ":" delimiter
 var data = values.join(":") + ":" + apiPassword;
 
 //3. Generate signature and add it to parameters
 parameters_sorted['signature'] = crypto.createHash('sha256').update(data).digest('hex');
 
 //4. Encode parameters and send it to the server
 var url = apiURL + methodName + "?";
 
 Object.keys(parameters_sorted).map(function(objectKey, index) {
 	url += "&" + objectKey + "=" + encodeURIComponent(parameters_sorted[objectKey]);
 });
 
 https.get(url, function(res) {
 	var body = '';
 
 	res.setEncoding('utf8')
 
 	res.on("data", function(chunk) {
 		console.log(chunk);
 	});
 
 	res.on('end', function() {
 		console.log(body);
 	});
 }).on('error', function(e) {
 	console.error(e);
 });