iosjsonrestcaching

How to fetch all the data from RESTful APIs?


I have implemented a RESTful API with few resources, for example:

/products/
/products/1
/products/2
/categories/
/categories/1
/categories/2
etc.

Now, I have been told that the app should mainly work offline, therefore I need to get all the data from the APIs and store it locally.

Since I am not providing a single chunk of data but there are different resources URI that needs to be called in order to get all the data I was wondering if this could be a problem.

How does this work? will there be many HTTP calls or one call will do everything?

What is the best approach in this case?


Solution

  • Are these endpoints in themselves?

    /products
    /categories
    

    It's a pretty well established convention for those to return the entire collection. You could even add some request parameters for filtering etc.