Enforcing an Apigee Product Quota

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

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
  1. On the Apigee dashboard page, click API Products.
  2. Click LA Weather Product to open it.
  3. Click Edit.
  4. In the Quota section, set the following values:
    • 3 requests every 1 Minute.
  5. Click Save.
Add a Verify API Key Policy to the API Proxy
  1. In the left navigation menu, click Develop > API Proxies.
  2. Select LA-Weather from the list of proxies.
  3. In the Proxy Endpoints section of the Navigator, make sure that PreFlow is selected.
  4. In the Request area at the top of the page, click + Step.
  5. In the dialog box, scroll down to Security, and select Verify API Key.
  6. Accept the default names, and click Add.
  7. Click Save.
Add the Quota Policy
  1. In the Proxy Endpoints section of the Navigator, select PreFlow.
  2. In the Request area at the top of the page, click + Step.
  3. Under Traffic Management, select Quota.
  4. Leave the default names, and click Add.
  5. Change the values of <Distributed> and <Synchronous> to true.
  6. Delete the <StartTime> and <AsynchronousConfiguration> elements.
  7. In the "Quota-1" element, remove the type="calendar" attribute.
  8. 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>
  9. Under the Flow section, select the Spike Arrest policy.
  10. In the <SpikeArrest> element, change the enabled parameter from true to false.
  11. Click Save.
Test the Product-Level Quota
  1. In the side navigation menu, click Publish > Apps.
  2. Select LA Weather App from the list of apps.
  3. In the Credentials section, next to Key, click Show.
  4. Copy the revealed API key.
  5. Under Product, click LA Weather Product.
  6. On the Product page, click the LA-Weather API proxy link.
  7. Select the Trace tab.
  8. In the URL field, add the following query parameters to the API proxy URI:
    ?q=atlanta&apikey=[YOUR_APP_API_KEY]
  9. Click Start Trace Session.
  10. Click Send 3-4 times within one minute.
  11. Review the results.

Additional Resources

Management has decided to offer a number of API products featuring the LA Weather API proxy. You've been asked to add a quota level to the existing API product that will overrule any quota settings within individual proxies.

You’ll need to complete the following steps to accomplish your task:

  1. Set the quota in the API product.
  2. Add a Verify API Key policy to the API proxy.
  3. Add a Quota policy to the API proxy.
  4. Test the product-level quota.

Please note: There are several prerequisites for this hands-on lab.

  1. You must have an Apigee account.
  2. You must have completed the following hands-on labs: Creating an Apigee API Proxy, Testing an API Proxy, and Establishing a Developer App for Apigee.
  3. Optionally, you should have registered for an API key with OpenWeathermap.org.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?