Apigee provides two different ways to impose a quota on an API proxy. It can be done at the proxy level by incorporating a Quota policy and setting the allowable rate. It can also be done at the API product level by defining a rate that could potentially apply to all proxies within the product. In this hands-on lab, we’ll learn how to set up an API product and an API proxy so that a quota at the API product level would be enforced, superseding a quota set at the proxy level.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Set the Quota in the API Product
- On the Apigee dashboard page, click API Products.
- Click LA Weather Product to open it.
- Click Edit.
- In the Quota section, set the following values:
- 3 requests every 1 Minute.
- Click Save.
- Add a Verify API Key Policy to the API Proxy
- In the left navigation menu, click Develop > API Proxies.
- Select LA-Weather from the list of proxies.
- In the Proxy Endpoints section of the Navigator, make sure that PreFlow is selected.
- In the Request area at the top of the page, click + Step.
- In the dialog box, scroll down to Security, and select Verify API Key.
- Accept the default names, and click Add.
- Click Save.
- Add the Quota Policy
- In the Proxy Endpoints section of the Navigator, select PreFlow.
- In the Request area at the top of the page, click + Step.
- Under Traffic Management, select Quota.
- Leave the default names, and click Add.
- Change the values of
<Distributed>
and<Synchronous>
to true. - Delete the
<StartTime>
and<AsynchronousConfiguration>
elements. - In the
"Quota-1"
element, remove thetype="calendar"
attribute. - Modify the following elements as shown:
<Allow count="200" 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">hour</TimeUnit> - Under the Flow section, select the Spike Arrest policy.
- In the
<SpikeArrest>
element, change theenabled
parameter fromtrue
tofalse
. - Click Save.
- Test the Product-Level Quota
- In the side navigation menu, click Publish > Apps.
- Select LA Weather App from the list of apps.
- In the Credentials section, next to Key, click Show.
- Copy the revealed API key.
- Under Product, click LA Weather Product.
- On the Product page, click the LA-Weather API proxy link.
- Select the Trace tab.
- In the URL field, add the following query parameters to the API proxy URI:
?q=atlanta&apikey=[YOUR_APP_API_KEY] - Click Start Trace Session.
- Click Send 3-4 times within one minute.
- Review the results.