Rate Limiting

  1. Rate Limiting
  2. JWT Authentication
  3. Idempotency
  4. API Keys
  5. API Versioning
  6. Pagination
  7. Consistent Error Format
Client
Server

Before

Route::post('/api/v1/login', [AuthController::class, 'login']);

class AuthController
{
    public function login(Request $request): JsonResponse
    {
        // any client can call this as fast as it wants
        return $this->attempt($request->only('email', 'password'));
    }
}

After

Route::post('/api/v1/login', [AuthController::class, 'login'])
    ->middleware('throttle:5,1');

class AuthController
{
    public function login(Request $request): JsonResponse
    {
        // the 6th request within the window gets a 429 automatically
        return $this->attempt($request->only('email', 'password'));
    }
}
{CC}