getNFTTransactions Question

I have been trying to get all historical transactions for a NFT collection using the getNFTTransactions endpoint in Cloud code. When i call the endpoint using the SDK I only get 11 results, but if I use the raw HTTP endpoint I get 52000. Here is the two methods for calling the endpt:

Moralis.Cloud.define("getTransactions", async (request) => {
  const resp = await Moralis.Web3API.account.getNFTTransfers({
    chain: "eth",
    address: request.params.contract,
  });

  const resp2 = Moralis.Cloud.httpRequest({
    url: "https://deep-index.moralis.io/api/v2/nft/0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB/transfers?chain=eth",
    headers: {
      "X-API-Key":
        "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
      accept: "application/json",
    },
  });
  
  return resp;
});

When I return resp I only get 11 results, but returning resp2 gives me 52,000+ results. These are supposed to be the same endpoint according to the docs so why am I getting different results?

Note: Calling these using cryptopunks contract address: 0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB

getNFTTransfers takes the wallet address as input address , however the http endpoint takes the contract address as input. That is the reason for the different results.

Understood. Is there a hook that takes the contract address as the input? Because when I call the HTTP endpoint in cloud code, I am having a problem:

When I return resp2 (the HTTP endpoint) and then console.log the entire response on the frontend (in a React app) I can look through all the responses as expected. However, when I try to parse through resp2 in cloud code before returning it, I have problems.

Namely, if I try to access resp2.text, resp2.data, or even resp2.status I get undefined for all of them. I haven’t had this problem in cloud code with parsing other responses from Moralis.Cloud.httpRequest()
any advice on what could be going on here?

Update: found the function I was looking for:

Moralis.Web3API.token.getContractNFTTransfers()

Thank you for the help

1 Like