Skip to main content
Version: 1.0.x

Configure your API Quotas

Lunar Quotas offer a flexible and centralized method for managing and configuring API quotas. These quotas can be both internal or provider-given, allowing users to set precise limits on API consumption. Quota management is defined in a quota.yaml file, shared across all flows within a Lunar Gateway, providing a scalable way to allocate and monitor API usage without shared state issues.

The Quota System is a key feature in this platform, enabling users to define quotas based on specific provider limits and internal limits based on your API consumption profile, such as monthly, daily, or other intervals. Quotas are dynamically updated as consumption occurs, ensuring real-time management across flows.


Quota File Structure​

The quota section defines the main constraints on API usage by specifying rate limiting strategies. This primary quota acts as the overarching rule for API requests, applying to all requests that match specified filters (e.g., URLs, headers). Quota's Filter allow quotas to be applied conditionally based on endpoint patterns or request headers, making it adaptable to different usage scenarios and customer types.

The internal_limits section is designed to set more specific constraints within the main quota by defining nested intenal limits that inherit from the main parent quota. Each internal limit can have its own filters and strategies, enabling precise control over distinct user groups or endpoints.

Benefits of Lunar Quota Management​

  • Real-time API Usage Monitoring: Automatically updated as quotas are consumed, ensuring accurate real-time usage statistics.
  • Granular Control: Ability to set quotas based on URLs, headers, and user groups. Nested quotas allow for more detailed control over specific API resources.
  • Scalability: Easily manage and track quotas across multiple API flows and user environments.

Quota Example​

Here’s an example of a quota configuration defined in a quota.yaml file:

/etc/lunar-proxy/quotas/{fileName}.yaml
quota:
id: MyQuota
filter:
url: api.website.com/*
strategy:
fixed_window:
max: 100
interval: 1
interval_unit: minute