← Back to Chapters

Working with Query Parameters

? Working with Query Parameters

? Quick Overview

Query parameters are key–value pairs appended to a URL to send data to a server. In Postman, query parameters are commonly used to filter results, search data, paginate responses, and pass optional inputs without modifying the request body.

? Key Concepts

  • Query String – Part of the URL after ?
  • Key–Value Pairs – Written as key=value
  • Multiple Parameters – Separated using &
  • URL Encoding – Converts special characters into safe URL format
  • Optional Data – Query params are optional compared to path params

? Syntax / Theory

The general syntax of query parameters in a URL is:

? View Code Example
// Basic structure of query parameters in a URL
https://api.example.com/users?role=admin&status=active

? Code Example(s)

In Postman, query parameters can be added directly in the URL or using the Params tab.

? View Code Example
// URL with query parameters added manually
https://reqres.in/api/users?page=2&per_page=3

? Live Output / Explanation

Response Behavior

  • page=2 requests the second page of users
  • per_page=3 limits the number of records returned
  • The server processes these parameters and customizes the response

? Interactive Example / Visualization

Use the simulator below to build a URL dynamically, just like in the Postman "Params" tab.

⚡ Postman URL Builder

 
Full URL:
https://api.store.com/products

Think of query parameters as form inputs sent via URL:

  • ?search=postman → keyword filter
  • ?sort=asc → sorting order
  • ?limit=10 → maximum records

? URL Encoding Example

? View Code Example
// URL encoded query parameter with space and special character
https://api.example.com/search?query=web%20development%20%26%20api

? Use Cases

  • Filtering API results
  • Pagination and limits
  • Search functionality
  • Sorting data dynamically
  • Passing optional parameters

✅ Tips & Best Practices

  • Always URL-encode special characters
  • Use meaningful and readable parameter names
  • Avoid sending sensitive data via query parameters
  • Prefer Postman Params tab for clarity

? Try It Yourself

  • Send a GET request with multiple query parameters in Postman
  • Experiment with pagination using page and limit
  • Test URL encoding by adding spaces and symbols
  • Observe how the response changes based on parameters