Skip to content

feat: add rate limiting to /generate-blog endpoint#179

Open
Unnati1007 wants to merge 3 commits into
vanshaggarwal27:mainfrom
Unnati1007:feat/rate-limiting
Open

feat: add rate limiting to /generate-blog endpoint#179
Unnati1007 wants to merge 3 commits into
vanshaggarwal27:mainfrom
Unnati1007:feat/rate-limiting

Conversation

@Unnati1007

Copy link
Copy Markdown

Description

The /generate-blog endpoint in the FastAPI backend lacked rate limiting, exposing the system to potential abuse and rapid exhaustion of AI API quotas.

This PR introduces rate limiting using the slowapi library to protect the endpoints. It limits clients to 15 requests per hour based on their IP address.

  • Added slowapi to requirements.txt.
  • Initialized Limiter in backend/main.py.
  • Applied a @limiter.limit("15/hour") decorator to the /generate-blog endpoint.
  • Registered an exception handler to return proper 429 Too Many Requests status codes.

Related Issue

Fixes #160

Type of Change

  • Bug fix
  • New feature
  • Documentation update

Checklist

  • My code follows project guidelines
  • I have tested my changes
  • Documentation updated if needed

@Unnati1007

Copy link
Copy Markdown
Author

@vanshaggarwal27 resolved the merged conflict do check it

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

Successfully merging this pull request may close these issues.

[BUG] Implement API Rate Limiting for the /generate-blog Endpoint (Backend)

1 participant