Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User customized rate limit ? #26

Closed
harshraj22 opened this issue Dec 12, 2022 · 2 comments
Closed

User customized rate limit ? #26

harshraj22 opened this issue Dec 12, 2022 · 2 comments

Comments

@harshraj22
Copy link

I want to have a subscription based api service. there are 3 types of subscription:
Free: 10 api calls per 24hour
Basic: 30 api calls per 24hour
Advanced: 80 api calls per 24hour.

Along with the request body, suppose the detaiils about the subscription is also available. Can such scenario be handled by your library ?
I am using fastapi, and I would prefer using a library than writing my own rate limiter using reddis.

@long2ice
Copy link
Owner

No, which need your own customization

@HutchNunez
Copy link

HutchNunez commented Dec 20, 2023

I opted for something like this

async def dynamic_rate_limiter(request: Request, response: Response):
    # logic here, if free, else if premium ...
    await RateLimiter(times=1, seconds=60)(request, response)


@router.get(
    "/v1/dummy",
    dependencies=[Depends(dynamic_rate_limiter)],
)
def get_dummy():
    return {"dummy": "dummy"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants