Skip to content

Instantly share code, notes, and snippets.

@benrules2
Created October 29, 2016 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benrules2/34be7f85d9a6af499717467199fb4eb5 to your computer and use it in GitHub Desktop.
Save benrules2/34be7f85d9a6af499717467199fb4eb5 to your computer and use it in GitHub Desktop.
Get Balance
def get_balance(base_url, username, password):
url = base_url + "/v1/client/balance"
b64str = base64.b64encode("{}:{}".format(username,password).encode('utf-8'))
headers = {'Content-length' : '0',
'Content-type' : 'application/json',
'Authorization' : "Basic " + b64str.decode('utf-8')}
req = ulib.Request(url, headers=headers)
responseData = ulib.urlopen(req).read()
balance = json.loads(responseData.decode('utf-8'))
return balance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment