Links
💻

NFT Collection Webhook

You can monitor an entire NFT collection by monitoring the list of all NFTs in a collection (mintlist). With Helius, you can programatically retrieve the mintlist from the NFT API and create a webhook based on that mintlist. The code example uses the following endpoints to create a webhook that monitor NFT sales for the DeGods collection:
const BASE_URL = 'https://api.helius.xyz';
const API_KEY = 'your-key-here';
const COLLECTION_ADDRESS = '6XxjKYFbcndh2gDcsUrmZgVEsoDxXMnfsaGY6fpTJzNr'; // DeGods
​
const createCollectionWebhook = async () => {
try {
const mints = await getMints();
const webhookId = await createWebhook(mints);
console.log(`Created webhook ${webhookId}!`);
} catch (ex) {
console.error('Error occurred: ', ex);
}
};
​
const getMints = async () => {
const url = `${BASE_URL}/v1/mintlist?api-key=${API_KEY}`;
const { data } = await axios.post(url, {
query: {
verifiedCollectionAddresses: [COLLECTION_ADDRESS],
},
options: {
limit: 10_000,
},
});
return data.result.map((x) => x.mint);
};
​
const createWebhook = async (mints) => {
const url = `${BASE_URL}/v0/webhooks?api-key=${API_KEY}`;
const { data } = await axios.post(url, {
webhookURL: 'https://server.example.xyz',
transactionTypes: ['NFT_SALE'],
accountAddresses: mints,
webhookType: 'enhanced',
});
return data.webhookID;
};
​
createCollectionWebhook();