Build an API Gateway REST API with HTTP Integration
Last Updated :
28 Mar, 2023
Pre-requisite: AWS
We can use either the HTTP proxy integration or the HTTP custom integration to build an API using HTTP integration. When feasible, leverage HTTP proxy integration for faster API setup while delivering varied and strong functionality. If it is essential to change client request data for the backend or backend response data for the client, HTTP custom integration might be appealing.
HTTP proxy integration is a simple, powerful, and adaptable way of creating an API that allows a web application to access numerous resources or features of the integrated HTTP endpoint, such as the full website, using a single API call. API Gateway sends the client-submitted method request to the backend via HTTP proxy integration. Request headers, query string parameters, URL path variables, and payload are all part of the request data that is passed through. The backend HTTP endpoint, often known as the web server, parses the incoming request data to determine the answer. Except for known limitations such as unsupported characters, which are noted in Amazon API Gateway's important notes, HTTP proxy integration allows the client and backend to connect directly with no interference from API Gateway when the API method is set up.
You can use an HTTP proxy integration to establish an API of a single API method using the all-encompassing proxy resource {proxy+} and the catch-all ANY verb for the HTTP method. The method exposes a website's whole collection of publicly available HTTP resources and actions. When the backend web server makes more resources available to the public, the client can use them using the same API configuration.
The following lesson serves as an overview of HTTP proxy integration. In this tutorial, we will construct an API using the API Gateway interface to interact with the PetStore website using a generic proxy resource {proxy+} and the HTTP method placeholder ANY.
Steps To Build an API with HTTP Proxy Integration with the PetStore Website through a Proxy Resource
Step 1: Access the API Gateway console by going AWS console.
Step 2: Choose Build from the REST API menu. Choose OK when the Create Example API box displays.
Step 3: Choose New API.
Step 4: Enter a name in the API Name.
Step 5: Add a brief description in the Description field if desired.
Step 6: Click Create API.
Step 7: Pick a parent resource item from the Resources tree and then choose to Create Resource from the Actions drop-down menu to create a child resource.
Step 8: To create a proxy resource, select the Configure as proxy resource option.
Step 9: Use the default name proxy in the Resource Name input text field.
Step 10: Use the default name /{proxy+} in the Resource Path input text field.
Step 11: Select Enable API Gateway CORS.
Step 12: Click Create Resource.
Step 13: Choose ANY from the HTTP method drop-down list, then click the check mark button to preserve your selection.
Step 14: Choose HTTP Proxy for Integration type.
Step 15: use http://petstore-demo-endpoint.execute-api.com/{proxy} for the Endpoint URL.
Step 16: Use default settings for other fields and click Save to finish configuring the ANY method.
The API's proxy resource path of {proxy+} becomes the placeholder of any of the backend endpoints under http://petstore-demo-endpoint.execute-api.com/ in the newly established API. For example, It can be a pet store, pet store/pets, or the pet store/pets/{petId}. At runtime, the ANY method acts as a placeholder for any of the available HTTP verbs.
Steps To Test an API with HTTP Proxy Integration
Step 1: In the Resources tree, choose ANY on a proxy resource.
Step 2: In the Method Execution window, select Test.
Step 3: Choose to GET from the Method drop-down list.
Step 4: In place of the proxy resource path ({proxy}), use pet store/pets for Path and type=fish for Query Strings.
Step 5: Leave other settings as it is.
Step 6: Click Test to test invoking the method.
Step 7: Because the backend website accepts the GET /pet store/pets?type=fish request, it returns the following successful response:
Step 8: If you attempt to call GET /pet store, you will receive a 404 response with the error message Cannot GET /pet store. This is because the provided operation is not supported by the backend. Because the PetStore website supports GET /pet store/pets/1, you will receive a 200 OK response with the following payload.
Similar Reads
Build an API Gateway REST API with Lambda Integration
Pre-requisite: AWS Amazon Web Services is a leading cloud provider which provides us with plenty of Paas, and Iaas, and services that we can use to build and deploy our applications. we going to build and Deploy a REST API with API Gateway which is integrated with AWS Lambda and expose GET and POST
4 min read
How to Build a REST API with Next.js 13?
Next.js is the most widely used React framework. Next.js 13.2 introduced a new file-based routing mechanism, called App Router, for building React frontend and serverless backend. In this article, we will be building a simple REST API using Next.js Route HandlersTable of ContentNext.js Route Handler
7 min read
Building a REST API with PHP and MySQL
This brief tutorial is a step-by-step guide on how to develop a REST API using PHP and MySQL. REST API will implement HTTP commands (Get, Post, Put, DELETE) and response will be in form of JSON. For development setup, we will be using the XAMPP while for testing of the API, we will use the Postman a
5 min read
Networking and API Integration in Android
Networking is a great way to connect your application with the world. Yes, before going straight into our topic, let's first try to find its necessity in your application. Networking is an essential aspect of modern applications, allowing them to connect with servers, databases, APIs, and other appl
9 min read
How to Build an API With Ruby on Rails?
Ruby on Rails API refers to the application programming interface (API) framework provided by the Ruby on Rails (Rails) web application framework. It allows developers to build and expose APIs for their web applications efficiently. Ruby on Rails is a popular web development framework written in the
4 min read
Amazon Web Service - Introduction to API Gateway
Firstly, API stands for Application Program Interface. An API Gateway is a management tool that acts as an interface between users and microservices. The Amazon API Gateway is an AWS service that allows users to create, publish, secure, maintain and monitor APIs at any scale. You can create APIs in
12 min read
Building RESTful APIs with FastAPI
FastAPI is a Python web framework that makes it easy to build APIs quickly and efficiently. There is Another famous framework for doing the same is Flask, which is also Python-based. In this article, we will focus on creating a RESTful API using FastAPI. In this article, we will learn how to create
5 min read
Securing Spring Boot API With API Key and Secret
In Web applications, securing the APIs is critical. One of the common methods of securing the APIs is by using API keys and secrets. This ensures that only the authorized clients can access the API endpoints. This article can guide you through the process of securing the Spring Boot API using the AP
6 min read
How to Build a RESTful API with Spring Boot and Spring MVC?
RESTful APIs have become the standard for building scalable and maintainable web services in web development. REST (Representational State Transfer) enables a stateless, client-server architecture where resources are accessed via standard HTTP methods. This article demonstrates how to create a RESTf
7 min read
Testing REST API with Postman and curl
In the world of API testing, there are many tools available. Postman and cURL are two of the most popular tools for it. Let's look at how to use these tools for testing them. We will send some HTTP requests and explore the basic syntax for both of them in this article. The article focuses on using a
7 min read