Get Account

Retrieve all profile data for an account, along with the account's verification status

Accounts Overview

🚧

Use Masquerading

If you're requesting an account which is not your own because you're acting on behalf of the account holder, you will need to use the masqueradeAs URL parameter. Both accounts/{accountId} and masqueradeAs={accountId} should be the sub account value.

You will encounter AccessDeniedException responses if you attempt to access a different account without this.

Sample
https://api.testwyre.com/v3/accounts/AC_B8J8NTYRY2G?masqueradeAs=AC_B8J8NTYRY2G

################### Get Wyre Account Information ###################
# In this example below, we are using the test environment at api.testwyre.com
# When you are ready, use the production url: https://api.sendwyre.com

curl -X GET \
-H "Authorization: Bearer SK-XXXXXXXX-XXXXXXXX-XXXXXXXX-XXXXXXXX" \
https://api.testwyre.com/v3/accounts/:accountId
#Ex: https://api.testwyre.com/v3/accounts/AC_XXXXXXXXXX
'''
This is a Python 3.7 Module that gets a Wyre Account
information using secret key authentication.

You can only use this module for getting individual
or business accounts if you already have an account set up.

If you do not have a business or individual account with a secretKey/ApiKey,
go through the sign-up process for a test account here: https://www.testwyre.com/
'''
import hashlib
import hmac
import json
import os
import requests
import time
import urllib.parse


class WyreApi:
    ACCOUNT_ID = os.getenv("ACCOUNT_ID")
    API_KEY = os.getenv("WYRE_APIKEY")
    SEC_KEY = os.getenv("WYRE_TOKEN")
    API_VER3 = "/v3"
    API_ACCOUNT_PATH = "/accounts"
    API_URL = "https://api.testwyre.com"

    '''
        This method calculates the auth signature hash required for secret key 
        authentication
    '''

    def calc_auth_sig_hash(self, url_body):
        # calculates a signature per Wyre API:
        # https://docs.sendwyre.com/docs/authentication#secret-key-signature-auth
        message, secret = bytes(
            url_body, 'utf-8'), bytes(WyreApi.SEC_KEY, 'utf-8')
        newhash = hmac.new(secret, message, hashlib.sha256)
        return newhash.hexdigest()

      
      
      
      
    '''
        This method calculates a timesteamp required for the secret key 
        authentication
    '''

    def calcTimeStamp(self):
        # creates a timestamp to the millisecond
        return str(round(time.time() * 1000))
      
      
      
      
    '''  
     		This method gets account information and returns it as a json object
        Prints an error message if call is unsuccessful.
    '''
    def getAccountInfo(self):
        params = {
            "timestamp": self.calcTimeStamp()
            # If you are masquerading (acting on behalf) of your subaccount
            # enter your account_id associated with your business account
            # You could add that field in when passing data into the method
            # "masqueradeAs": "ENTER ACCOUNT ID HERE"
        }
        url = WyreApi.API_URL + WyreApi.API_VER3 + WyreApi.API_ACCOUNT_PATH + \
            "/" + WyreApi.ACCOUNT_ID + "?" + \
            urllib.parse.urlencode(params, encoding='utf-8')

        headers = {
            'X-API-Key': WyreApi.API_KEY,
            'X-API-Signature': self.calc_auth_sig_hash(url)
        }
        response = requests.get(url, headers=headers)
        if response.status_code == 200:
            return json.loads(response.text)
        else:
            print(response)


if __name__ == "__main__":
    #=========== Initializes a Wyre Obj ============= #
    account = WyreApi()
    response = account.getAccountInfo()
    # response is the server response
    if response:
    	print(response)
Language
Credentials
Bearer
URL
Click Try It! to start a request and see the response here!