How to achieve Quota based on Dev App

Hi

Suppose we have two API Products each having different API Proxies with following quota P1 (10 requests per min), P2 (20 requests per min) . Now we have usecase

We have two Apps App1 and App2 both having P1 and P2 , now we want quota to apply on App or Appkey basis i.e App1 should have separate quota for both P1 and P2 and same with App2, it should not be cumulative for both App1 and App2.

Please send me the Quota Policy that should be present in each API Proxy.

Thanks

Solved Solved
0 6 783
1 ACCEPTED SOLUTION

Just change it to refer to custom attributes that you attach to the developer app.

<Quota name="Quota1">
    <Interval ref="verifyapikey.Verify-API-Key.app_quota_interval"/>
    <TimeUnit ref="verifyapikey.Verify-API-Key.app_time_unit"/>
    <Allow countRef="verifyapikey.Verify-API-Key.app_quota_count"/>
    <Identifier ref="request.queryparam.appkey"/>
</Quota><br>

VerifyApiKey sets app attributes as context variables, and prefixes them with verifyapikey.POLICYNAMEHERE .

So the above configuration would work if you had these three items on your app as custom attributes:

  • app_quota_interval
  • app_time_unit
  • app_quota_count

4230-custom-attrs-on-app.png

By the way, you don't need ALL of those items to be stored as custom attributes. If you plan to do monthly quotas, then you could hard-code 'month' as the timeunit , and not use a ref at all.

View solution in original post

6 REPLIES 6

@GAURAV , What have you tried ? Do you have any sample proxy to share ? Where exactly are you struggling ? You need to leverage app attributes in your case.

@Anil Sagar

I have tried this code but in this I have to provide the custom attributes in API Product like quotaInterval, quotaTimeUnit and quota.

I have to utilize the API Product out of box Quota configuration.

Also is this configuration correct for my usecase ?

<?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.quotaInterval"/>
    <TimeUnit ref="verifyapikey.Verify-API-Key.apiproduct.quotaTimeUnit"/>
    <Allow countRef="verifyapikey.Verify-API-Key.apiproduct.quota"/>
    <Identifier ref="request.queryparam.appkey"/>
</Quota>

Just change it to refer to custom attributes that you attach to the developer app.

<Quota name="Quota1">
    <Interval ref="verifyapikey.Verify-API-Key.app_quota_interval"/>
    <TimeUnit ref="verifyapikey.Verify-API-Key.app_time_unit"/>
    <Allow countRef="verifyapikey.Verify-API-Key.app_quota_count"/>
    <Identifier ref="request.queryparam.appkey"/>
</Quota><br>

VerifyApiKey sets app attributes as context variables, and prefixes them with verifyapikey.POLICYNAMEHERE .

So the above configuration would work if you had these three items on your app as custom attributes:

  • app_quota_interval
  • app_time_unit
  • app_quota_count

4230-custom-attrs-on-app.png

By the way, you don't need ALL of those items to be stored as custom attributes. If you plan to do monthly quotas, then you could hard-code 'month' as the timeunit , and not use a ref at all.

Not applicable

HI,

You can use custom attribute to control the limit values at Dev App level.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Quota async="false" continueOnError="false" enabled="true" name="set-quota-limit" type="flexi"> <DisplayName>Set Quota Limit</DisplayName> <Properties/> <Identifier ref="client_id"/> <Allow count="3000" countRef="apiproduct.user.quota.limit"/> <Interval>1</Interval> <TimeUnit ref="apiproduct.user.quota.timeout">month</TimeUnit> </Quota>

here user.quota.timeout and user.quota.limit 2 custom attribute in product.

Is there anyway to achieve collective quota per developer app? for example "dev app1" has access to api1, api2 and api3. Can we set a collective quota for "dev app1" that is shared across apis it has access to?

Is there anyway to achieve collective quota per developer app?

Is there any way you could ask this as a new question, instead of posting a new question as an "answer" to a 18-month old question?