Help

Re: How to Work Around API Limits

Solved
Jump to Solution
1536 0
cancel
Showing results for 
Search instead for 
Did you mean: 

I can only request 15 new record creations with a single API call.

// create a People-Holiday::Christmas record for each person in the People table
people.map(person => {
    peopleHolidaysTable.createRecordAsync({
        'Person' : [{id: `${person.id}`}],
        'Holiday' : [{id: 'reclZYRpInJiev0ce'}]
    });
});

I have 33 people in my array. I’m not terribly proficient with async programming in JS yet. What is the proper way to chunk this into 3 API calls of 15/15/3? I suspect I need to split it up into arrays of 15 and then have each call await the one previous with a timeout of 1000ms.

Anyone able to provide some guidance on how to do that?

1 Solution

Accepted Solutions
Emma_Yeap
Airtable Employee
Airtable Employee

Hi Jeremy,

We rate-limit blocks to 15 writes per second and batch methods allow modification of 50 records in one call. Your current code looks like it does a separate API call for each person, so you’re running into the 15 writes per second limit.

You could switch your code to use the batch createRecordsAsync instead of createRecordAsync to get around this. You could also do what you suggested (split the calls and await each previous one). The time it takes for the write to complete (while you await) should be long enough that you wouldn’t need to include an additional timeout.

For the first option, it’d look like this:

peopleHolidaysTable.createRecordsAsync(people.map(person => ...))

For the second option, we have an example on how to that in the “Size limits & rate limits” section of this guide: Airtable Blocks SDK as well as in the Wikipedia Enhancement example block: https://github.com/Airtable/blocks/blob/master/examples/wikipedia-enrichment-block/frontend/index.js...

Sorry for the late response, hope this is still helpful!

See Solution in Thread

2 Replies 2
Emma_Yeap
Airtable Employee
Airtable Employee

Hi Jeremy,

We rate-limit blocks to 15 writes per second and batch methods allow modification of 50 records in one call. Your current code looks like it does a separate API call for each person, so you’re running into the 15 writes per second limit.

You could switch your code to use the batch createRecordsAsync instead of createRecordAsync to get around this. You could also do what you suggested (split the calls and await each previous one). The time it takes for the write to complete (while you await) should be long enough that you wouldn’t need to include an additional timeout.

For the first option, it’d look like this:

peopleHolidaysTable.createRecordsAsync(people.map(person => ...))

For the second option, we have an example on how to that in the “Size limits & rate limits” section of this guide: Airtable Blocks SDK as well as in the Wikipedia Enhancement example block: https://github.com/Airtable/blocks/blob/master/examples/wikipedia-enrichment-block/frontend/index.js...

Sorry for the late response, hope this is still helpful!

Very helpful — thank you, @Emma_Yeap!