

# 在 REST API 和 HTTP API 之间进行选择
<a name="http-api-vs-rest"></a>

REST API 和 HTTP API 都是 RESTful API 产品。REST API 支持的功能比 HTTP API 多，而 HTTP API 在设计时功能就极少，因此能够以更低的价格提供。如果您需要如 API 密钥、每客户端节流、请求验证、AWS WAF 集成或私有 API 端点等功能，请选择 REST API。如果您不需要 REST API 中包含的功能，请选择 HTTP API。

以下各节汇总了 REST API 和 HTTP API 中可用的核心功能。必要时，还会提供其他链接，以便于在《API Gateway 开发人员指南》的 REST API 部分与 HTTP API 部分之间导航。

## 端点类型
<a name="http-api-vs-rest.differences.endpoint-type"></a>

端点类型是指 API Gateway 为 API 创建的端点。有关更多信息，请参阅 [API Gateway 中针对 REST API 的 API 端点类型](api-gateway-api-endpoint-types.md)。


| 端点类型 | REST API | HTTP API | 
| --- | --- | --- | 
|  [边缘优化](api-gateway-api-endpoint-types.md#api-gateway-api-endpoint-types-edge-optimized)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [区域性](api-gateway-api-endpoint-types.md#api-gateway-api-endpoint-types-regional)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | 
|  [ Private](api-gateway-api-endpoint-types.md#api-gateway-api-endpoint-types-private)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 

## 安全性
<a name="http-api-vs-rest.differences.security"></a>

API Gateway 提供了多种方法来保护您的 API 免受某些威胁危害，例如恶意行为者或流量高峰。要了解更多信息，请参阅 [保护 API Gateway 中的 REST API](rest-api-protect.md) 和 [保护 API Gateway 中的 HTTP API](http-api-protect.md)。


| 安全功能 | REST API | HTTP API | 
| --- | --- | --- | 
|  [双向 TLS 身份验证](rest-api-mutual-tls.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](rest-api-mutual-tls.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-mutual-tls.md)  | 
|  [用于后端身份验证的证书](getting-started-client-side-ssl-authentication.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [AWS WAF](apigateway-control-access-aws-waf.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 

## 授权
<a name="http-api-vs-rest.differences.authorization"></a>

API Gateway 支持多种用于控制和管理对 API 的访问的机制：有关更多信息，请参阅[在 API Gateway 中控制和管理对 REST API 的访问](apigateway-control-access-to-api.md) 和[控制和管理对 API Gateway 中的 HTTP API 的访问](http-api-access-control.md)。


| 授权选项 | REST API | HTTP API | 
| --- | --- | --- | 
|  [（IAM](permissions.md)）  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](permissions.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-access-control-iam.md)  | 
|  [资源策略](apigateway-resource-policies.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持   | 
|  [Amazon Cognito](apigateway-integrate-with-cognito.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是 1  | 
|  [使用 AWS Lambda 函数的自定义授权](apigateway-use-lambda-authorizer.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](apigateway-use-lambda-authorizer.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-lambda-authorizer.md)  | 
|  [JSON Web 令牌 (JWT)](http-api-jwt-authorizer.md) 2  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg)否  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | 

1 您可以将 Amazon Cognito 与 [JWT 授权方](http-api-jwt-authorizer.md)结合使用。

2 您可以使用 [Lambda 授权方](apigateway-use-lambda-authorizer.md)以验证适用于 REST API 的 JWT。

## API 管理
<a name="http-api-vs-rest.differences.management"></a>

如果您需要 API 管理功能（例如 API 密钥和每客户端费率限制），请选择 REST API。有关更多信息，请参阅 [在 API Gateway 中向客户端分配 REST API](rest-api-distribute.md)、[API Gateway 中公共 REST API 的自定义域名](how-to-custom-domains.md) 和 [API Gateway 中的 HTTP API 的自定义域名](http-api-custom-domain-names.md)。


| 功能 | REST API | HTTP API | 
| --- | --- | --- | 
|  [自定义域](how-to-custom-domains.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](how-to-custom-domains.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-custom-domain-names.md)  | 
|  [API 密钥](api-gateway-api-usage-plans.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [每客户端费率限制](api-gateway-request-throttling.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [每客户端使用量节流](api-gateway-api-usage-plans.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [开发人员门户](apigateway-portals.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 

## 开发
<a name="http-api-vs-rest.differences.development"></a>

在开发 API Gateway API 时，您可以决定 API 的许多特征。这些特征取决于 API 的使用案例。有关更多信息，请参阅[开发 API Gateway 中的 REST API](rest-api-develop.md)和[开发 API Gateway 中的 HTTP API](http-api-develop.md)。


| 功能 | REST API | HTTP API | 
| --- | --- | --- | 
|  [CORS 配置](how-to-cors.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](how-to-cors.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-cors.md)  | 
|  [测试调用](how-to-test-method.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [缓存](api-gateway-caching.md)：  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [用户控制的部署](how-to-deploy-api.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](how-to-deploy-api.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-stages.md)  | 
|  [自动部署](http-api-stages.md)  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg)否  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | 
|  [自定义网关响应](api-gateway-gatewayResponse-definition.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [Canary 版本部署](canary-release.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [请求验证](api-gateway-method-request-validation.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [请求参数转换](rest-api-data-transformations.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](rest-api-data-transformations.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-parameter-mapping.md)  | 
|  [请求正文转换](rest-api-data-transformations.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 

## 监控
<a name="http-api-vs-rest.differences.monitoring"></a>

API Gateway 支持多种选项来记录 API 请求和监控 API。有关更多信息，请参阅[监控 API Gateway 中的 REST API](rest-api-monitor.md)和[监控 API Gateway 中的 HTTP API](http-api-monitor.md)。


| 功能 | REST API | HTTP API | 
| --- | --- | --- | 
|  [Amazon CloudWatch 指标](monitoring-cloudwatch.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](monitoring-cloudwatch.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-metrics.md)  | 
|  [访问 CloudWatch Logs 的日志](set-up-logging.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](set-up-logging.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-logging.md)  | 
|  [访问 Amazon Data Firehose 的日志](apigateway-logging-to-kinesis.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [执行日志](set-up-logging.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [AWS X-Ray 跟踪](apigateway-xray.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 

## 集成
<a name="http-api-vs-rest.differences.integrations"></a>

集成将 API Gateway API 连接到后端资源。有关更多信息，请参阅[针对 API Gateway 中的 REST API 的集成](how-to-integration-settings.md)和[针对 API Gateway 中的 HTTP API 创建集成](http-api-develop-integrations.md)。


| 功能 | REST API | HTTP API | 
| --- | --- | --- | 
|  [公有 HTTP 端点](setup-http-integrations.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](setup-http-integrations.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-develop-integrations-http.md)  | 
|  [AWS 服务](api-gateway-api-integration-types.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](api-gateway-api-integration-types.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-develop-integrations-aws-services.md)  | 
|  [AWS Lambda 函数](set-up-lambda-integrations.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](set-up-lambda-integrations.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-develop-integrations-lambda.md)  | 
|  [与网络负载均衡器的私有集成](set-up-private-integration.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](set-up-private-integration.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](http-api-develop-integrations-private.md)  | 
|  [与应用程序负载均衡器的私有集成](http-api-develop-integrations-private.md)  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) [是](set-up-private-integration.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | 
|  [与 AWS Cloud Map 的私有集成](http-api-develop-integrations-private.md)  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg)否   |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | 
|  [模拟集成](how-to-mock-integration.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 
|  [响应流式处理](response-transfer-mode.md)  |  ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/success_icon.svg) 是  | ![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/apigateway/latest/developerguide/images/negative_icon.svg) 不支持  | 