Project

General

Profile

Actions

Task #929

closed

PE-1814: Add API usage analytics and rate limiting

Added by Fredrick Amnehagen about 3 hours ago. Updated about 2 hours ago.

Status:
Done
Priority:
High
Assignee:
-
Target version:
-
Start date:
2026-05-16
Due date:
% Done:

100%

Estimated time:

Description

Problem

No visibility into API usage patterns. No per-user rate limiting or quotas.

Missing Features

  1. Per-user API usage dashboard
  2. Rate limiting by endpoint/user
  3. Quota enforcement (e.g., 1000 requests/day)
  4. Usage metrics (requests, bandwidth, compute time)

Implementation Plan

  1. Create api_usage_logs table (timestamp, user_id, endpoint, response_time, status_code)
  2. Add middleware to log all requests
  3. Create GET /api/v1/usage/summary endpoint
  4. Add X-RateLimit-* headers to responses
  5. Configurable rate limits per endpoint

Rate Limit Configuration

Endpoint Limit
/search 50/min
/personas 200/min
/webhooks 100/min
/health 1000/min

Files to Create/Modify

  • app/Http/Middleware/LogApiUsage.php
  • app/Models/ApiUsageLog.php
  • database/migrations/ (api_usage_logs)
  • routes/api_v1.php (usage endpoints)
  • config/api.php (rate limits)

Benefits

  • Prevent abuse
  • Track usage patterns
  • Identify performance issues
  • Enable tiered pricing
Actions #1

Updated by Fredrick Amnehagen about 2 hours ago

  • Status changed from To do to Done
  • % Done changed from 0 to 100

Added api_usage_logs and api_rate_limits tables. Added RateLimitApi middleware with endpoint-based limits. Added GET /usage/summary and GET /usage/me endpoints. OpenAPI spec updated.

Actions

Also available in: Atom PDF