Skip to content

Query aggregate

To query keys from an account aggregate, you need to call the fetch_aggregate function on the client.

Since version 0.8.0, only the asynchronous methods are available.

Usage

It exists two methods to query an aggregate:

  • fetch_aggregate: Query a single key
  • fetch_aggregates: Query all keys.
def fetch_aggregate(
    address,
    key,
)
def fetch_aggregates(
    address,
    key, # optional
)

Parameters

Parameter Type Description
address String The address of the aggregate to query.
key String The key of the aggregate to query.

Example

from aleph.sdk.client import AlephHttpClient

async def main():
    async with AlephHttpClient() as client:
        aggregate = await client.fetch_aggregates(
            "0xbC80BeEcBd67549E70cb1C729e903818E6370D37",
        )
        print(aggregate)
from aleph.sdk.client import AlephHttpClient

async def main():
    async with AlephHttpClient() as client:
        aggregate = await client.fetch_aggregate(
            "0xbC80BeEcBd67549E70cb1C729e903818E6370D37",
            "profile",
        )
        print(aggregate)

outputs:

respectively:

{'profile': {'bio': 'tester', 'name': 'Antony'}, 'testing': {'bio': 'tester', 'name': 'Antony'}}
{'bio': 'tester', 'name': 'Antony'}

Note

It is also possible to retrieve an aggregate from the API endpoint like this.