title: How to call the same API for N number of times using Retrofit and RXJava.I am using the following approach as of now
body: <p>Ok. So the API documentation says :</p>
  
  <p><strong>Get up to 100 restaurants by changing the 'start' and 'count' parameters with the maximum value of count being
  20.</strong>
  API LINK : <a href="https://developers.zomato.com/documentation#!/restaurant/search" rel="nofollow noreferrer">https://developers.zomato.com/documentation#!/restaurant/search</a></p>
  
  <p>This is the sample code :</p>
  
  <pre><code>restaurantList = new ArrayList&lt;&gt;();
      restaurantFinderAPI = RetrofitClient.getRetrofitClientAPI();
      restaurantScheduler = Schedulers.newThread();
  
      for (int i = 0; i &lt;= 80; i += 20) {
          restaurantModelObservable = restaurantFinderAPI.getRestaraunts(city, entitytype, searchString, i, 20);
  
          restaurantModelObservable.subscribeOn(restaurantScheduler);
          restaurantModelObservable.observeOn(AndroidSchedulers.mainThread());
          restaurantModelObservable.subscribe(new Observer&lt;RestaurantModel&gt;() {
              @Override
              public void onSubscribe(Disposable d) {
                  COUNT++;
                  restaurantDisposable = d;
              }
  
              @Override
              public void onNext(RestaurantModel value) {
                  restaurantList.addAll(value.getRestaurants());
              }
  
              @Override
              public void onError(Throwable e) {
                  restaurantDisposable.dispose();
                  onRestaurantSync.onRestaurantSyncFail();
              }
  
              @Override
              public void onComplete() {
                  if (COUNT == 5) {
                      new ModifyTask().execute(restaurantList);
                      COUNT = 0;
                  }
              }
          });
  </code></pre>
  
  <p>This is the Retrofit interface :</p>
  
  <pre><code>    String ZOMATO_ROOT_URL = "https://developers.zomato.com/api/v2.1/";
  
  @GET("search")
  @Headers({"Accept: application/json","user-key: 258f3e496748d15cb792bc554000d6b6"})
  Observable&lt;RestaurantModel&gt; getRestaraunts(@Query("entity_id") int entityID,
                                             @Query("entity_type") String entity_type,
                                             @Query("q")String searchFor,
                                             @Query("start") int start,
                                             @Query("count") int count);
  </code></pre>
  
  <p>I making the call 5 times which is counted by the COUNT field, so it would give 100 results , by changing 'i'. Once I get 100 results, I start an asynctask for some processing on the dat. Is this a good way to call the same API multiple times. I am new to RXJava and I could not find a nice answer. Please help. Thanks</p>