SharedPublic / PYTHON / 02-get-my-account-id.ipynbOpen in CoCalc
Use API to get account_id

Get Account ID for user who owns the api_key

# import utility definitions
%run ./01-utils.ipynb
# load credentials
uinfo = load_user_info("../../SECRET/testuser.yaml")
# make an API call
payload = {"query":{"accounts":{"account_id":None}}}
response = call_api("query", payload, uinfo['api_key'])
pp.pprint(response)
  
## expected result, last line contains the account id:
#
# {'event': 'query',
# 'id': '...'              # message id for the API request
# 'multi_response': False, # for internal use, may be ignored
# 'query': {'accounts': {'account_id': 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'}}} # this is the account id