Amazon API Gateway

Nupur Sogani
5 min readApr 18, 2022
API Gateway

Amazon API Gateway helps developers to create and manage APIs to back-end systems running on Amazon EC2, AWS Lambda, or any publicly addressable web service. With Amazon API Gateway, we can generate custom client SDKs for our APIs, to connect our back-end systems to mobile, web, and server applications or services.

What is an API?

API is the acronym for Application Programming Interface, which is a software intermediary that allows two applications to talk to each other. An application programming interface is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software.

How API works

It is the software intermediary that delivers a request to the server and then relays a response back to the client.

There are several HTTP methods like GET, POST, UPDATE, DELETE etc., these are like one functionality or interface for program (hence, API). Its up to developer what functionalities it provides to the client. Not all programs support all of them. For example, when we search something in Google, the result we see is by GET method.

Google search result for www.redhat.com
output for same URL on Postman

In the image above we can see the result of search www.redhat.com. By using this in Postman app we can see that this is the result of GET request. On this same URL, there is no way that we can send our data i.e. POST because the developer hasn’t given that functionality.

Now, we see in LinkedIn, we get both functionalities i.e., we can see the data(GET) and also can send data(POST).

The data that we see comes in via GET method whereas when we upload any article or message someone we are making use of POST method which makes use of different APIs as we can see the different URL paths for different purposes.

API Gateway

An API gateway is an API management tool that sits between a client and a collection of backend services.

Why use an API gateway?

Basically, an API service accepts a remote request and returns a response. But real life is never that simple. There are various concerns while hosting large-scale APIs.

  • We want to protect our APIs from overuse and abuse, so we use an authentication service and rate limiting.
  • We want to understand how people use our APIs, so we’ve added analytics and monitoring tools.
  • We may have adopted a microservices architecture, in which case a single request could require calls to dozens of distinct applications.
  • Over time we’ll add some new API services and retire others, but our clients will still want to find all our services in the same place.

Modern cloud development, including the serverless model, depends on APIs for provisioning infrastructure. We can deploy serverless functions and manage them using an API gateway.

Amazon API Gateway

Amazon API Gateway helps to create, maintain and secure APIs at any scale. When we create web servers, we share our webapp to clients. Server has some limits with respect to network bandwidths, number of connections, amount of data transferred etc. Instead of worrying about server, AWS helps us to create fully managed web servers where client comes and it is responsibility of AWS to maintain server, set limits etc. It provides resources on the fly i.e., scale them as and when required. This also helps to save monetary resources.

API Gateway can also filter the data coming from client like malicious traffic or DOS attack using WAF or Web Application Firewall.

API Gateway Use Cases

  1. Use API Gateway to create HTTP APIs : We can create an HTTP API that integrates with a Lambda function on the backend. When a client calls API, API Gateway sends the request to the Lambda function and returns the function’s response to the client.
  2. Use API Gateway to create REST APIs: An API Gateway REST API is made up of resources and methods. For example, /incomes could be the path of a resource representing the income of the app user. A resource can have one or more operations that are defined by appropriate HTTP verbs such as GET, POST, PUT, PATCH, and DELETE. A combination of a resource path and an operation identifies a method of the API. For example, a POST /incomes method could add an income earned by the caller, and a GET /expenses method could query the reported expenses incurred by the caller.
  3. Use API Gateway to create Websocket APIs: In a WebSocket API, the client and the server can both send messages to each other at any time. Backend servers can easily push data to connected users and devices, avoiding the need to implement complex polling mechanisms.

To create one API Gateway :

  1. Go to API Gateway in Amazon Web Console.
  2. Select REST API -> Build -> Protocol : REST
  3. Create new API -> Name: testgateway , Endpoint: Regional -> Create API
  4. Create resource, give the url of endpoint, enable CORS.
  5. Create method -> Integration type (HTTP/Lambda/VPC/Amazon services etc.)
  6. Actions -> Deploy API -> Stage -> Deploy

A URL is invoked which we use to reach to server rest all is managed by AWS. It can also work as reverse proxy.

Over 80,000 companies use Amazon API Gateway. Amazon API Gateway is most often used by companies with 10–50 employees and 1M-10M dollars in revenue.

Some companies that uses Amazon API Gateway are Lorven Technologies, Zendesk Inc, Comcast corporation etc.

--

--