The best time to establish protocols with your clients is when you onboard them.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse varius enim in eros elementum tristique. Duis cursus, mi quis viverra ornare, eros dolor interdum nulla, ut commodo diam libero vitae erat. Aenean faucibus nibh et justo cursus id rutrum lorem imperdiet. Nunc ut sem vitae risus tristique posuere.
AWS API Gateway is a fully managed service provided by Amazon Web Services (AWS) that enables developers to create, publish, monitor, and secure APIs at any scale. Furthermore, AWS API Gateway seamlessly integrates with other AWS services, such as AWS Lambda, AWS Step Functions, and Amazon DynamoDB, enabling developers to build serverless architectures and create powerful API-driven applications.
AWS API Gateway introduced usage plans in October 2015. Usage plans are a feature that allows API owners to manage and control access to their APIs by defining usage limits and associated quotas for individual API keys or client IDs. With usage plans, you can provide your API as an offering. For example, if you had some AI-powered Backend you can take that API into the market by sorting the clients under usage plans (normal, premium..). This Article contains four sections.
The reader should understand what a lambda function is, as well as how to create a function in AWS Lambda and an API in API Gateway.
Usage plans in API Gateway enable you to set limits on the number of requests an API key or client can make within a specified time period. These limits are typically set as a steady-state rate limit, which defines the maximum number of requests allowed per second, minute, or hour.
When using usage plans, API keys can be associated with specific plans, allowing you to control access and set usage limits on a per-key basis.
The throttling limit refers to the maximum number of requests that an API key or client is allowed to make within a specified time period. It is a mechanism for controlling the rate at which requests are processed by an API.
Burst requests provide some flexibility by allowing occasional bursts of traffic that exceed the steady-state rate limit. It allows a certain number of requests to be processed immediately, even if they exceed the defined rate limit, instead of being throttled or rejected.
A quota limit sets the target maximum number of requests with a given API key that can be submitted within a specified time interval.
SECTION-2:
2. Get the code from here:
3. From the API gateway console create an API with Name demo-API-usage-plan in the same region where Lambda is created.
4. Under this API create a New Resource named /usageplanOffering.
5. Create a POST method under this resource and establish a proxy integration between the lambda you created (demo-lambda-usage-plan) previously and this method.
6. Finally, deploy the API to the stage usage-plan-test.
SECTION-3:
Now, let’s create an API Key and Usage Plan.
2. From API Gateway Console → Usage Plans → Create a New Usage plan named “demo-usage-plan”.
3. Tick Enable Throttling & Quota and configure the fields as per your requirements. Here we are providing a Quota of 5 requests per day. (please refer to the keywords section in this article). Now click “Next”.
4. Here we need to associate the API (demo-API-usage-plan), API Stage(usage-plan-test), resource (/usageplanoffering), and Method to the usage plan(demo-usage-plan) and click “Next”.
5. Select the API Keys tab and associate the API Key we created (testApikey) previously.
6. From the Usage option you can view the graph of the number of invocations made by this API Key.
7. From API Gateway Console → Resources → POST Method pane → Method Request → change the status of API Key required to true.
8. From API Gateway Console → Stages, again deploy the API to stage (usage-plan-test).
9. Now copy the method invocation URL and paste it in Postman.
10. From API Gateway Console → API KEYS, select testApikey and copy the API key.
11. Now put this API KEY in Headers with a key name “X-API-Key”.
12. Now use the request body as shown and make a request. The API will respond with a status of 200 for the first 5 invocations. For the sixth invocation, it will respond with a status code of 429 (Too Many Requests).
13. To view the invocations count visit Api gateway console → usage Plans → select (demo-usage-plan) → API Keys tab → click usage.
14. Using the export option you can export to JSON or CSV.
SECTION-4:
Important points to remember:
Get more updates and further details about your project right in your mailbox.