Skip to content
BENIBIX Learn

Query Parameter

Infrastructure🌐 NetworkingRequests and Responses

Also known as Query String, URL Parameter, Query Params

A name and value added after a ? in a web address, like ?page=2.

Think of it like

Think of it like the extra notes on an order. Size large, no onions.

Example

Jack filters a shop by colour. The address becomes /shoes?colour=red&size=9, and the server sends back only red shoes in size 9.

Why it matters

They turn a page you filtered or searched into an address. You can share it, save it and load it again.

Definition

A query parameter is a name and a value added to the end of a web address. It comes after a question mark. In /search?q=shoes&page=2, q and page are query parameters. Each pair is joined with an equals sign, and pairs are split by an ampersand. They are used to search, filter, sort and pick a page. Anyone can see them, so they must never hold secrets.

Example code

url
https://example.com/search?q=shoes&page=2
Two query parameters: q is shoes and page is 2.

Common mistake

Forgetting to encode spaces and symbols. A search for rock & roll breaks unless the & is written as %26.

Key takeaways

  1. 1
    After the question mark. At the end of the address.
  2. 2
    Name equals value. Split by &.
  3. 3
    Public. Never put secrets there.

Compare

Learn it properly