Has there ever been any talk of rate limiting specific api's? Or from a dev's perspective should this be left up to the end user to tackle? Just curious as I'm needing it for a requirement.
For example, an api that takes in search terms, and returns a list of matching results. I intended to send each character as a new request to the api, but rate limiting for even 2 full seconds would be appropriate, to not hit the API to often.
You can do this yourself using RxJava. It's definitely an application-level concern, not Retrofit. Retrofit just maps HTTP semantics onto Java interfaces.
Observable<String> text = ...
text.throttleLast(2, SECONDS)
.flatMap(retrofitApiCall())
.subscribe(result -> System.out.println("result: " + result));
where retrofitApiCall() is some interface method that returns Observable<Result>.
Awesome thanks for the quick reply @JakeWharton !
any way of doing that without using rx?
maybe something like https://github.com/Netflix/concurrency-limits
Most helpful comment
You can do this yourself using RxJava. It's definitely an application-level concern, not Retrofit. Retrofit just maps HTTP semantics onto Java interfaces.
where
retrofitApiCall()is some interface method that returnsObservable<Result>.