From b1fab56f7cba1718d34ee4e810ff3b39852105b9 Mon Sep 17 00:00:00 2001 From: Ido Slonimsky Date: Sun, 30 Jul 2023 13:38:37 +0300 Subject: [PATCH] chore: add documentation --- docs/features.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/features.md b/docs/features.md index 91b6ff6a..684e8c9c 100644 --- a/docs/features.md +++ b/docs/features.md @@ -609,3 +609,25 @@ async def hello(): app.include_router(sub_router) ``` + +## Rate limiting + +Robyn provides built-in rate limiting functionality, allowing you to control the frequency of requests made to the API. + +By implementing rate limiting, you can manage resource consumption, prevent abuse, and maintain system stability, ensuring a smooth and reliable user experience. + +In order to the rate limiter to properly identify users, a `Request` object must be defined as an input parameter for the route. + +```python +from robyn import Robyn, RateLimiter + +app = Robyn(__file__) + +rate_limiter = RateLimiter(calls_limit=3, limit_ttl=60) + +@app.get("/throttled_route", rate_limiter=rate_limiter) +def throttled_route(request: Request): + return "OK" +``` + +In this example the limit for `/throttled_route` is 3 calls per 1 minutes (60 seconds)