Different Quota Policy for each API Product

Suppose I have 500 API Proxies divided into 2 different API Products as follows

API_Product_1 contains first 300 API Proxies having quota of 10000 requests/day

API_Product_2 contains second 200 API Proxies of 5000 requests/day

So how many Quota Policies I need to have in API Proxy ? Do I need to have two Quota Policies one for each API Product like below then how api product is mapped to Quota policy, I mean how Quota Policy specify which API Product it will act upon ?

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Quota async="false" continueOnError="false" enabled="true" name="Quota">
    <DisplayName>Quota</DisplayName>
    <FaultRules/>
    <Properties/>
    <Interval ref="verifyapikey.Verify-API-Key.apiproduct.developer.quota.interval"/>
    <TimeUnit ref="verifyapikey.Verify-API-Key.apiproduct.developer.quota.timeunit"/>
    <Allow countRef="verifyapikey.Verify-API-Key.apiproduct.developer.quota.limit"/>
    <Distributed>true</Distributed>
    <Synchronous>true</Synchronous>
    <PreciseAtSecondsLevel>false</PreciseAtSecondsLevel>
    <!--
   <AsynchronousConfiguration> 
      <SyncIntervalInSeconds>20</SyncIntervalInSeconds> 
      <SyncMessageCount>5</SyncMessageCount> 
   </AsynchronousConfiguration> -->
   <Identifier ref="request.queryparam.tenantId"/>
</Quota>
0 3 947
3 REPLIES 3

@GAURAV ,

You just need one quota policy. You will configure the quota in API Product & use those values in quota policy using reference variables just like you mentioned above. You need to place your quota policy after the verifyApiKey policy to retrieve the values.

Apigee Edge automatically picks the API Product based on API Key that you are sending in the run time to retrieve quota values. Remember, API Key is associated with API Product. You choose API Products while creating developer apps which provide you keys to access APIs.

Steps to see it in action,

1. Create a proxy let's say proxy001 & API Product

4596-screen-shot-2017-04-06-at-94320-am.png

2. Update API Product Quota settings

4597-screen-shot-2017-04-06-at-94241-am.png

3. Create another proxy with another API Product

4. Update second product quota to different value

4598-screen-shot-2017-04-06-at-94731-am.png

5. Add quota policy to the proxy after the verify api key,

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Quota async="false" continueOnError="false" enabled="true" name="Quota-1">
    <DisplayName>Quota-1</DisplayName>
    <Properties/>
    <Allow countRef="verifyapikey.verify-api-key.apiproduct.developer.quota.limit"/>
    <Interval ref="verifyapikey.verify-api-key.apiproduct.developer.quota.interval">1</Interval>
    <TimeUnit ref="verifyapikey.verify-api-key.apiproduct.developer.quota.timeunit">month</TimeUnit>
    <Distributed>true</Distributed>
    <Synchronous>true</Synchronous>
</Quota>

6. Create an app & use the api key to make a call, See the quota in action,

4599-apigee4mv4d-apigee-and-new-tab.png

Sample proxy attached below.

proxy001-rev1-2017-04-06-1.zip

Hope it helps. Keep us posted if any.

Thanks @Anil Sagar

I understand the given example and it is like one quota policy with different API Products and

Apigee Edge automatically picks the API Product based on API Key that you are sending in the run time to retrieve quota values.

Now my actual use case is little complex

Suppose I have 500 API Proxies and have 3 different API Products as follows

P1 contains first 300 API Proxies having quota of 10000 requests/day

P2 contains second 200 API Proxies of 5000 requests/day

P3 contains all 500 API Proxies of 100000 requests/day

Now in our case tenant/customer will have multiple Developer Apps with different api keys having all API Products (1,2 and 3) , now suppose there is a call to API Proxy which is part of P1 & P3 from one of the Developer App , then will the quota gets reduced from both P1 & P3 to 999 & 99999 respectively ?

Also when another Developer App(different api key) from the same tenant hits the same API Proxy , then will the quota again gets reduced from both P1 & P3 to 998 & 99998 respectively ?

As we have the identifier as tenantId specified in Quota Policy below

<Identifier ref="request.queryparam.tenantId"/>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Quota async="false" continueOnError="false" enabled="true" name="Quota"> <DisplayName>Quota</DisplayName> <FaultRules/> <Properties/> <Interval ref="verifyapikey.Verify-API-Key.apiproduct.developer.quota.interval"/> <TimeUnit ref="verifyapikey.Verify-API-Key.apiproduct.developer.quota.timeunit"/> <Allow countRef="verifyapikey.Verify-API-Key.apiproduct.developer.quota.limit"/> <Distributed>true</Distributed> <Synchronous>true</Synchronous> <PreciseAtSecondsLevel>false</PreciseAtSecondsLevel> <!-- <AsynchronousConfiguration> <SyncIntervalInSeconds>20</SyncIntervalInSeconds> <SyncMessageCount>5</SyncMessageCount> </AsynchronousConfiguration> --> <Identifier ref="request.queryparam.tenantId"/> </Quota>

We want Quota to be applied based on tenantId from the query parameter and not from the api key.


See similar questions here and here & @Dino answer in same threads.