Table of contents
No headings in the article.
Introduction
In this post, I will take you through a high-level walkthrough of the Amazon API gateway. I will have a future post on demos and hands-on teaching on creating our own API gateway, connecting it to a server, and serverless backends, and securing our API gateways by the implementation of best practices.
What is an API
An Application Programming Interface (API), acts as an entry point or a front door for applications to gain access to business logic, data, or functionalities from backend services. API design is usually seen as a client-server design, the app sending the request is seen as the client while the app sending the response is usually the server.
APIs are mechanisms that allow communication between software parts using set protocols and definitions. An example of such communication is a request to the weather bureau’s software system and the weather App on your phone to get the weather information of a place at a particular time, and you get a response to the request sent by seeing the weather information of the place requested on your app. The popular types of API integrations are websocket APIs and REST APIs.
What is REST?
REST stands for Representational state transfer and is meant to be an architectural reference for developing modern and user-friendly web services.
Instead of defining custom methods and protocols such as SOAP or WSDL, REST is based on HTTP as the transport protocol. HTTP is used to exchange textual representations of web resources across different systems, using predefined methods such as GET, POST, PUT, PATCH, DELETE, etc. JSON is its standard representation format.
Amazon API Gateway
Amazon API Gateway is a fully managed service that increases the flexibility for developers to create, publish, maintain, monitor, and secure APIs at any scale. API Gateway securely handles every task involved in accepting and processing up to hundreds of thousands of concurrent API calls, including access control, traffic management, CORS support, authorization, monitoring, throttling, and API version management.
Amazon API Gateway creates RESTful APIs that are HTTP based, enable stateless client-server communication, and use standard HTTP methods such as GET, POST, PUT, PATCH, and DELETE. It also creates Websocket APIs that Adhere to the WebSocket protocol, which enables stateful, full-duplex communication between client and server, and also routes incoming messages based on message content.
Amazon API Gateway enables you to design and build RESTful interfaces and helps connect them to your application backend. With API Gateway You can have the flexibility of designing your personal resource structure, adding dynamic routing parameters, and developing custom authorization logic. Each API resource can be configured independently, while each stage can have specific cache, throttling, and logging configurations.
API Gateway is a serverless service, which means you don't have to bother about provisioning the underlining resources. AWS provisions all the resources under the hood for you while you select all the implementation and configuration needed for your application. This helps to boost developers' productivity by ensuring that the focus is on building their code and not bothering about the underlining infrastructure.
Amazon API Gateway can integrate with various AWS services such as Lambda, AWS load balancer, AWS WAF, and Cloudfronts.
With Amazon API Gateway, you can define resources, map them to custom models, specify which methods are available (i.e. GET, POST, etc.), and eventually bind each method to a particular Lambda function. Alternatively, you can attach more than one method to one single Lambda function. This way, you will maintain fewer functions and partially avoid the cold-start Lambda issues.