TsgcWSRateLimiter › Properties › PerAPIKey
Rate-limit rule scoped to an API-key identifier (keys prefixed apikey:).
property PerAPIKey: TsgcRateLimitRule read FPerAPIKey write SetPerAPIKey;
—
Same structure as PerIP but scoped to an API-key identifier. The component recognizes keys that start with the prefix apikey: as API-key-scoped. Designed to integrate with TsgcWSAPIKeyManager so every customer gets an independent rate budget regardless of source IP. Ideal for SaaS with tiered pricing — differentiate customer tiers (Free / Pro / Enterprise) either through a PerEndpoint rule keyed by path prefix or by overriding the decision inside OnThrottled.
// Default API-key tier: 1000 req/min
sgcWSRateLimiter1.PerAPIKey.Enabled := True;
sgcWSRateLimiter1.PerAPIKey.Strategy := rlsSliding;
sgcWSRateLimiter1.PerAPIKey.MaxRequests := 1000;
sgcWSRateLimiter1.PerAPIKey.WindowSec := 60;