Introduction
AWS API Gateway Query Parameters are commonly used to pass additional information to an API request without modifying the request body. Understanding how AWS API Gateway Query Parameters work is essential when building REST APIs that require filtering, searching, validations, or user inputs.
In this tutorial, we’ll learn how to create and validate query parameters in AWS API Gateway, test them using the built-in API Gateway console, configure request validation, and understand how the request flows through different stages of API Gateway.
📚 AWS API Gateway Series
✔ Part 1: AWS API Gateway Integration with AWS Lambda Explained
➡ This Article: AWS API Gateway Query Parameters Explained
What Are Query Parameters in AWS API Gateway?
Query parameters are values passed in the URL after the question mark (?).
Example:
https://example.com/users?salary=5000
In this example:
salary is the query parameter and 5000 is its value.
Query parameters are widely used for:
- Searching records
- Filtering data
- Pagination
- User inputs
- API validations
Understanding the Request Flow
Before implementing query parameters, it’s important to understand how a request moves through API Gateway.
Client Request ↓ Method Request ↓ Integration Request ↓ Mock Integration ↓ Integration Response ↓ Method Response ↓ Client Response
This flow helps API Gateway validate, process, and return responses even without using AWS Lambda.
Creating a New AWS API Gateway Resource
Navigate to:
AWS Console → API Gateway
Open the API created in the previous tutorial.
Under the root resource:
/
Create a new resource.
Example:
getUserData
Once the resource is created, you’ll be ready to create methods and configure query parameters.
Creating a GET Method for AWS API Gateway Query Parameters
Click:
Create Method
Choose:
GET
For Integration Type select:
Mock
Unlike Lambda integration, a Mock integration allows you to test API functionality directly inside API Gateway without invoking any backend service.
This makes it perfect for learning and testing query parameter validations.
Configuring AWS API Gateway Query Parameters
Open:
Method Request
Click:
Edit
Validate body, query string parameters and headers
Now create a Query String Parameter:
salary
Mark it as:
Required = Yes
This means every request must include:
?salary=value
Otherwise API Gateway will reject the request.
Save the configuration.
Understanding AWS API Gateway Request Validation
Request validation helps ensure users send the required parameters before the request is processed.
For example:
?age=25
Since salary is missing, the request fails.
Expected Output:
Missing required parameter: salary
This prevents invalid requests from reaching your backend systems.
Configuring the Integration Request
Navigate to:
Integration Request
Because we selected Mock integration, keep:
Integration Type = Mock
Ensure:
Content-Type = application/json
No additional changes are required in this section.
Configuring Integration Response for AWS API Gateway Query Parameters
Open:
Integration Response
Edit the existing response mapping template.
Content Type:
application/json
Response Mapping Template:
{
"message": "Salary received successfully",
"submittedSalary": "$input.params('salary')"
}
This template reads the query parameter and returns it in the response.
Save the changes.
Configuring Method Responses
Open:
Method Response
Create two response codes:
Success Response
200
Validation Error Response
400
For Content Type use:
application/json
This allows API Gateway to return proper status codes based on the request result.
Testing AWS API Gateway Query Parameters
Click:
Test
Example 1: Missing Query Parameter
Request:
GET /getUserData?age=50
Response:
Missing required parameter: salary
Status Code:
400
Example 2: Valid Query Parameter
Request:
GET /getUserData?salary=5000
Response:
{
"message": "Salary received successfully",
"submittedSalary": "5000"
}
Status Code:
200
The validation is now working exactly as expected.
Why Use Mock Integrations?
Mock integrations are useful when:
✅ Testing API design
✅ Validating query parameters
✅ Learning API Gateway
✅ Returning sample responses
✅ Building prototypes
Since no Lambda function is involved, testing becomes much quicker.
Key Takeaways
Before implementing query parameters in AWS API Gateway, remember:
✅ Query parameters are passed through URLs
✅ Request Validators can enforce mandatory parameters
✅ Mock integrations eliminate backend dependencies
✅ Integration Responses can return dynamic values
✅ Method Responses handle status codes such as 200 and 400
✅ API Gateway can perform validation without Lambda
🎥 Watch the Complete Video Tutorial
Prefer learning visually?
Watch the complete hands-on walkthrough on YouTube:
Related Articles
- Understanding AWS IAM Policies with Real AWS Examples
- AWS MWAA Tutorial for Beginners: Create Your First MWAA Environment
- AWS API Gateway Tutorial Part 1: Integrating API Gateway with AWS Lambda
Further Reading
Final Thoughts
Learning AWS API Gateway Query Parameters is an important step toward building production-ready APIs. Query parameters help APIs accept dynamic user inputs while ensuring proper validation before requests reach backend services.
Using Mock Integrations provides a safe and efficient way to experiment with request validation, status codes, and response mappings without incurring Lambda execution costs.