How to Handle Pagination in External APIs with Bubble’s API Connector

When integrating with external APIs (like Airtable, Brevo, or Shopify), you often face a challenge: the API only returns a limited number of results per request. This is called pagination. If your API returns, say, 100 items per page, and you have 500 items total—you’ll need to request multiple pages.

Common Pagination Methods

  1. Page Number (e.g., ?page=2)
    You send the page number in the API URL as a parameter.

  2. Offset (e.g., ?offset=100)
    You skip a number of records. Useful when you don’t know the page count.

  3. Cursor-based (e.g., ?after=xyz)
    You get a “cursor” or “token” in the response, and use that to fetch the next page.


How to Handle This in Bubble:

1 Set Up the Initial API Call

In the API Connector, define your API call and include the page/offset parameter as a dynamic field (e.g., page=[page]).

2 Create a Backend Workflow

Use a recursive API workflow to:

  • Make the call

  • Save the results to your database

  • Check if more data is available (based on the response)

  • Trigger itself again with the next page/cursor value

Step 3: Handle Limits

If the API has rate limits, add a delay using Schedule API Workflow and space out your requests.


Example

http

CopyEdit GET https://api.example.com/contacts?limit=100&offset=2

Response:

json

CopyEdit

{ "data": [...], "next_offset": 300 }

In the response, you check next_offset and call the same workflow again using that value.

Thanks

1 Like