1

I am trying to get a response from any public REST API and process it (parsing it and putting in data structure). While getting this response from the API I want to use some pagination functionality. I referred this, the question discussed the pagination techniques for a particular API.

What I want to implement is making the pagination code snippet generic ie

  1. I don't have any control over server side pagination
  2. At run time I don't know the query parameter for the pagination provided by that API

I was wondering if there is any way that one can do the 'client-side only' pagination ie limit the response from the server, process it and the get the remaining response and so on.

I haven't worked much in pagination, so any ideas, suggestions, pointers are appreciated.

Thank you!

Community
  • 1
  • 1
HitchHiker
  • 825
  • 2
  • 11
  • 31
  • 1
    You can write your own server api to get it all from that api and provide paginated results yourself. – cafebabe1991 Aug 24 '15 at 05:18
  • My purpose of including the pagination is that the apis I'm dealing with can return me a huge response, like lacs of json records. So will this method help me deal with the outofMemory issue? – HitchHiker Aug 24 '15 at 05:22
  • At run time I don't know the query parameter for the pagination provided by that API, then how are you accessing pagination from REST api? – Naman Gala Aug 24 '15 at 05:23
  • @NamanGala That's the issue, I can't perform pagination and I get outOfMemory eror – HitchHiker Aug 24 '15 at 05:24
  • @Vaishnavee , Yes it will deal with it. Store that huge response in your backend at once and give it in a paginated way your client side implementation. – cafebabe1991 Aug 24 '15 at 07:16

1 Answers1

4

Client side pagination is not a good idea because generally clients are meant to be light weight(low memory and processing power). As you have mentioned that you have no control on server or REST service does not provide any pagination params then here are two choices i can think of:

  1. You may introduce a proxy service for REST service on a server with sufficient resources. This proxy will consume the original response and can provide the paginated response as per your need.

  2. If your client can consume the entire result and have enough memory to keep it then you can implement your own client side logic for pagination.

I would prefer the first one. Hope it helps.

Juned Ahsan
  • 67,789
  • 12
  • 98
  • 136
  • Thanks for the response, will the proxy service help in resolving outOfMemory issue? as the response is very huge. – HitchHiker Aug 24 '15 at 05:27
  • 2
    @Vaishnavee By proxy i mean a new server with sufficient resources hosting a custom rest proxy service running on it. Proxy will give the paginated response to your client so client should not crash. – Juned Ahsan Aug 24 '15 at 05:28
  • oh I guess that's the best choice available here, will try this out :) – HitchHiker Aug 24 '15 at 05:30
  • @Vaishnavee Good luck...let the forum know how you go. – Juned Ahsan Aug 24 '15 at 05:32