Throttling allows you to limit the number of hits to an API during a given period of time, 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 Cloud, see Throttling tiers.
Let's get started.
Log in to the API Store and select the
Subscribe to the API using the
Bronzetier if you haven't done so already.
In the API Store, click the APPLICATIONS menu, click
DefaultApplicationto open it, and then click the Production Keys tab. If you already have an access token for the application, you may have to scroll down and click Re-generate. Access tokens expire 1 hour after creation unless you extend the period.
Let's invoke this API.
Click on the API, then go to its API Console tab and expand the GET method.
Give values to the parameters (PhoneNumber 18006785432 and LicenseKey 0) and click Try it out to invoke the API.
Note the response that appears in the API Console. As we used a valid phone number in this example, the response returns as valid.
- 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.
Let's try to invoke the API using an unavailable resource name.
Click the APIs menu in the API Store, click the API you want to invoke and then copy the production URL in the API's Overview tab.
Append the payload to the API's URL you copied earlier. For example, https://gateway.api.cloud.wso2.com:443/t/companyn3/phoneverify/1.0.0/CheckPhoneNumber?PhoneNumber=18006785432&LicenseKey=0.
Let's invoke the API.
Install cURL or any other REST client.
Go to the command-line and invoke the API using the following cURL command.
Note that the
PhoneVerificationAPI's resource name is
CheckPhoneNumber, but we use an undefined resource name as
Here's an example:
- Note that the call gets blocked by the API Gateway with a 'no matching resource' message. It doesn't reach your backend services as you are trying to access a REST resource that is not defined for the API.
You have seen how the API Gateway enforces throttling and resource access policies for APIs.