Rate limit outgoing requests made with Laravel's HTTP client
roundly-consulting/http-client-rate-limits-for-laravel is a Laravel package for rate limit outgoing requests made with laravel's http client.
It currently has 5 GitHub stars and 406 downloads on Packagist (latest version 1.1.1).
Install it with composer require roundly-consulting/http-client-rate-limits-for-laravel.
Discover more Laravel packages by roundly-consulting
or browse all Laravel packages to compare alternatives.
Last updated
Rate limit the outgoing requests you make with Laravel's HTTP client, so you never blow past a
third-party API's quota. When a budget is spent the request waits for the next free slot
instead of earning a 429; compound windows, per-owner budgets, server-adaptive limits and
shared stores come built in.
Requires PHP 8.4 and Laravel 12 or 13.
composer require roundly-consulting/http-client-rate-limits-for-laravel
The default InMemoryStore counts per process. With several workers, share one budget by
setting HTTP_CLIENT_RATE_LIMITS_STORE to the CacheStore, RedisStore or DatabaseStore
class (the last one needs its tables:
php artisan vendor:publish --tag="http-client-rate-limits-migrations", then migrate).
Throttle any HTTP client call with the rateLimit() macro and the RateLimits facade:
use Illuminate\Support\Facades\Http;
use RoundlyConsulting\HttpClientRateLimits\Facades\RateLimits;
// 5 requests per second; the sixth waits for a free slot, then goes out.
Http::rateLimit(RateLimits::perSecond(5))->get('https://api.example.com/things');
// 30 per minute, with a separate budget per account.
Http::rateLimit(30, by: 'acct-1')->get('https://api.example.com/orders');
Combine windows, follow the server's own limits and cap the wait:
$limit = RateLimits::perSecond(5)
->alongside(RateLimits::perMinute(100)) // both windows apply; the strictest wins
->adaptive() // honour Retry-After / X-RateLimit-* headers
->maxWait(5_000); // throw RateLimitExceededException past 5 s
Http::rateLimit($limit)->get('https://api.example.com/report');
$limit->remaining(); // requests left in the window, without sending one
The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/http-client-rate-limits-for-laravel
Release notes are in CHANGELOG.md. To contribute, see the contributing guide.
This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.
The MIT License (MIT). Please see License File for more information.