How would you implement rate limiting for an API?

Technical