Airstack 🛠️ One API for all your web3 data integrations - Jason Goldberg, Sarvesh Jain
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Join Jason Goldberg and Sarvesh Jain from Airstack for a workshop titled "One API for all your web3 data integrations". Welcome to back to ETHGlobal Waterloo, where it all began! Returning to Canada's tech hub, we're thrilled to bring together international enthusiasts and local talent for an unforgettable hackathon experience. This year we had 650+ attendees from 29 different countries and 47% were new to Web3! We concluded the weekend with 168 projects submitted and gave away $250,000+ in prizes ----------------- Follow us: https://twitter.com/ETHGlobal Check us out: https://ethglobal.com Email us at: hello@ethglobal.com
Transcript
Well. Hi everyone. I'm Jason and this is Sares from Airirststack. Today we will show you how to create applications using Airirststack and how to use the APIs using Airirststack and how to use the APIs . First of all, Airstack is a single API that allows you to query and combine data across projects and chains in a single query and response.
Today we have APIs that manage blockchains like Ethereum, Polygon, every transaction from the genesis block, and new transactions within seconds as soon as they are finalized, as well as being very powerful in areas like identity. So ENS, Farcaster Lens, POP, NFTTS, social and so on. Many products use Airstack for identity resolvers, to build recommendation engines, and to build all kinds of new dataware experiences. Sarbish will show you exactly how to use Airstack and what APIs are involved. I'll show you the cheat codes very quickly first and then Sarish will go into detail.
But if you go to airstack xyz app you will first see a marketplace of queries that other people have run and shared with the community. So after you run a query, if you want, you can share it. So here are popular queries like recent token die transfers, apecoin metal balance, bulky, and actually executed queries. The cheat codes I will show you are Sarbash which will show you how to write queries from scratch. Cheat codes use our AI generator to write the query for you.
I actually recommend trying it out to get started because it's a great way to learn APIs very quickly. If you look on the left side, these are all the APIs that airstack offers, and I can write a query that goes cross-chain and the AI will write it for me. So I can say, “Show me all the Orange dow .this holders,” and we have a selector where you can select it from about 10,000 different tokens, co-ops, NFT projects, Orange dow on Polygon. And I can say, "What about their social web 3 and ENS," and Airstack's AI will generate that query for you.
Um, and so here you can see that it's entering "get token balances" of this contract address. He's searching on Polygon, he's getting the top 10, you can increase the number of responses and for each person he's getting the token balance that they have, the owners, um, their domains, primary domains and their socials. And so here, as you can see that, um, Orange dow, um, this token holder, his Lens name is Byron sue.lens lens his Lens name is Byron sue.lens lens .
You can see his ENS names and you can see this for the next person see this for the next person , the next person, the next person. Now, this is a great way to learn how to use APIs. I'll make another one just to show you that you can do this in all different directions too. So I can say, for Steini. Showcase your NFTs and their images.
And so here we are combining, we are getting stunni.lens as you know obviously he is the founder of Lens. This is an address on Lens which is on Polygon which resolves it to a 0x address. So let's go find all of his NFTs. And also get images that we've resized so you don't have to go to IPFS and get them yourself.
So here are Stany's NFTs as an example. So let me go to Sarvves and he will give you a whole tutorial on how to use the API. Excuse me. Yes, it's nice. Yes.
Yes. Okay. So, I'm going to spend the next few minutes reviewing what's currently possible with the Airstrike APIs, and then I'll talk about a couple of use cases you can build with the APIs right now. In this diagram, you can see that we are currently active on Ethereum and Polygon Chain, and on the left side, we have the most basic building blocks of any blockchain-based project . So we have all the tokens, NFTs, balances and transfers for the NFTs.
We have offchain metadata and image resizing. We have a whole vertical identity, like this, where a lot of people are integrating Abstract. Then you can query all ENS domains and their primary domains. We have Lens and Forecaster. You can query PO apps with Airstrike right now.
And then on the last side we have sales data from NFTs, such as sales from OpenC Blur and Variable. We also aggregate this sales data at a specific NFT level, or at a connection collection level, or at a market level, and this aggregation occurs across multiple timelines, such as daily, weekly, monthly, yearly, and lifetime. This slide is a basic summary of what you can build with Air Strike today at this hackathon, and these are a couple of use cases that we think are very easy to build on AirStrike right now. This is not an exhaustive list; you can add, because it's a generic product, so you can add more. But to proceed, the first thing is the identity resolver, so I'll create a couple of queries from this use case, I think three or four.
But if you have a zerox or ENS address, you can actually ask about lengths for Caster POPS, NFT. So this is an identity resolver. Similarly, you can create groups if you are building a chat application and want to understand which groups you should create which groups you should create . Then you can create groups based on NFT holders or the POPS of the event they attended together. So it 's possible.
Today I will create this recommendation engine. So a simple POPS-based recommendation engine. So if you have a goal profile and you need to recommend which other goal profile should follow that profile. So, based on similar events that are happening, I will try to build a recommendation engine today. Token balances, transfer history , and token earnings are certainly highly possible.
Then you can use the Token Balances API and put a wallet into a token address and check whether the wallet has a token or not. This new thing we are looking at can be used for ZKistration. So you can prove what is true on-chain and then est can be a source of truth and then you can generate proofs and validate with other protocols that are here for this. And another area we're looking at is creating really cool visualizations on strike. So we have a lot of data on NFT and ENS and POP sales.
So you can actually create a visualization like find me the joint portfolios that participated in East and East Water. So many of these visualizations are possible. I'll go through a couple of use cases. Then I will prepare the queries that I will create. I'll start with a very simple query.
I want to create a use case to get tokens. I want to create token balances along with NFT images and metadata. So I'm going to go here on the wallet. Yes. I have the full list of APIs here, but to get tokens I want to create with the token balance.
Then I will select the token balance. I will filter by portfolio. Then I'll select this as a variable and select all the fields I want as output. So I definitely need the amount and since I'm retrieving the balance, I need to query the name and symbol and if the balance is for NFTs, then it makes sense to also ask about any images or metadata. So I'll select those fields and yes, from the token I should also select the address and token ID, right?
So, these are all the fields I will be using for the query. Let's now move on to the filters part. We have a very complex set of filters that are allowed, so you have AND, OR, NOR in the clause, so all the clauses that you have used in any SQL or database programming language, you can create these types of filters in the ads. So, I'll add a filter on the owner, right? And so my query is complete.
Now I'll add a variable. Then it completes automatically. Okay. So just recharge it . Yes, it loads correctly now.
I quickly recreate the same query. I select the amount, token, address, name, and symbol from the NFTs. I will select the images. I'll rename my query variable to something more meaningful. So I'll call it identity and put it here in the variables.
So now you should be able to tell me this little field. I'm sorry about that. Yes, I only use this. Yes. Okay, we're ready with the query.
So let's say I first want to create getting tokens and I want to fetch balances based on the ENS name. So I just entered Falik's ENS. So it is possible. Um, you could, if you're integrating with Lens or Lens, you could also put a Lens profile in here, so you can also run queries based on the Lens profile. You can get the same result.
Um, sure, you can enter a wallet address, so I'll just select my wallet. Yes, so this is possible too. Now, let's say you're creating a token getting, so not only the owner, but you also want to add a filter on the token, so you'll add a filter here and you can just enter your token address. See, I have the token. So this query can help us help you create token getting applications.
Let's move on to the next use case. So the next use case is more about identity. So you want to find out who owns the Moonbird collection, and you also want to know what their social media profiles and main social media handles are. Then the holders are refunded from the token balance. So I'll use the same type of query again but, again, the token address for me is moonbirds.
So I'll change it to moons. I'm not interested in the owner right now because I 'm looking for all the owners. So I'll remove it. Okay. Now I'm interested in the owners' social media profiles.
So in owners, the owner represents a wallet and you can ask any question about the wallet from this field. So you can ask on social profiles. I will select the DAP name and profile name. Similarly, you can select ENS domains. We also have a primary domain if you're interested.
So this completes the query. We can just run it query. We can just run it . So it gives you all the moonbirds holders and it will also give you all the domains and primary domains of those holders. Let's see some of the interesting data points here.
Ok, one more thing, you can add, ask for 200 records at once. So initially by default it takes 10. Then I'll add 200. So you can see that you're getting a lot more records. You can see that this moonbird is held by this lens profile which has this ENS and this is also a primary ENS for it.
So you can solve many identities with this combination. Ok, now the last two queries are more similar to the recommendation engine I'm trying to build today. So the use case is that I have a lens profile and I want to know which events I attended. This is the first part of the query and the second part is from an event I attended, I will find out what other slow OS profiles were attending the same event. So I'll create the first one.
So the first query is used to create the lens profile. Given the lens profile, find the po. So since I'm querying POPS since I'm querying POPS , I need to go to the POPS API and my input is a lens profile. So this is an identity for me. Then I will select the owner.
Then from the PO apps I will retrieve some details about the pop-up event itself. Then the description and name of the event. That's it. If you want we can change the names of the variables. They're not that pretty, but I'll leave them as they are for now.
Okay. This is my target profile and I can also select the event ID. Yes. Okay. Let me see what's going on here.
Let me try here. Yes. So I'll ask about the event. I will select other fields. Event name.
I can simply run this query. So you can see that I have attended these events. One of these events is 8 danward 2023. So the event ID is 103093. So I will only remember this one.
So here the input was a target profile. So I could see that this target profile attended this event. Now, to build the recommendation engine, you also need to figure out what other target profiles participated in the ETH dan. Right? So this is my second query.
So recover the social web 3 in the NS primary school. So people who frequented East Danville. So this time I'm back in the POPS API, but this time I want to filter by Event ID and ETH Denver Event ID. I'll use this event ID that I got in the previous query and insert it here. Now in this case I want the target profile of the participants, so I'll go to the owner and select the social and tap on the name and profile name tap on the name and profile name .
If I put it here, I get the target profile. So not everyone has a target profile, but I can also select user identities and addresses . So it will at least give me the wallet addresses. Yes. So if you can see that this target profile also attended ETH Denver.
So if you're building an application that has a social aspect, you can actually build a recommendation engine with these kinds of queries. I can also add more records. So you'll see more data coming in . So there's also a profile on the forecaster who frequented East Denver. So, by combining these two queries, I can create a simple recommendation engine where I find people based on the same activity on POPS.
Right. Okay. Let me show you two more queries. I want to show this social query in bulk once. Okay.
So, we have this wallet API and we have the social API. Sometimes you have a use case where you want to require more than one wallet. So you want to search for 100 of these wallets, right? So here we're using something called an in clause. In the in clause called an in clause.
In the in clause , you can pass an array of addresses at once and you can select them as puts. So in this query, I'm typing as if I'm searching based on an identity, so the identity here is a wallet address. So, I have 100 wallet addresses and I'm asking for social profiles for those wallets, so I'm getting all the results in one query for. So, you can bulk request information from 200 profiles at once, okay? Along with that, uh, so if you're building your own apps, we currently have two SDKs: React and Python.
I can quickly show you what the SDK looks like and how you can add these queries to the SDK and get the data. So this is a Python SDK. So you first need to install the Python SDK and once you have the SDK you need to import the necessary files. So the edstrike client is a class that we export, and in any SDK you will need an API key for integration. So to get the API key you will go to the profile page.
So here I have a profile in the profile you will get your API key. You will copy this API key and insert it into the SDK, and any queries you want to run you will create in the query builder and insert them here. Then you will initialize your query here. Then you will initialize your query . The next thing you'll do is create a query object and simply execute that query.
In this case you can see that I have already created the po query here for service.lans and you can see that each query response gives me two things: an error object and a data object. So if the error is none you will get the data and you can just use it. Sometimes you're building an application that requires a lot of data, and an API can't provide all the data. So you need to use pagination.
In that case, the SDK provides two Boolean flags in the query response, namely next page and previous page. So if you have a next page in your query response, you can request the next page here again. This will provide the second page. Similarly, if you want to go to the previous page, you can again go to the pre-run previous page method. So I created this little utility function where you can simply pass the Airstrike SDK client a query variable.
This function executes the query. He is collecting the answer and will continue to do so until he reaches the last page and as soon as he receives the answer he will return it in one go. So yes, this way you can actually integrate any query into the SDK. So since the SDK is for general use, you just need to work on the query part and put your variables in here and it will run it and give you the answer like this. Okay.
Yes, I think that's all. These are the use cases I wanted to cover. Yes. So you'll be able to...for NFTs you'll be able to run queries based on...
okay, so the token represents the collection here. So you'll be able to run queries based on...let me select the CPI token here. Yes. So you'll be able to query by name, symbol, and address type.
Okay. Yes symbol, and address type. Okay. Yes , you can enter the contract address and ask for it. And we have one more thing I want to show.
So in NFT tokens, if you want to query specific NFTs of a contract and you want to query them based on trades, then something that has a green background, right? So you can basically go to attributes and put trading type with background color and put like the value in green, right? Then it will only give you the NFTs from that collection that have that background that collection that have that background . Yes. Custom property.
At Genosis we only have POPS at the moment. POPS and but for Ethereum and Polygon we have all the data from Genesis to the live block. Yes, we have five $2,000 prizes. The first three are just our three favorite projects. Build anything you want on AirStack.
There are a lot of ideas in our concept. And then we have a specific $2,000 reward if you build something that uses AirStack and XMTP or AI or attestation. Um, and specifically for XMTP, we do a lot with…a lot of XMTP projects are built with Airirststack. No, we don't, we just think ...XMTP is a fantastic way to send messages to people with an Ethereum address.
And what was missing before AirStack was a way to resolve, for example, from a zero address to an ENS or a Lens or a fire, caster etc. And so we joined together to make it possible. And so…many applications are making use of it. Um applications are making use of it. Um , and so if you build something with XMTP, there's $2,000 from Airirststack plus another thousand from XMTP available.
And finally, if someone simply wants to create a single visualization of AirStack data. So if you see the response here now it's a JSON file. If you want to create something that is just a unique display of the response, there is another $2,000 we have. Um, and just to quickly show you an example, we've created a demo app that you can look at on demo.airsyz, Slack XYZ that's just a front end to, I can say, put any, um, lens, sparker, ENS, setter and, it pinged the APIs and gives a visual response instead of the API response that shows the five calculations.
Exact. Yeah. So if you check out an app I can show you later, um, called Converse. Which gets converse. They have a recommendation engine built by, it's based on airstack where if you click on a button that says "who received a message," it will show you everyone who went to the same events with POPS, everyone you sent tokens to or from, um, from your airstack transfer history.
So, it's kind of overcoming the cold start problem with Web 3 and showing you people you already know based on on-chain data. Any other questions? Someone? Well. If you need help, our Telegram chat is our team, available 24/7 .
Automatic transcript — names and jargon may be misspelled.