Bird
Raised Fist0
Rest APIprogramming~5 mins

Search parameter in Rest API - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What is a search parameter in a REST API?
A search parameter is a key-value pair sent in the URL query string to filter or find specific data from the server.
Click to reveal answer
beginner
How do you include a search parameter in a REST API request URL?
You add it after a question mark (?) in the URL, like ?key=value. Multiple parameters are separated by an ampersand (&).
Click to reveal answer
beginner
Example: What does this URL do?
https://api.example.com/users?age=25
It asks the server to return users who are 25 years old by using the search parameter age=25.
Click to reveal answer
beginner
Why are search parameters useful in REST APIs?
They let you get only the data you want, making responses smaller and faster, like searching for a book by title instead of getting all books.
Click to reveal answer
beginner
Can you use multiple search parameters in one REST API request?
Yes, you can combine them using &. For example, ?age=25&city=London finds users aged 25 who live in London.
Click to reveal answer
What symbol starts the search parameters in a REST API URL?
A?
B&
C#
D/
How do you separate multiple search parameters in a URL?
A&
B?
C;
D:
What does this search parameter do? ?status=active
ADeletes active items
BFilters results to only active items
CSorts items by active status
DReturns all items
Which part of the URL contains search parameters?
APath
BFragment
CQuery string
DProtocol
Why use search parameters in REST API calls?
ATo speed up the internet connection
BTo change the server's database
CTo encrypt the data
DTo filter data and get only what you need
Explain what a search parameter is and how it is used in REST API requests.
Think about how you ask for specific data from a server.
You got /3 concepts.
    Describe how multiple search parameters can be combined in a REST API URL and why this is helpful.
    Imagine searching for users by age and city at the same time.
    You got /3 concepts.

      Practice

      (1/5)
      1.

      What is the main purpose of a search parameter in a REST API URL?

      easy
      A. To change the API server address
      B. To filter the data returned by the API
      C. To add security to the API
      D. To format the API response as XML

      Solution

      1. Step 1: Understand what search parameters do

        Search parameters are added to the URL to specify what data you want from the API.
      2. Step 2: Identify the purpose of filtering

        Filtering means selecting only the data that matches your criteria, which is what search parameters do.
      3. Final Answer:

        To filter the data returned by the API -> Option B
      4. Quick Check:

        Search parameter = filter data [OK]
      Hint: Search parameters filter data in API URLs [OK]
      Common Mistakes:
      • Thinking search parameters change server address
      • Confusing search parameters with security tokens
      • Assuming search parameters format response
      2.

      Which of the following is the correct way to add a search parameter named name with value alice to a REST API URL?

      https://api.example.com/users
      easy
      A. https://api.example.com/users#name=alice
      B. https://api.example.com/users/name=alice
      C. https://api.example.com/users?name=alice
      D. https://api.example.com/users&name=alice

      Solution

      1. Step 1: Recall the syntax for search parameters

        Search parameters start with a question mark (?) after the base URL.
      2. Step 2: Check the correct separator and format

        The parameter is added as ?name=alice. Using & or # or slashes is incorrect here.
      3. Final Answer:

        https://api.example.com/users?name=alice -> Option C
      4. Quick Check:

        Use ? before first parameter [OK]
      Hint: First parameter starts with ? in URL [OK]
      Common Mistakes:
      • Using & instead of ? for first parameter
      • Using # which is for anchors, not parameters
      • Adding parameters as path segments
      3.

      What will be the full URL to search for users with age 30 and city as NY?

      Base URL: https://api.example.com/users
      medium
      A. https://api.example.com/users?age=30&city=NY
      B. https://api.example.com/users?age=30?city=NY
      C. https://api.example.com/users&age=30&city=NY
      D. https://api.example.com/users#age=30&city=NY

      Solution

      1. Step 1: Add first parameter with ?

        The first search parameter starts with a question mark: ?age=30.
      2. Step 2: Add second parameter with &

        Additional parameters use & to separate: &city=NY.
      3. Final Answer:

        https://api.example.com/users?age=30&city=NY -> Option A
      4. Quick Check:

        First ? then & for multiple parameters [OK]
      Hint: Use ? for first, & for others in URL [OK]
      Common Mistakes:
      • Using ? for every parameter
      • Using & before first parameter
      • Using # which is for anchors
      4.

      Identify the error in this URL with search parameters:

      https://api.example.com/products?category=books&price=20?sort=asc
      medium
      A. Using two question marks (?) for parameters
      B. Missing & between parameters
      C. Using = instead of : in parameters
      D. Parameters should be in the URL path, not query

      Solution

      1. Step 1: Check parameter separators

        Only the first parameter uses ?, others must use &.
      2. Step 2: Identify the error in the URL

        The URL incorrectly uses a second ? before sort=asc instead of &.
      3. Final Answer:

        Using two question marks (?) for parameters -> Option A
      4. Quick Check:

        Only one ? allowed, others use & [OK]
      Hint: Only one ? in URL, then & for others [OK]
      Common Mistakes:
      • Using multiple ? instead of &
      • Confusing = with : in parameters
      • Thinking parameters belong in URL path
      5.

      You want to search a REST API for books with author as John and year greater than 2010. Which URL correctly uses search parameters to do this?

      hard
      A. https://api.example.com/books?author=John&year>2010
      B. https://api.example.com/books?author=John&year=2010>
      C. https://api.example.com/books?author=John&year=gt2010
      D. https://api.example.com/books?author=John&year_gt=2010

      Solution

      1. Step 1: Understand how to express 'greater than' in search parameters

        REST APIs often use suffixes like _gt for 'greater than' in parameters.
      2. Step 2: Check each option for correct syntax

        https://api.example.com/books?author=John&year_gt=2010 uses year_gt=2010, which is a common and correct way to express this filter.
      3. Final Answer:

        https://api.example.com/books?author=John&year_gt=2010 -> Option D
      4. Quick Check:

        Use _gt suffix for greater than filters [OK]
      Hint: Use _gt suffix for 'greater than' in parameters [OK]
      Common Mistakes:
      • Using > directly in URL parameter
      • Placing operators after values
      • Confusing parameter syntax for filters
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard