API & AWS API Gateway
What is an API?
An application programming interface (API) is a way for two or more Computer programs to communicate with each other. It is a type of software interface, that offers a service to other pieces of software
Much Simpler Analogy: Think of a waiter as a messenger(API) that takes your request or order and tells the kitchen(the system) what is ordered(requested). Then the waiter delivers the response(food).
Real-life API example. You may be familiar with the process of searching for flights online.
How does API work?
API architecture is usually explained in terms of client and server. The application sending the request is called the client, and the application sending the response is called the server. So in the weather example, the bureau’s weather database is the server, and the mobile app is the client.
Four different ways APIs can work depending on when/why they were created👇🏻
SOAP API: These APIs use the Simple Object Access Protocol. Client and server exchange messages using XML. This is a less flexible API that was more popular in the past.
REST APIs: These are the most popular and flexible APIs found on the web today. The client sends requests to the server as data. The server uses this client input to start internal functions and returns output data back to the client. Let’s look at REST APIs in more detail below.
RPC APIs: These APIs are called Remote Procedure Calls. The client completes a function (or procedure) on the server, and the server sends the output back to the client.
WebSocket APIs: It is another modern web API development that uses JSON objects to pass data. A WebSocket API supports two-way communication between client apps and the server. The server can send callback messages to connected clients, making it more efficient than REST API.
— — — — — — — — — — — — — — — — — — — — — — — — — — — — —
What is an API Gateway?
An API gateway is an API management tool that sits between a client and a collection of backend services. An API gateway acts as a reverse proxy to accept all API calls, aggregate the various services required to fulfill them and return the appropriate result.
Also, Amazon API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. APIs act as the “front door” for applications to access data, business logic, or functionality from your backend services.
- Using API Gateway, you can create RESTful APIs and WebSocket APIs that enable real-time two-way communication applications.
- API Gateway handles all the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls, including traffic management, CORS support, authorization and access control, throttling, monitoring, and API version management.
- API Gateway has no minimum fees or startup costs. You pay for the API calls you receive and the amount of data transferred out and, with the API Gateway tiered pricing model, you can reduce your cost as your API usage scales.
How does API Gateway work?
Benefits of using API Gateway
Efficient API development
Run multiple versions of the same API simultaneously with API Gateway, allowing you to quickly iterate, test, and release new versions.
Performance at any scale
Provide end-users with the lowest possible latency for API requests and responses by taking advantage of our global network of edge locations using Amazon CloudFront. Throttle traffic and authorize API calls to ensure that backend operations withstand traffic spikes and backend systems are not unnecessarily called.
Cost savings at scale
API Gateway provides a tiered pricing model for API requests. With an API Requests price as low as $0.90 per million requests at the highest tier, you can decrease your costs as your API usage increases per region across your AWS accounts.
Monitor performance metrics and information on API calls, data latency, and error rates from the API Gateway dashboard, which allows you to visually monitor calls to your services using Amazon CloudWatch.
Flexible security controls
Authorize access to your APIs with AWS Identity and Access Management (IAM) and Amazon Cognito. If you use OAuth tokens, API Gateway offers native OIDC and OAuth2 support. To support custom authorization requirements, you can execute a Lambda authorizer from AWS Lambda.
RESTful API options
Create RESTful APIs using HTTP APIs or REST APIs. HTTP APIs are the best way to build APIs for a majority of use cases — they’re up to 71% cheaper than REST APIs. If your use case requires API proxy functionality and management features in a single solution, you can use REST APIs.
Reference: AWS Website, Google.com