

# API Gateway에서 REST API 개발
<a name="rest-api-develop"></a>

 Amazon API Gateway에서 Amazon API Gateway [리소스](https://docs.aws.amazon.com/apigateway/latest/api/API_Resource.html)로 알려진 프로그래밍 가능 엔터티 모음으로 REST API를 구축합니다. 예를 들어 [RestApi](https://docs.aws.amazon.com/apigateway/latest/api/API_RestApi.html) 리소스를 사용하여 [Resource](https://docs.aws.amazon.com/apigateway/latest/api/API_Resource.html) 엔터티 모음을 포함할 수 있는 API를 나타냅니다.

각 `Resource` 엔터티마다 [Method](https://docs.aws.amazon.com/apigateway/latest/api/API_Method.html) 리소스가 하나 이상 있을 수 있습니다. `Method`는 클라이언트가 제출한 수신 요청이며 경로 파라미터, 헤더 또는 쿼리 문자열 파라미터와 같은 요청 파라미터를 포함할 수 있습니다. 또한 HTTP 메서드에 따라 요청에 본문이 포함될 수 있습니다. 메서드는 클라이언트가 노출된 `Resource`에 액세스하는 방법을 정의합니다. `Method`를 통합 엔드포인트라고도 하는 백엔드 엔드포인트에 통합하려면 [Integration](https://docs.aws.amazon.com/apigateway/latest/api/API_Integration.html) 리소스를 생성합니다. 그러면 수신 요청이 지정된 통합 엔드포인트 URI로 전달됩니다. 필요한 경우 백엔드 요구 사항을 충족하도록 요청 파라미터 또는 요청 본문을 변환하거나 프록시 통합을 만들 수 있습니다. 여기서 API Gateway는 전체 요청을 표준화된 형식으로 통합 엔드포인트 URI에 전송한 다음 클라이언트에 직접 응답을 전송합니다.

응답에 대해 [MethodResponse](https://docs.aws.amazon.com/apigateway/latest/api/API_MethodResponse.html) 리소스를 만들어 클라이언트가 수신하는 응답을 표시하고 [IntegrationResponse](https://docs.aws.amazon.com/apigateway/latest/api/API_IntegrationResponse.html) 리소스를 만들어 백엔드에서 반환되는 응답을 표시할 수 있습니다. 통합 응답을 사용하여 클라이언트에 데이터를 반환하기 전에 백엔드 응답 데이터를 변환하거나 클라이언트에 백엔드 응답을 있는 그대로 전달할 수 있습니다.

## REST API에 대한 리소스 예제
<a name="rest-api-develop-example"></a>

다음 다이어그램은 API Gateway가 HTTP 프록시에 대해 이 요청/응답 모델을 구현하고 `GET /pets` 리소스에 대해 HTTP 비프록시 통합을 구현하는 방법을 보여줍니다. 클라이언트는 `x-version:beta` 헤더를 API Gateway로 전송하고 API Gateway는 `204` 상태 코드를 클라이언트로 전송합니다.

비프록시 통합에서 API Gateway는 통합 요청 및 통합 응답을 수정하여 백엔드 요구 사항을 충족하기 위해 데이터 변환을 수행합니다. 비프록시 통합에서는 메서드 요청의 본문에 액세스할 수 있지만 통합 요청에서는 변환할 수 있습니다. 통합 엔드포인트가 본문과 함께 응답을 반환하면 통합 응답에서 응답에 액세스하고 이를 변환합니다. 메서드 응답에서 본문을 수정할 수 없습니다.

프록시 통합에서 통합 엔드포인트는 요청 및 응답을 수정합니다. API Gateway는 통합 요청 또는 통합 응답을 수정하지 않고 수신 요청을 백엔드로 있는 그대로 보냅니다.

통합 유형에 관계없이 클라이언트는 API Gateway에 요청을 전송했으며 API Gateway는 동기식으로 응답했습니다.

------
#### [ Non-proxy integration ]

![API Gateway 비프록시 통합 다이어그램](http://docs.aws.amazon.com/ko_kr/apigateway/latest/developerguide/images/develop-non-proxy.png)


------
#### [ Proxy integration ]

![API Gateway 프록시 통합 다이어그램](http://docs.aws.amazon.com/ko_kr/apigateway/latest/developerguide/images/develop-proxy.png)


------

다음 예제 실행 로그는 이전 예제에서 로깅할 API Gateway를 보여줍니다. 명확성을 위해 일부 값과 초기 로그가 제거되었습니다.

------
#### [ Non-proxy integration ]

```
Wed Feb 12 23:56:44 UTC 2025 : Starting execution for request: abcd-1234-5678
Wed Feb 12 23:56:44 UTC 2025 : HTTP Method: GET, Resource Path: /pets
Wed Feb 12 23:56:44 UTC 2025 : Method request path: {}
Wed Feb 12 23:56:44 UTC 2025 : Method request query string: {}
Wed Feb 12 23:56:44 UTC 2025 : Method request headers: {x-version=beta}
Wed Feb 12 23:56:44 UTC 2025 : Method request body before transformations: 
Wed Feb 12 23:56:44 UTC 2025 : Endpoint request URI: http://petstore-demo-endpoint.execute-api.com/petstore/pets
Wed Feb 12 23:56:44 UTC 2025 : Endpoint request headers: {app-version=beta}
Wed Feb 12 23:56:44 UTC 2025 : Endpoint request body after transformations: 
Wed Feb 12 23:56:44 UTC 2025 : Sending request to http://petstore-demo-endpoint.execute-api.com/petstore/pets
Wed Feb 12 23:56:45 UTC 2025 : Received response. Status: 200, Integration latency: 123 ms
Wed Feb 12 23:56:45 UTC 2025 : Endpoint response headers: {Date=Wed, 12 Feb 2025 23:56:45 GMT}
Wed Feb 12 23:56:45 UTC 2025 : Endpoint response body before transformations:
Wed Feb 12 23:56:45 UTC 2025 : Method response body after transformations: (null)
Wed Feb 12 23:56:45 UTC 2025 : Method response headers: {X-Amzn-Trace-Id=Root=1-abcd-12345}
Wed Feb 12 23:56:45 UTC 2025 : Successfully completed execution
Wed Feb 12 23:56:45 UTC 2025 : Method completed with status: 204
```

------
#### [ Proxy integration ]

```
Wed Feb 12 23:59:42 UTC 2025 : Starting execution for request: abcd-1234-5678
Wed Feb 12 23:59:42 UTC 2025 : HTTP Method: GET, Resource Path: /pets
Wed Feb 12 23:59:42 UTC 2025 : Method request path: {}
Wed Feb 12 23:59:42 UTC 2025 : Method request query string: {}
Wed Feb 12 23:59:42 UTC 2025 : Method request headers: {x-version=beta}
Wed Feb 12 23:59:42 UTC 2025 : Method request body before transformations: 
Wed Feb 12 23:59:42 UTC 2025 : Endpoint request URI: http://petstore-demo-endpoint.execute-api.com/petstore/pets
Wed Feb 12 23:59:42 UTC 2025 : Endpoint request headers: { x-version=beta}
Wed Feb 12 23:59:42 UTC 2025 : Endpoint request body after transformations: 
Wed Feb 12 23:59:42 UTC 2025 : Sending request to http://petstore-demo-endpoint.execute-api.com/petstore/pets
Wed Feb 12 23:59:43 UTC 2025 : Received response. Status: 204, Integration latency: 123 ms
Wed Feb 12 23:59:43 UTC 2025 : Endpoint response headers: {Date=Wed, 12 Feb 2025 23:59:43 GMT}
Wed Feb 12 23:59:43 UTC 2025 : Endpoint response body before transformations: 
Wed Feb 12 23:59:43 UTC 2025 : Method response body after transformations:
Wed Feb 12 23:59:43 UTC 2025 : Method response headers: {Date=Wed, 12 Feb 2025 23:59:43 GMT}
Wed Feb 12 23:59:43 UTC 2025 : Successfully completed execution
Wed Feb 12 23:59:43 UTC 2025 : Method completed with status: 204
```

------

유사한 API를 가져와서 AWS Management Console에서 테스트하려면 [예제 API](api-gateway-create-api-from-example.md)를 참조하시기 바랍니다.

## 개발용 추가 REST API 기능
<a name="rest-api-develop-details"></a>

API Gateway는 REST API 개발을 위한 추가 기능을 지원합니다. 예를 들어 고객이 API를 이해하는 데 도움이 되도록 API에 대한 설명서를 제공할 수 있습니다. 이를 활성화하려면 지원되는 API 엔터티에 대한 [DocumentationPart](https://docs.aws.amazon.com/apigateway/latest/api/API_DocumentationPart.html) 리소스를 추가하세요.

클라이언트가 API를 호출하는 방법을 제어하려면 [IAM 권한](permissions.md), [Lambda 권한 부여자](apigateway-use-lambda-authorizer.md), 또는 [Amazon Cognito 사용자 풀](apigateway-integrate-with-cognito.md)을 사용합니다. API 사용을 측정하려면 API 요청을 조절하도록 [사용량 계획](api-gateway-api-usage-plans.md)을 설정하세요. API를 생성 또는 업데이트할 때 이를 활성화할 수 있습니다.

다음 다이어그램은 REST API 개발에 사용할 수 있는 기능과 요청/응답 모델에서 이러한 기능이 구성된 위치를 보여줍니다.

![API Gateway 기능 다이어그램](http://docs.aws.amazon.com/ko_kr/apigateway/latest/developerguide/images/develop-features.png)


API를 생성하는 방법 소개는 [자습서: Lambda 프록시 통합을 통해 REST API 생성](api-gateway-create-api-as-simple-proxy-for-lambda.md) 섹션을 참조하세요. REST API를 개발하는 동안 사용할 수 있는 API Gateway의 기능에 대한 자세한 내용은 다음 주제를 참조하세요. 이러한 주제에는 개념 정보와 API Gateway 콘솔, API Gateway REST API, AWS CLI 또는 AWS SDK 중 하나를 사용하여 수행할 수 있는 절차가 포함되어 있습니다.

**Topics**
+ [REST API에 대한 리소스 예제](#rest-api-develop-example)
+ [개발용 추가 REST API 기능](#rest-api-develop-details)
+ [API Gateway의 REST API에 대한 API 엔드포인트 유형](api-gateway-api-endpoint-types.md)
+ [API Gateway의 REST API 보안 정책](apigateway-security-policies.md)
+ [API Gateway의 REST API에 대한 IP 주소 유형](api-gateway-ip-address-type.md)
+ [API Gateway의 REST API 메서드](how-to-method-settings.md)
+ [API Gateway에서 REST API에 대한 액세스 제어 및 관리](apigateway-control-access-to-api.md)
+ [API Gateway에서 REST API 통합](how-to-integration-settings.md)
+ [API Gateway의 REST API API 검증 요청](api-gateway-method-request-validation.md)
+ [API Gateway에서 REST API의 데이터 변환](rest-api-data-transformations.md)
+ [API Gateway의 REST API에 대한 게이트웨이 응답](api-gateway-gatewayResponse-definition.md)
+ [API Gateway의 REST API CORS](how-to-cors.md)
+ [API Gateway의 REST API에 대한 이진 미디어 유형](api-gateway-payload-encodings.md)
+ [API Gateway에서 REST API 간접 호출](how-to-call-api.md)
+ [API Gateway에서 OpenAPI를 사용하여 REST API 개발](api-gateway-import-api.md)