Python sdk for airstack apis
Project description
airstack-python-sdk
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.
Installation
pip3 install airstack
Getting started
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')
Methods
execute_query
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
Example
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()
execute_paginated_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
Example
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file airstack-0.0.7.tar.gz
.
File metadata
- Download URL: airstack-0.0.7.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0978a9c0e0eceef4f2286c550e16190a23df7d8ba87fb1b2e9c951ef9e38d292 |
|
MD5 | 46ba9cf3bcb2614d016bdc85699367c5 |
|
BLAKE2b-256 | cacdffaf2b2591f249f383515818b68986bd649565db80fb672394233996fe0d |
File details
Details for the file airstack-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: airstack-0.0.7-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01990f293360d2206a615798e1a0e85f311a563111a9700a69ae6e378245192e |
|
MD5 | 85a0d427f999451ff81955b4fa713fed |
|
BLAKE2b-256 | a6c0d59cbceed1c14f9e04a757e636acdb1897d8329028eab678081004b12b9e |