Rate Limit Exceeded Foursquare API

I have a file contains 1000++ tweets which for each entry i want to get user's information from Foursquare API. The problem is, i keep getting error Rate Limit Exceeded, is there a best practice to avoid Rate Limit Exceeded on Foursquare API?

Answers


Yes, You should limit your request rates. You can create a thread and then pause the api invocations for the specified interval. Or you can use RxJava. An example is mentioned below.

public static invokeRateLimitedFetch(List<RequestInfo> requests){
      //2 second pause             
      Observable.zip(Observable.from(requests),
               Observable.interval(2, TimeUnit.SECONDS), (obs,timer)->obs)
               .doOnNext(item -> {
                  //Invoke here use item
               }
).toList().toBlocking().first();

 }

}

Need Your Help

SQL comparison within max function

mysql sql

I'm trying to get a list of 20 events grouped by their Ids and sorted by whether they are in progress, pending, or already finished. The problem is that there are events with the same id that include