Implement a rate limiter for API requests, explaining the trade-offs between token bucket and sliding window algorithms.