[{"data":1,"prerenderedAt":31},["ShallowReactive",2],{"$f18ccr6eekgrn5":3,"$fgph23vl6tmr9":23},{"content":4,"package":5,"version":22},"# Rate Limiting\n\nThe shipping estimate endpoint is unauthenticated and, depending on your shipping calculators, a single request can trigger a call to an external carrier API. The plugin can rate limit it using the [Symfony RateLimiter component](https:\u002F\u002Fsymfony.com\u002Fdoc\u002Fcurrent\u002Frate_limiter.html).\n\nEvery estimate response is also sent with `Cache-Control: no-store, private`, so a shared cache or CDN in front of your shop never serves one customer's rates to another.\n\n## Installing\n\nThe component is an optional dependency:\n\n```bash\ncomposer require symfony\u002Frate-limiter\n```\n\nThe plugin's default reflects whether you have it:\n\n- **installed** — rate limiting is **on** by default, and you can turn it off\n- **not installed** — rate limiting is **off** by default, and the configuration is inert\n\n## Configuration\n\nThe defaults allow 30 estimates per client address per minute:\n\n```yaml\nbabdev_sylius_shipping_estimate:\n    rate_limiter:\n        enabled: true\n        policy: 'sliding_window'\n        limit: 30\n        interval: '1 minute'\n        cache_pool: 'cache.rate_limiter'\n        lock_factory: ~\n```\n\n| Option         | Description                                                                                                            |\n|----------------|------------------------------------------------------------------------------------------------------------------------|\n| `enabled`      | Whether to limit at all. Defaults to whether the RateLimiter component is installed.                                   |\n| `service`      | The service ID of your own rate limiter factory. When set, every other option is ignored.                              |\n| `policy`       | One of `fixed_window`, `sliding_window`, `token_bucket` or `no_limit`.                                                 |\n| `limit`        | Estimates allowed per client in one interval.                                                                          |\n| `interval`     | The window the limit applies over, such as `1 minute`.                                                                 |\n| `cache_pool`   | The cache pool holding the limiter state.                                                                              |\n| `lock_factory` | A lock factory making limiter updates atomic. Off by default, as it needs the Lock component installed and configured. |\n\nTo turn it off without removing the component:\n\n```yaml\nbabdev_sylius_shipping_estimate:\n    rate_limiter:\n        enabled: false\n```\n\n### Using Your Own Limiter\n\nIf you already define limiters in your application, point the plugin at one and it will be used as-is:\n\n```yaml\nframework:\n    rate_limiter:\n        shipping_estimate:\n            policy: 'token_bucket'\n            limit: 10\n            rate: { interval: '15 seconds' }\n\nbabdev_sylius_shipping_estimate:\n    rate_limiter:\n        service: 'limiter.shipping_estimate'\n```\n\n## What The Customer Sees\n\nWhen a client exhausts its allowance the endpoint answers `429 Too Many Requests` with `Retry-After`, `X-RateLimit-Limit` and `X-RateLimit-Remaining` headers, and this body:\n\n```json\n{\"error\": true, \"options\": [], \"reason\": \"shipping_estimate_rate_limited\"}\n```\n\nThe bundled JavaScript shows the translated `babdev_sylius_shipping_estimate.ui.shipping_estimates_requested_too_quickly` message.\n",{"name":6,"slug":7,"previousSlugs":8,"description":10,"github":11,"packagistName":14,"packageType":15,"hasDocumentation":16,"supported":16,"visible":16,"versions":17},"Sylius Shipping Estimate Plugin","shipping-estimate-plugin",[9],"syliusshippingestimateplugin","Adds a shipping estimator widget to a Sylius website's cart",{"owner":12,"repo":13},"BabDev","SyliusShippingEstimatePlugin","babdev\u002Fsylius-shipping-estimate-plugin","sylius-plugin",true,[18],{"version":19,"gitBranch":20,"released":21},"1.x","0.3",false,{"version":19,"gitBranch":20,"released":21},{"content":24,"package":25,"version":30},"- [Introduction](\u002Fopen-source\u002Fpackages\u002Fshipping-estimate-plugin\u002Fdocs\u002F1.x\u002Fintro)\n- [Installation & Setup](\u002Fopen-source\u002Fpackages\u002Fshipping-estimate-plugin\u002Fdocs\u002F1.x\u002Finstallation)\n- [Customize the Output](\u002Fopen-source\u002Fpackages\u002Fshipping-estimate-plugin\u002Fdocs\u002F1.x\u002Fcustomize-the-output)\n- [Hooking The Estimator](\u002Fopen-source\u002Fpackages\u002Fshipping-estimate-plugin\u002Fdocs\u002F1.x\u002Fhooking-the-estimator)\n- [Rate Limiting](\u002Fopen-source\u002Fpackages\u002Fshipping-estimate-plugin\u002Fdocs\u002F1.x\u002Frate-limiting)\n",{"name":6,"slug":7,"previousSlugs":26,"description":10,"github":27,"packagistName":14,"packageType":15,"hasDocumentation":16,"supported":16,"visible":16,"versions":28},[9],{"owner":12,"repo":13},[29],{"version":19,"gitBranch":20,"released":21},{"version":19,"gitBranch":20,"released":21},1790007747620]