Query Parameters

Understand how query parameters can be integrated into an API Gateway request.

What's a query parameter?

Consider the URL, https://example.com?arg1=val1&arg2=val2. Here, arg1 and arg2 are called query parameters. We need query parameter integration in two scenarios.

  • The URL invoking our API contains query parameters that should pass into the target API.

  • The URL of the target API requires some query parameters.

API Gateway enables either of them. When we integrate the requests, we can change the query parameters to get the required mapping.

Example

Let’s check out an example to see how this works. Agify.io has a free public API that can guess a person's age from the name. We can’t expect accurate results from such an API. However, we can use it to test our API integration. For example, GET https://api.agify.io?name=meelad gives us a JSON response {"name": "meelad", "age": 29, "count": 21}

Let’s create a new API with the API Gateway that integrates with this API.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy