Developing an HTTP API in API Gateway - Amazon API Gateway
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Developing an HTTP API 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.

Creating 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 Amazon 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 Getting started with API Gateway.

Create an HTTP API by using the Amazon Web Services Management Console

  1. Open the API Gateway console.

  2. Choose Create API.

  3. Under HTTP API, choose Build.

  4. Choose Add integration, and then choose an Amazon Lambda function or enter an HTTP endpoint.

  5. For Name, enter a name for your API.

  6. Choose Review and create.

  7. 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-west-2.amazonaws.com

Create an HTTP API by using the Amazon 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 Amazon Lambda Permissions in the Amazon Lambda Developer Guide.

aws apigatewayv2 create-api --name my-api --protocol-type HTTP --target arn:aws:lambda:us-west-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-west-2.amazonaws.com