Handling paginated API results in business integrations
Check that an integration retrieves all relevant pages of supplier data and can recover from interruptions.
Understand the supplier format
Some APIs return results in pages rather than one response. Read the supplier’s documentation to see how to request the next page and how the end of the result set is indicated. GitHub documents one approach using links; other suppliers may use different methods.
Plan for changing data
Records can be added or changed while a long retrieval is running. Ask the supplier how its pagination behaves and whether a stable sort, cursor or change timestamp is available. Do not assume that simply increasing a page number prevents missed or repeated records.
Handle interruptions
Record enough progress to resume or safely repeat the retrieval without silently creating duplicates. For example, if a customer import stops after several pages, the team needs to identify which records arrived and how the remaining work will be recovered.
Reconcile the result
Test with more records than fit on one page, including an empty final page if the API uses one. Compare received references and counts with an independently obtainable source where possible, and investigate mismatches before relying on the imported data. For example, a returned total of 500 customers is not sufficient by itself: compare identifiers as well, because a missing record and a duplicate can leave the count unchanged.