How to limit maximum number of API calls with no pre-defined time limit like in Quota?

Not applicable

How to limit maximum number of API calls with no pre-defined time limit like in Quota?

Solved Solved
3 8 489
1 ACCEPTED SOLUTION

What you are looking for is not supported. Implementing this in custom way is also very difficult (distributed quota counters).

I would go with very long intervals:

<Interval>99999</Interval>
<TimeUnit>month</TimeUnit>

View solution in original post

8 REPLIES 8

The 'flexi' quota specifies the quota for a time period i.e., 1 week or 1 month or whatever the period is. I just want to limit the number of API calls without a time period.

i.e., Allow only 5 API calls. This should be without a time limit. The 5 calls can take place in a day, month or year. Once the 5 calls are complete anytime, revoke the access.

I need this functionality

I would do as Ozan suggests and set a long interval. A very long interval (Ozan's example is over 8000 years) is effectively without time limit.

Now, you can argue that sort of thinking is just the type of thing that got us in trouble with the Y2K issues, but if you are building APIs that are going to last for decades, let alone centuries, you are a lucky person! 😉

I think the Quota policy, also quota with API products are defined with time intervals. If your requirement is to limit based on some identifier without a time limit, then you might have go with a custom implementation (e.g. using a Key-Value Map). It's an interesting requirement though.

What you are looking for is not supported. Implementing this in custom way is also very difficult (distributed quota counters).

I would go with very long intervals:

<Interval>99999</Interval>
<TimeUnit>month</TimeUnit>

Interesting use case. As Ozan has commented, it's possible to do this by specifying an extremely long expiry period. I'd love to hear more about the use case, if you care to share.

Not applicable

Hello,

Apologies for the delayed reply in answering to the post. We had stopped the development in between due to some blockers. Thank you for answering the questions nevertheless

The use case is simple as per our requirement:

Allow the user for a one-time-subscription wherein he is allowed to make a certain number of calls just once and be done. If he wants another set of calls, he has to subscribe again via our platform. That's the requirement in general.

Hi @Hardik Kamdar,

What you are describing is a natural usecase for Monetization, you can find more details about it here,

http://apigee.com/docs/monetization/content/basics-monetization

Typically, you would configure a ratecard or a simple fees based plan and allow only certain number of calls, if the user has consumed all of them, they will have to subscribe for more. This will also allow you to extend your subscription model with additional usecases [prepaid or postpaid, revenue sharing, ratecards, message weights etc..]

Thanks,