Async_#

Toplevel Subgrounds module

This module implements the toplevel API that most developers will be using when querying The Graph with Subgrounds.

class subgrounds.client.async_.AsyncSubgrounds(timeout=30, headers=<factory>, global_transforms=<factory>, subgraphs=<factory>, schema_cache=PosixPath('schemas'))#
property _client#

Cached client

async load(url, save_schema=False, is_subgraph=True)#

Performs introspection on the provided GraphQL API url to get the schema, stores the schema if save_schema is True and returns a generated class representing the GraphQL endpoint with all its entities.

async load_subgraph(url, save_schema=False)#

Performs introspection on the provided GraphQL API url to get the schema, stores the schema if save_schema is True and returns a generated class representing the subgraph with all its entities.

Parameters:
  • url (str) -- The url of the API

  • save_schema (bool) -- Flag indicating whether or not the schema should be cached to disk. Defaults to False.

  • cache_dir -- If save_schema == True, then subgraph schemas will be stored under cache_dir. Defaults to schemas/

Returns:

A generated class representing the subgraph and its entities

Return type:

Subgraph

async load_api(url, save_schema=False)#
Performs introspection on the provided GraphQL API url to get the

schema, stores the schema if save_schema is True and returns a generated class representing the GraphQL endpoint with all its entities.

Parameters:
  • url (str) -- The url of the API

  • save_schema (bool) -- Flag indicating whether or not the schema should be saved to disk. Defaults to False.

Returns:

A generated class representing the subgraph and its entities

Return type:

Subgraph

async execute(req, pagination_strategy=LegacyStrategy)#

Executes a DataRequest and returns a DataResponse.

Parameters:
  • req (DataRequest) -- The DataRequest object to be executed

  • pagination_strategy (Optional[Type[PaginationStrategy]]) -- A Class implementing the PaginationStrategy Protocol. If None, then automatic pagination is disabled. Defaults to LegacyStrategy.

Returns:

A DataResponse object representing the response

Return type:

DataResponse

async query_json(fpaths, pagination_strategy=LegacyStrategy)#

See query_json().

Parameters:
Returns:

The reponse data

Return type:

list[dict[str, Any]]

async query_df(fpaths, columns=None, concat=False, pagination_strategy=LegacyStrategy)#

See query_df().

Parameters:
Returns:

A pandas.DataFrame containing the reponse data.

Return type:

pandas.core.frame.DataFrame | list[pandas.core.frame.DataFrame]

async query(fpaths, unwrap=True, pagination_strategy=LegacyStrategy)#

See query().

Parameters:
Returns:

The FieldPath object(s) data

Return type:

str | int | float | bool | list | tuple | None