0
0
Rest APIprogramming~10 mins

Offset-based pagination 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 set the offset parameter for pagination.

Rest API
params = {"offset": [1], "limit": 10}
Drag options to blanks, or click blank then click option'
A20
B"offset"
Cstart
Dpage
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a number for offset.
Using variable names instead of numeric values.
2fill in blank
medium

Complete the code to calculate the offset for page 3 with 10 items per page.

Rest API
offset = ([1] - 1) * 10
Drag options to blanks, or click blank then click option'
Alimit
Bpage
Ccount
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using limit instead of page.
Using start or count which are not page numbers.
3fill in blank
hard

Fix the error in the code to correctly set offset and limit in the API request.

Rest API
response = requests.get(url, params={"offset": [1], "limit": 10})
Drag options to blanks, or click blank then click option'
Alimit
B"offset"
Cpage
Doffset
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the string "offset" instead of the variable offset.
Using page instead of offset.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps page numbers to their offset values for 5 pages.

Rest API
offsets = {page: (page [1] 1) [2] 10 for page in range(1, 6)}
Drag options to blanks, or click blank then click option'
A-
B+
C*
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using addition instead of subtraction.
Using division instead of multiplication.
5fill in blank
hard

Fill all three blanks to filter a list of items for the current page using offset and limit.

Rest API
page_items = items[[1]: [2] + [3]]
Drag options to blanks, or click blank then click option'
Aoffset
Blimit
Dpage
Attempts:
3 left
💡 Hint
Common Mistakes
Using page instead of offset for slicing.
Adding limit to page instead of offset.