Get Fan Token Auction Schedule By Status
In this tutorial, you will learn how to all the fan token auction schedules by their status 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($status: FarcasterFanTokenAuctionStatusType) {
FarcasterFanTokenAuctions(
input: {filter: {status: {_eq: $status}, entityType: {_in: [USER, CHANNEL, CHANNEL]}}, blockchain: ALL, limit: 10}
) {
FarcasterFanTokenAuction {
auctionId
auctionSupply
decimals
entityId
entityName
entitySymbol
entityType
estimatedEndTimestamp
estimatedStartTimestamp
launchCastUrl
minBiddingAmount
minFundingAmount
minPriceInMoxie
subjectAddress
}
}
}
{
// For example, to fetch all upcoming fan token auctions
"status": "UPCOMING"
}
{
"data": {
"FarcasterFanTokenAuctions": {
"FarcasterFanTokenAuction": [
{
"auctionId": null,
"auctionSupply": 2.612e+21,
"decimals": 18,
"entityId": "screens",
"entityName": "/screens",
"entitySymbol": "cid:screens",
"entityType": "CHANNEL",
"estimatedEndTimestamp": "2024-08-07T14:00:00Z",
"estimatedStartTimestamp": "2024-08-04T14:00:00Z",
"launchCastUrl": "",
"minBiddingAmount": 10000000000000000,
"minFundingAmount": 0,
"minPriceInMoxie": 1000000000000000000,
"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($status: FarcasterFanTokenAuctionStatusType) {
FarcasterFanTokenAuctions(
input: {filter: {status: {_eq: $status}, entityType: {_in: [USER, CHANNEL, CHANNEL]}}, blockchain: ALL, limit: 10}
) {
FarcasterFanTokenAuction {
auctionId
auctionSupply
decimals
entityId
entityName
entitySymbol
entityType
estimatedEndTimestamp
estimatedStartTimestamp
launchCastUrl
minBiddingAmount
minFundingAmount
minPriceInMoxie
subjectAddress
}
}
}
`;
const variable = {
// For example, to fetch all upcoming fan token auctions
"status": "UPCOMING"
}
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($status: FarcasterFanTokenAuctionStatusType) {
FarcasterFanTokenAuctions(
input: {filter: {status: {_eq: $status}, entityType: {_in: [USER, CHANNEL, CHANNEL]}}, blockchain: ALL, limit: 10}
) {
FarcasterFanTokenAuction {
auctionId
auctionSupply
decimals
entityId
entityName
entitySymbol
entityType
estimatedEndTimestamp
estimatedStartTimestamp
launchCastUrl
minBiddingAmount
minFundingAmount
minPriceInMoxie
subjectAddress
}
}
}
`;
const variable = {
// For example, to fetch all upcoming fan token auctions
"status": "UPCOMING"
}
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",
"entityType": "CHANNEL",
"estimatedEndTimestamp": "2024-08-07T14:00:00Z",
"estimatedStartTimestamp": "2024-08-04T14:00:00Z",
"launchCastUrl": "",
"minBiddingAmount": 10000000000000000,
"minFundingAmount": 0,
"minPriceInMoxie": 1000000000000000000,
"subjectAddress": "0xFeddb7c19D458833e082F4c7A8037DFa57F0929E"
}
]
}
}
}
Congrats! 🥳🎉 You've just fetched all the fan token auction schedules by their status!
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.