Develop HTTP APIs in API Gateway
This section provides details about API Gateway capabilities that you need while you're developing your API Gateway APIs.
As you're developing your API Gateway API, you decide on a number of characteristics of your API. These characteristics depend on the use case of your API. For example, you might want to only allow certain clients to call your API, or you might want it to be available to everyone. You might want an API call to execute a Lambda function, make a database query, or call an application.
Topics
- Create an HTTP API
- Create routes for HTTP APIs in API Gateway
- Control and manage access to HTTP APIs in API Gateway
- Create integrations for HTTP APIs in API Gateway
- Configure CORS for HTTP APIs in API Gateway
- Transform API requests and responses for HTTP APIs in API Gateway
- Use OpenAPI definitions for HTTP APIs in API Gateway
Create an HTTP API
To create a functional API, you must have at least one route, integration, stage, and deployment.
The following examples show how to create an API with an AWS Lambda or HTTP integration, a route, and a default stage that is configured to automatically deploy changes.
This guide assumes that you're already familiar with API Gateway and Lambda. For a more detailed guide, seeĀ Get started with API Gateway.
Create an HTTP API by using the AWS Management Console
-
Open the API Gateway console
. -
Choose Create API.
-
Under HTTP API, choose Build.
-
Choose Add integration, and then choose an AWS Lambda function or enter an HTTP endpoint.
-
For Name, enter a name for your API.
-
Choose Review and create.
-
Choose Create.
Now your API is ready to invoke. You can test your API by entering its invoke URL in a browser, or by using Curl.
curl https://
api-id
.execute-api.us-east-2
.amazonaws.com
Create an HTTP API by using the AWS CLI
You can use quick create to create an API with a Lambda or HTTP integration, a default catch-all route, and a default stage that is configured to automatically deploy changes. The following command uses quick create to create an API that integrates with a Lambda function on the backend.
Note
To invoke a Lambda integration, API Gateway must have the required permissions. You can use a resource-based policy or an IAM role to grant API Gateway permissions to invoke a Lambda function. To learn more, see AWS Lambda Permissions in the AWS Lambda Developer Guide.
aws apigatewayv2 create-api --name
my-api
--protocol-type HTTP --target arn:aws:lambda:us-east-2
:123456789012
:function:function-name
Now your API is ready to invoke. You can test your API by entering its invoke URL in a browser, or by using Curl.
curl https://
api-id
.execute-api.us-east-2
.amazonaws.com