Handling Paginated API Responses in Google Apps Script

A book on a table, opened in the middle with the pages fanning out.

One of my favorite things about Google Apps Script is that I can get information from an API and write it directly to a shared document or spreadsheet. Information is collected automatically and immediately available to a group of people working on that same doc.

It's not uncommon for these requests to come back in paginated form. Meaning, if your request has 100 responses, they'll come in batches of n size instead of all at once. To demonstrate, I've made a video showing how I use a script to handle requests to Canvas.

If you want to play with it, here's an example you can start from:


The featured image is by Brandi Redd on Unsplash.