Amazon Web Service – Introduction to API Gateway
Firstly, API stands for Application Program Interface. An API Gateway is a management tool that acts as an interface between users and microservices. The Amazon API Gateway is an AWS service that allows users to create, publish, secure, maintain and monitor APIs at any scale. You can create APIs in your client application and can also make them available to third-party developers. It is serverless. It supports HTTP, WebSocket, and REST APIs. API Gateway is a type of server that provides the service of API which is used to customize each client.
The Netflix API Gateway is the most popular example of API Gateway. Many e‑commerce site uses an API gateway to provide the endpoint for retrieving the details of all products from mobile clients with only a single request. So, This invokes many different services like the proper information of product, and product reviews and then combines the results.
What is Amazon API Gateway?
Amazon API gateway is fully managed by Amazon Web Services (AWS) which makes it easier to publish, maintain, monitor, and secure APIs at any scale. APIs act as a server between client applications and backend services if clients make any API request they will all go through this particular API. APIs are responsible for routing the request from the client side to the appropriate services, as well as performing other tasks such as authentication, authorization, and traffic management. Following are some of the features that make it more powerful.
- Traffic Management
- CORS support
- Authorization, authentication, and Access Control
- Request routing, shaping, and Management
- Throttling (The process of limiting the number of API requests a user can make in a certain period)
- API Health Monitoring
- API version Management
- Load balancing
- Caching
- Static response handling
- Protocol translation
- Composition
How Amazon API Gateway Works?
An API Gateway endpoint receives requests from clients. The request will be routed to the relevant backend service via API Gateway to the proper service. After processing the request, the backend service provides a response then the client receives the response from API Gateway.
What types of APIs does Amazon API Gateway support?
Following are some of the different types of APIs
REST APIs Private and Public
Representational State Transfer (REST) is an architectural style that defines a set of constraints to be used for creating web services. REST API is a way of accessing web services in a simple and flexible way without having any processing. To know more refer to the REST API Introduction.
SOAP APIs
Simple Object Access Protocol(SOAP) is a network protocol for exchanging structured data between nodes. It uses XML format to transfer messages. It works on top of application layer protocols like HTML and SMTP for notations and transmission. SOAP allows processes to communicate throughout platforms, languages and operating systems, since protocols like HTTP are already installed on all platforms.To know more refer to the Basics of SOAP – Simple Object Access Protocol.
GraphQL APIs
We will use GraphQL API for demonstration. GraphQL is an open-source data query and manipulation language for APIs and a runtime for fulfilling queries with existing data. It’s neither an architectural pattern nor a web service. GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015.To know more refer to the GraphQL | Query.
WebSocket APIs
Web API is an API as the name suggests, it can be accessed over the web using the HTTP protocol. It is a framework that helps you to create and develop HTTP based RESTFUL services. The web API can be developed by using different technologies such as java, ASP.NET, etc. Web API is used in either a web server or a web browser. Basically Web API is a web development concept.To know more refer to the What is Web API and why we use it ?.
Amazon API Management Components
Following are some Amazon API Management Components that you need to be familiar with to get a better understanding.
- HTTP (HyperText Transfer Protocol) API is an application layer protocol that helps to communicate over the World Wide Web to get the data.
- REST (Representational State Transfer ) API takes the HTTP standards to perform operations of GET, POST, PUT, PATCH, and DELETE on the data.
- WebSocket is a device communication protocol that provides point-to-point system communication channels over a single TCP. It enables stateful, full-duplex communication between client and server.
Benefits Of Amazon API Gateway
- Simple to Use: The AWS console provides very simple UI to use API GW which make its easy to manage and monitoring APIs.
- Scalable: Usually Amazon web services maintains very high scalable API gate ways then only they can handle the heavy demanding workloads.
- High Secure: API Gateway offers several capabilities, like custom authorizers and IAM integration, to help secure APIs.
- Exposes Backend Services: We can expose backend services to external clients, such web applications, mobile applications, and other APIs, with the use of API gateways.
Features of Amazon API Gateway
- API creation and deployment: Creating different types of APIs and managing them will be very easy.
- Authorization and access control: With the help of IAM roles, IAM policies, and custom authorizers you can achieve authorization and control mechanisms that API Gateway offers for your APIs.
- Traffic management: Load balancing, throttling and chaching are the some of the services offered by the API Gateway to managethe traffic.
- API versioning: Based on the request you API Gateway will route the traffic to the and to route traffic to the appropriate version based on the client’s request.
Pricing of Amazon API Gateways (GW)
You pay for use only, i.e you pay for the API calls you receive and the amount of data transfer. There is an optional data caching charged at an hourly rate that varies based on the cache size you select.
Amazon also provides free tier services for up to 12 months, which includes:
- 1 million HTTP API calls
- 1 million REST API calls
- 1 million messages
- 750,000 connection minutes per month
Take a look at the below table for standard pricing of Amazon API Gateway:
Pricing for the API Calls | ||
---|---|---|
APIs | No. of requests per month | Price(per million) |
HTTP | First 300 million | $1.00 |
300+ million | $0.90 | |
REST | First 333 million | $3.50 |
Next 667 million | $2.80 | |
Next 19 billion | $2.38 | |
Over 20 billion | $1.51 | |
WebSocket | First 1 billion | $1.00 |
Over 1 billion | $0.80 |
Amazon API Gateway Architecture
The below diagram shows how the APIs built-in Amazon API Gateway provides customers with an integrated and consistent developer experience for building AWS serverless applications. It acts as a gateway for applications to access data from your backend services such as code running on Amazon Elastic Compute Cloud (Amazon EC2), AWS Lambda, any web applications, etc.
The entire architecture of AWS API Gateway consists of the below key components:
- Amazon API Gateway: It is used to create, publish, secure, maintain and monitor APIs.
- API Gateway Cache: Users can enable API caching to cache their endpoint responses, which can reduce the number of calls made to the endpoint and also improve the latency of API requests.
- Amazon Cloud Watch: It is a monitoring and observability service. It collects monitoring and operational data and visualizes it using automated dashboards, which allows users to visually monitor calls to their services.
Working With Amazon API Gateway
The Amazon API Gateway can be accessed through the following:
- AWS Management Console
- AWS SDKs, API Gateway V1, and V2 APIs
- AWS Command Line Interface
- AWS Tools for Windows PowerShell
For example, if you want to create an HTTP API, first, you have to create a lambda function and for creating a AWS lambda function, you have to use the lambda service of AWS, then you have to create HTTP API using API Gateways followed by testing the API.
Let us look at AWS API Gateways on the AWS management console. Login to your AWS account. Once you are redirected to the AWS management console. Click on “Services”. Search on the search bar for API Gateways. Refer to the given image:
In This Article we will try to create HTTP API Gatewway.
Steps To Create HTTP API Gatewway
Follow the steps mentioned below to HTTP API Gateway
HTTP API is an protocol which is used to communicate between the cline and servers.
Step 1: Chosse the API type according the organization requirement. Here we are going to select the HTTP API for demonstration purpose.
Step 2: In this step we need to select the integration with which the API is going to work. The integartions are like an backend part with which the API is going to work. API gate waye will invoke the lambda function and responds with the response from the function.
Step 3: API gateway will uses the routes to expose integrations to the end users of the API. And select the the type of method which you are going to use depending on the requirment of the organization like.
- GET
- POST
- PATCH
- HEAD.
Step 4: This stage where we are going to deploy our API gateway.
Step 5: After configuring the all the details know click on review create. After completion of review create with the name which you have been given there will be API created.
Amazon API Gateways Advantages
Following are the advantages of using the API Gateway:
- It helps in efficient API development. Users can run multiple versions of the same API simultaneously with API Gateway, allowing users to quickly iterate, test, and release new versions.
- It provides the lowest latency possible latency (time taken by data to pass one point in the network to another) for API requests and responses.
- Users can easily monitor performance and information using the API Gateway dashboard.
- It is cost-saving at scale i.e user can decrease their costs as their API usage increases per region across their AWS accounts.
- It gives flexible security control by providing access to APIs with AWS Identity, Access Management (IAM), and Amazon Cognito.
- With API gateways, the coding efforts reduces which makes the application more efficient. Also, there is less chances of errors all at the same time.
- The API Gateway helps to encapsulates the internal structure of many application.
- In API Gateway, the client directly talks rather than invoking the specific service.
- Handling multiple API’s handling is much easy with API gateway.
Amazon API Gateways Disadvantages
Following are the disadvantages of using the API Gateway:
- Not much Secure. Many a times, it is very difficult to implement the security practices in every API call. From which leads to difficulty in tracking their performance.
- API gateway is tough to consider as reliable.
- It is very difficult to maintain API gateway updates regularly with the inclusion of every microservice. So, when a single application turns into the services of millions of microservices then this becomes very hectic to handle.
- API gateway requires the routing rules. so, there are much more possibility of failure from a single point.
- In API Gateway, there are all the API rules in one place. So, there is Risk of complexity.
FAQs On AWS API Gateway(GW)
1. AWS API Gateway Full Form
The full form of AWS API Gateway is Amazon Application Programming Interface Gateway.
2. AWS API Gateway Timeout
Following are the some reasons that you are getting this timeout error
- The backend service which is used to route the API request is to slow or unresponsive.
- The data which is being processed is large amount.
3. AWS API Gateway Limits
The main purpose of the limits is to protect the service and ensures reliable and high-performance experience for all users.Following are the some of the limits
- Request rate
- Concurrent connections
- API size
- Response size.
Contact Us