0
0
Rest APIprogramming~10 mins

Search parameter in Rest API - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a search parameter to the API endpoint URL.

Rest API
url = "https://api.example.com/items?[1]=book"
Drag options to blanks, or click blank then click option'
Aquery
Bfilter
Csort
Dsearch
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'filter' or 'query' which may not be recognized by this API.
2fill in blank
medium

Complete the code to extract the search parameter value from the URL query string.

Rest API
search_term = request.args.get('[1]')
Drag options to blanks, or click blank then click option'
Asearch
Bfilter
Cquery
Dterm
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different parameter name that does not match the URL.
3fill in blank
hard

Fix the error in the code to correctly check if the search parameter exists.

Rest API
if '[1]' in request.args:
Drag options to blanks, or click blank then click option'
Aquery
Bterm
Csearch
Dfilter
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for wrong parameter names like 'term' or 'filter'.
4fill in blank
hard

Fill both blanks to build a URL with search and sort parameters.

Rest API
url = f"https://api.example.com/items?[1]=phone&[2]=asc"
Drag options to blanks, or click blank then click option'
Asearch
Bfilter
Csort
Dorder
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'filter' instead of 'search' or 'order' instead of 'sort'.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension filtering items by search term length and sorting by price.

Rest API
filtered = {item['name']: item['price'] for item in items if len(item['name']) [1] [2] and item['price'] [3] 100}
Drag options to blanks, or click blank then click option'
A>
B3
C<=
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators or values that don't filter correctly.