Define a named limiter and attach it to the API route group: ```php use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Support\Facades\RateLimiter; RateLimiter::for('api', function ($request) { return Limit::perMinute(60)->by( $request->user()?->id ?: $request->ip() ); }); ``` ```php Route::prefix('v1') ->middleware(['throttle:api', 'auth:sanctum']) ->group(function () { Route::get('/posts', [PostController::class, 'index']); }); ``` Key authenticated users by user ID and anonymous calle...
Scanned 9/5/2026
Install to Claude Code
npx -y skills add HoangNguyen0403/agent-skills-standard --skill laravel-api --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of Laravel Api?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-laravel-api-c4ab16be)More formats (shields.io, HTML) on the badges page.
Define a named limiter and attach it to the API route group:
```php
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Support\Facades\RateLimiter;
RateLimiter::for('api', function ($request) {
return Limit::perMinute(60)->by(
$request->user()?->id ?: $request->ip()
);
});
```
```php
Route::prefix('v1')
->middleware(['throttle:api', 'auth:sanctum'])
->group(function () {
Route::get('/posts', [PostController::class, 'index']);
});
```
Key authenticated users by user ID and anonymous callers by IP so one user cannot consume a shared global bucket. Tune the limit by endpoint sensitivity and return Laravel's normal `429 Too Many Requests` response, including retry information where appropriate. Keep the limiter definition in the application service-provider bootstrap path and verify both authenticated and anonymous behavior with feature tests.
Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.
No comments yet. Be the first to comment!