Enforce Throttling and Resource Access Policies

Throttling allows you to limit the number of hits to an API during a given period, typically to protect your APIs from security attacks and your backend services from overuse, regulate traffic according to infrastructure limitations and to regulate usage for monetization. For information on different levels of throttling in WSO2 API Manager (WSO2 API-M), see Throttling tiers .

Note

This tutorial uses the PizzaShack API, which has  GET and POST methods to access it and a throttling policy enforced.

Before you begin , follow the Create and Publish an API to create and publish the PizzaShack API and then the Subscribe to an API to subscribe to the API using the Bronze throttling tier.

After you created, published, and subscribed to the API, let's see how the API Gateway enforces throttling and resource access policies to the API.

  1. Sign in to the Developer portal and select the PizzaShack API. Go to the subscriptions tab and make sure we have subscribed to an application or if not subscribe. Subscribed Applications

  2. Go to the Applications tab and go in to the Default Application, click the Production Keys tab and generate an access token. If you already have an access token for the application, you have to regenerate it after 1 hour. Copy the access token after it has been generated. Generate-keys

    Let's invoke this API.

  3. Click on the API, then go to its Try Out tab. Enter the copied access token. Tryout

  4. Expand the GET method and click Try it out. Provide the required parameters and click Execute to invoke the API. For example,

    OrderID E.g., 7fd574cc-49e7-4491-973c-08214b2c64fc

    Query

    Note the response that appears in the API Console. As we used a valid order id in this example, the response returns a correct order details. Query response

    Note that you subscribed to the API on the Bronze throttling tier. The Bronze tier allows you to make a 1000 calls to the API per minute. If you exceed your quota, you get a throttling error as shown below. Error response

Top