I can add quota settings to an API product, and I can also add quota policies to an API proxy. How do those settings interact? Also, how do I reference quota settings on the product in a quota policy?
Solved! Go to Solution.
Good question, this brings up a common misconception about quota settings on an API product.
API products have a set of fields called "Quota" that allow you to configure how many requests per number of time periods (like 10 requests per 1 second) you want to allow. Just configuring this does NOT enforce quotas though!
Quotas are only enforced by adding a quota policy into your proxies. The configuration of the API Product Quota fields will populate variables that are accessible in your proxy, and these variables can be fed into a quota policy.
For example, if I have a VerifyAPIKey policy named VerifyKey, I'll have the following variables populated upon verification of a key with the Quota fields set as 10 requests per 1 second:
verifyapikey.VerifyKey.apiproduct.developer.quota.limit = 10 verifyapikey.VerifyKey.apiproduct.developer.quota.interval = 1 verifyapikey.VerifyKey.apiproduct.developer.quota.timeunit = second
I can then set the Quota policy like this (if the field is not set, I'm allowing a default of 2 calls per minute):
<Quota async="false" continueOnError="false" enabled="true" name="MyQuota" type="calendar"> <Allow count="2" countRef="verifyapikey.VerifyKey.apiproduct.developer.quota.limit"/> <Interval ref="verifyapikey.VerifyKey.apiproduct.developer.quota.interval">1</Interval> <TimeUnit ref="verifyapikey.VerifyKey.apiproduct.developer.quota.timeunit">minute</TimeUnit> <Identifier ref='verifyapikey.VerifyKey.client_id'/> <Distributed>true</Distributed> <Synchronous>false</Synchronous> <StartTime>2015-02-13 12:00:00</StartTime> </Quota>