Return application local state for a specific account with IndexerClient

I would try to return application local state for a specific account. I’m trying to use indexer with PureStake.

#initialize an indexerClient 
    headers = {
   "X-API-Key": "my_key_purestake",
    indexer_client = indexer.IndexerClient("", "", headers)

I found this method v2client.indexer — algosdk documentation ( but does not appear in visual studio, as if it were not available.

In fact, if I try to call it:

#initialize an indexerClient 
    headers = {
   "X-API-Key": "my_key_purestake",
    indexer_client = indexer.IndexerClient("", "", headers)

it returns an error:

Traceback (most recent call last):
File “c:\Users\loren\OneDrive\Desktop\algorand_project\project\contracts\my_sasso_carta_forbici\”, line 500, in
File “c:\Users\loren\OneDrive\Desktop\algorand_project\project\contracts\my_sasso_carta_forbici\”, line 414, in main
AttributeError: ‘IndexerClient’ object has no attribute ‘lookup_account_application_local_state’

Not sure about “lookup_account_application_local_state” but you can find local state of all apps for an account using “account_info”.

Here is the documentation:

The response contains local states of all apps that the account has opted-in. You need to iterate over the local states and find it based on the app-id.


Ok perfect! I have implemented method like this:

#account_address: public key account, app_id: application id, indexer: IndexerClient
def read_local_state (account_address, app_id, indexer) -> None:
    account_info = indexer.account_info(account_address)
    dict_account  = account_info['account']
    dict_local_state = dict_account['apps-local-state']
    for x in dict_local_state:
        if x['id'] == app_id:
            dict_key_value = x['key-value']
            for y in dict_key_value :
                key = y['key'] #key in b64
                key_b64_bytes = key.encode('ascii')
                msg_bytes = base64.b64decode(key_b64_bytes)
                key_ascii = msg_bytes.decode('ascii') #key in ascii
                value = y['value']
                print("key:",key_ascii, ", value:", value)
1 Like

Perfect. please mark the above as a solution.