Get Fan Token Auction Schedule By Fan Token Type
In this tutorial, you will learn how to all the fan token auction schedules by the fan token type by calling the Airstack GraphQL API.
Pre-requisites
Install dependenciesgraphql
and graphql-request
to your project :- npm
- yarn
- pnpm
- bun
npm install graphql graphql-request dotenv
yarn add graphql graphql-request dotenv
pnpm add graphql graphql-request dotenv
bun install graphql graphql graphql-request dotenv
In addition, to access the Airstack API, you should get your Airstack API key.
For access to the Airstack API key, you'll need to hold at least 1 /airstack Channel Fan Token in either your Farcaster custodial wallet or one of your Farcaster verified wallets AND make sure that you have connected one of those wallet or your Farcaster account to your Airstack account.
If you don't have it yet, you can buy it here.
Step 1: Add The API Query To Your Code
To all the fan token auction schedules by their status, you can use the following query:
- Query
- Variable
- Response
query MyQuery($fanTokenType: FarcasterFanTokenAuctionEntityType) {
FarcasterFanTokenAuctions(
input: {blockchain: ALL, filter: {entityType: {_eq: $fanTokenType}}}
) {
FarcasterFanTokenAuction {
auctionId
auctionSupply
decimals
entityId
entityName
entitySymbol
estimatedEndTimestamp
estimatedStartTimestamp
launchCastUrl
minBiddingAmount
minFundingAmount
minPriceInMoxie
status
subjectAddress
}
}
}
{
// For example, to fetch all auction schedules for channel-type fan tokens
"fanTokenType": "CHANNEL"
}
{
"data": {
"FarcasterFanTokenAuctions": {
"FarcasterFanTokenAuction": [
{
"auctionId": null,
"auctionSupply": 2.612e+21,
"decimals": 18,
"entityId": "screens",
"entityName": "/screens",
"entitySymbol": "cid:screens",
"estimatedEndTimestamp": "2024-08-07T14:00:00Z",
"estimatedStartTimestamp": "2024-08-04T14:00:00Z",
"launchCastUrl": null,
"minBiddingAmount": 10000000000000000,
"minFundingAmount": 0,
"minPriceInMoxie": 0,
"status": "UPCOMING",
"subjectAddress": "0xfeddb7c19d458833e082f4c7a8037dfa57f0929e"
}
]
}
}
}
graphql-request
library:- TypeScript
- JavaScript
import { gql, GraphQLClient } from "graphql-request";
import { config } from "dotenv";
config();
const graphQLClient = new GraphQLClient(
"https://api.airstack.xyz/gql"
);
const query = gql`
query MyQuery($fanTokenType: FarcasterFanTokenAuctionEntityType) {
FarcasterFanTokenAuctions(
input: {blockchain: ALL, filter: {entityType: {_eq: $fanTokenType}}}
) {
FarcasterFanTokenAuction {
auctionId
auctionSupply
decimals
entityId
entityName
entitySymbol
estimatedEndTimestamp
estimatedStartTimestamp
launchCastUrl
minBiddingAmount
minFundingAmount
minPriceInMoxie
status
subjectAddress
}
}
}
`;
const variable = {
// For example, to fetch all auction schedules for channel-type fan tokens
"fanTokenType": "CHANNEL"
}
const headers = {
// Add Airstack API key here
Authorization: process.env.AIRSTACK_API_KEY as string,
}
try {
const data = await graphQLClient.request(query, variable, headers);
console.log(data);
} catch (e) {
throw new Error(e);
}
const { gql, GraphQLClient } = require("graphql-request");
const { config } = require("dotenv");
config();
const graphQLClient = new GraphQLClient(
"https://api.airstack.xyz/gql"
);
const query = gql`
query MyQuery($fanTokenType: FarcasterFanTokenAuctionEntityType) {
FarcasterFanTokenAuctions(
input: {blockchain: ALL, filter: {entityType: {_eq: $fanTokenType}}}
) {
FarcasterFanTokenAuction {
auctionId
auctionSupply
decimals
entityId
entityName
entitySymbol
estimatedEndTimestamp
estimatedStartTimestamp
launchCastUrl
minBiddingAmount
minFundingAmount
minPriceInMoxie
status
subjectAddress
}
}
}
`;
const variable = {
// For example, to fetch all auction schedules for channel-type fan tokens
"fanTokenType": "CHANNEL"
}
const headers = {
// Add Airstack API key here
Authorization: process.env.AIRSTACK_API_KEY as string,
}
try {
const data = await graphQLClient.request(query, variable, headers);
console.log(data);
} catch (e) {
throw new Error(e);
}
Step 2: Execute Your Code
Once you have your code ready, you can execute it by running the following command:
- TypeScript
- JavaScript
ts-node index.ts
node index.js
If it runs successfully, you should see the data returned in the terminal:
{
"data": {
"FarcasterFanTokenAuctions": {
"FarcasterFanTokenAuction": [
{
"auctionId": null,
"auctionSupply": 2.612e+21,
"decimals": 18,
"entityId": "screens",
"entityName": "/screens",
"entitySymbol": "cid:screens",
"estimatedEndTimestamp": "2024-08-07T14:00:00Z",
"estimatedStartTimestamp": "2024-08-04T14:00:00Z",
"launchCastUrl": null,
"minBiddingAmount": 10000000000000000,
"minFundingAmount": 0,
"minPriceInMoxie": 0,
"status": "UPCOMING",
"subjectAddress": "0xfeddb7c19d458833e082f4c7a8037dfa57f0929e"
}
]
}
}
}
Congrats! 🥳🎉 You've just fetched all the fan token auction schedules by the fan token type!
Developer Support
If you have any questions or need help with other use cases, feel free to join the /airstack Warpcast channel and ask your questions there.
Our team is always ready to help you with any questions you may have.