I tried fetching all data from a specific NFT collection using getAllTokenIds from Web3Api. However, I also have the sync the events of the collection on my database.
Which one is better and recommended?
I tried fetching all data from a specific NFT collection using getAllTokenIds from Web3Api. However, I also have the sync the events of the collection on my database.
Which one is better and recommended?
it depends on what is your final goal, with syncing events you don’t get the metadata, only events info.
Ohhh, but what if it’s like this? The problem with this is it takes almost a second to fetch one nft.
const NFTs = await Web3Api.token.getAllTokenIds({
chain: currentChain,
address: marketplaceContract
}).then(async (data) => {
// let metadata = JSON.parse(data)
console.log(data)
for (let x = 0; x < data.result.length; x++) {
await fetch(data.result[x].token_uri)
.then((response) => response.json())
.then((data) => {
console.log(data)
})
}
trying to get all the token ids for a marketplace contract will not be instant, and you may also have to use pagination in order to get more than 100 results
Yes, what can you suggest to fetch them faster?
I don’t know if it is a faster way to do it
If the metadata for this specific collection isn’t going to change (or won’t change much), you could cache this data in your own database and query for that instead.