Search code examples
javaspringjpapaginationmicroservices

How to create aggregator Paginated API on top of non paginated apis?


Here is the problem

(Microservice A) API A: returns large data set of ItemA (Non Paginated) (Microservice B) API B: returns small data set of ItemB (Non Paginated)

(Microservice C) API C: calls API A and API B and aggregates data

I'd like API C to be paginated but not sure this is possible on top of 2 NON paginated apis without doing complex logic within API C itself

Is it a bad practice? Or should the API A and API B be converted to paginated?


Solution

  • You can write complex logic in API C to support pagination but if the APIs(A & B) supports filters, you would have a hard time. You should ideally work towards making API A & B support paginated responses.