You can limit some URL to be called a maximum of 60 times per minute, with throttle:60,1:
Route::middleware('auth:api', 'throttle:60,1')->group(function () { Route::get('/user', function () { // });});
But also, you can do it separately for public and for logged-in users:
// maximum of 10 requests for guests, 60 for authenticated usersRoute::middleware('throttle:10|60,1')->group(function () { //});
Also, you can have a DB field users.rate_limit and limit the amount for specific user:
Route::middleware('auth:api', 'throttle:rate_limit,1')->group(function () { Route::get('/user', function () { // });});
Enjoyed This Tip?
Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.
Recent Courses
[NEW] Building a Typical Laravel SaaS
8 lessons
1 h 07 min
How to Build Laravel 12 API From Scratch
28 lessons
1 h 21 min
NativePHP: Build Mobile App with Laravel
11 lessons
2 h 2 min read