Airstack Developer Docs & FAQs
  • ℹ️Introduction
Powered by GitBook
  1. Quickstart & SDKs

Python

Learn how to integrate Airstack APIs to your Python-based application using the Airstack Python SDK.

Last updated 7 months ago

Was this helpful?

🐍 Python

In this tutorial, you will learn how to start integrating API into your Python application.

Table Of Contents

Step 0: Pre-requisites

  • Completed

  • Git

  • Node v.16+

Step 1: Install Airstack Python SDK

Use a package manager to install the into your Python project:

pip install airstack

Step 2: Set Environment Variable

Create a new .env file:

touch .env
AIRSTACK_API_KEY=YOUR_AIRSTACK_API_KEY
pip install python-dotenv

and import it into your Python project to inject the environment variables:

index.py
from dotenv import load_dotenv

load_dotenv()

Step 3: Create API Client

index.py
import os
from airstack.execute_query import AirstackClient

api_key = os.environ.get("AIRSTACK_API_KEY")
if api_key is None:
  raise Exception("Please set the AIRSTACK_API_KEY environment variable")

api_client = AirstackClient(api_key=api_key)

Step 4: Call Your Query

index.py
import asyncio
from airstack.execute_query import AirstackClient

query = """
query MyQuery {
  Wallet(input: {identity: "vitalik.eth", blockchain: ethereum}) {
    socials {
      dappName
      profileName
    }
    addresses
  }
}
"""



async def main():
  execute_query_client = api_client.create_execute_query_object(query=query)
  query_response = await execute_query_client.execute_query()
  data = query_response.data
  error = query_response.error
  if query_response.error is not None:
    raise Exception(error.message)

  print(data)

asyncio.run(main())

The data variable will return and logged into your terminal as follows:

{
  "data": {
    "Wallet": {
      "socials": [
        {
          "dappName": "farcaster",
          "profileName": "vitalik.eth"
        }
      ],
      "addresses": ["0xd8da6bf26964af9d7eed9e03e53415d37aa96045"]
    }
  }
}

Developer Support

More Resources

Learn to build more with Airstack using our tutorials:

  • Resolve Identities

  • Wallet API Reference

Add the as the environment variable:

Install package to your project:

Wrap your application or React component with AirstackClient from the SDK to initialize it with the :

Once you have initialized the SDK, you can use the to call the Airstack API.

Below you have been provided with Airstack query to fetch the 0x address and Farcaster owned by :

If you have any questions or need help regarding integrating into your Python application, please join our Airstack's group.

🚀
🐍
Airstack API key
python-dotenv
Airstack API key
execute_query
vitalik.eth
Airstack
Telegram
Python SDK Reference
Airstack
Get API Key
Airstack Python SDK
Step 0: Pre-requisites
Step 1: Install Airstack Python SDK
Step 2: Set Environment Variable
Step 3: Create API Client
Step 4: Call Your Query