0
0
Rest APIprogramming~5 mins

Query parameters for filtering in Rest API - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What are query parameters in a REST API?
Query parameters are key-value pairs added to the end of a URL to send extra information to the server, often used to filter or sort data.
Click to reveal answer
beginner
How do you add multiple filters using query parameters?
You add multiple filters by separating each key-value pair with an ampersand (&) in the URL, like ?color=red&size=medium.
Click to reveal answer
beginner
Example: What does this URL filter? <br>/products?category=books&price_lt=20
It filters products to show only those in the 'books' category with a price less than 20.
Click to reveal answer
intermediate
Why use query parameters for filtering instead of sending data in the request body?
Query parameters are part of the URL and are ideal for GET requests to retrieve filtered data without changing server state, while request bodies are used for POST or PUT requests.
Click to reveal answer
intermediate
What is a common naming convention for query parameters used to filter by comparison (e.g., less than, greater than)?
Common conventions add suffixes like _lt (less than), _gt (greater than), _lte (less than or equal to), _gte (greater than or equal to) to the parameter name.
Click to reveal answer
Which symbol starts query parameters in a URL?
A?
B&
C#
D/
How do you separate multiple query parameters?
A&
B;
C?
D:
What HTTP method usually uses query parameters for filtering?
APOST
BGET
CPUT
DDELETE
What does the query parameter price_gte=10 mean?
APrice is less than 10
BPrice equals 10
CPrice is greater than or equal to 10
DPrice is not 10
Which URL filters products by color red and size medium?
A/products?color:red;size:medium
B/products/color/red/size/medium
C/products?red&medium
D/products?color=red&size=medium
Explain how query parameters are used to filter data in a REST API.
Think about how URLs change when you want to see only certain items.
You got /5 concepts.
    Describe common naming conventions for query parameters that filter by comparison operators.
    Suffixes help specify how to compare values.
    You got /5 concepts.