Help with API calls with limitations and data transformation from retrieved data

I would like to complete data of a table I retrieve from an API with data from another API to complete the information needed.

The simplified workflow is:

Problems?

Sure. I get two main issues:

  1. The API has a limitation, so I set the splitonbatches node to retrieve the first 20 but I don’t get the next ones. Maybe I can use also proxies.

  2. I achieved calling the second API which has the attributes I need, but it retrieves them in an awkward way that blows my mind. My expected (or desired) result was: ids, usd, usd_market_cap instead of this monster:

Please share the workflow

What should I do? Thanks!

You do not need to use the Split Batches node. n8n automatically will do the looping for you. Remove the split batches node and reference in the second HTTP request the output of the first HTTP request. Be aware that you are gonna have to limit the number of requests or you are going to hit the rate limit of the CounGecko API. To do that, you can use the parameters Batch Interva and Batch Size. They located under options in the HTTP request.

Use the function node below to map the data to something more readable.

const results = []

for (const item of items) {
  const key = Object.keys(item.json)[0]
  results.push({
    json: {
          id: key,
    ...item.json[key]
    }
  })
}

return results
2 Likes

Worked amazing. Thanks!