In this blog post series we’ll take a closer look at Amazon web services (AWS) and all their Serverless related services in detail.
Today we look at API Gateway. What is it and how does the Serverless framework use it?
This chapter is a free sample taken from our “Learn Serverless” book.
API Gateway is another great service available through AWS. Nearly everyone who has developed an application before was confronted with the task to define an API.
Aside: What is an API?
An API (application programming interface) is a service you’ll develop so that other users / applications can access certain data of your application. Imagine that you’ve developed the next social network and you want to enable other developers to use the data of your network to build cool new applications around them.
How API Gateway helps you
But as soon as you’ve started to develop your API you’ll maybe encountered hurdles. What about versioning? Should it be RESTful? How do I implement a RESTful API? How do I handle different stages (development, testing, production)?
API Gateway is Amazons answer to target those pain points. It makes it easy to version APIs, monitor events (like usage of a certain API method), scale the API independently, roll out APIs for different stages and create RESTful services.
How Serverless uses the API Gateway
The Serverless framework uses API Gateway to help you setup routes to your Lambda functions. You can e.g. perform a GET request and fetch all related data which is then available in your related Lambda function. The API Gateway is the trigger which causes your Lambda function to run.