The Airstack Python SDK is a library that allows Python developers to integrate Airstack's blockchain functionalities into their applications. With this SDK, developers can perform various tasks, such as querying and fetching data from smart contracts, displaying NFT assets.
pip3 install airstack
To use the SDK you will need airstack api-key, which you can find in your profile setting section in airstack web, once you have it you can initialise the Airstackclient with the api-key.
from airstack.execute_query import AirstackClient
api_client = AirstackClient(api_key='api-key')
The execute query method query the data and return the data in asynchronous, it returns query_response which has below data
query_response.data
: data returned by the queryquery_response.status_code
: status code of the query responsequery_response.error
: any error that occurred while loading the query
from airstack.execute_query import AirstackClient
api_client = AirstackClient(api_key='api-key')
execute_query_client = api_client.create_execute_query_object(query=query, variables=variables)
query_response = await execute_query_client.execute_query()
Note: pagination methods only works with queries that has support for pagination, and the query passed to method must have a cursor as argument for it to work.
The execute_paginated_query
method provides a simple way to paginate the data returned by a query. It works the same as the execute_query
method, it returns query_response which has below data:
query_response.data
: data returned by the queryquery_response.status_code
: status code of the query responsequery_response.error
: any error that occurred while loading the queryquery_response.has_next_page
: a boolean indicating whether there is another page of data after the current pagequery_response.has_prev_page
: a boolean indicating whether there is another page of data before the current pagequery_response.get_next_page
: a function that can be called to fetch the next page of dataquery_response.get_prev_page
: a function that can be called to fetch the previous page of data
from airstack.execute_query import AirstackClient
api_client = AirstackClient(api_key='api-key')
execute_query_client = api_client.create_execute_query_object(query=query, variables=variables)
query_response = await execute_query_client.execute_paginated_query()
if query_response.has_next_page:
next_page_response = await query_response.get_next_page
if next_page_response.has_prev_page:
prev_page_response = await query_response.get_prev_page