0
0
Rest APIprogramming~10 mins

Rate limit headers (X-RateLimit) 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 the X-RateLimit-Limit header with a value of 100.

Rest API
response.headers['X-RateLimit-[1]'] = '100'
Drag options to blanks, or click blank then click option'
ALimit
BRemaining
CReset
DCount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Remaining' instead of 'Limit' will set the wrong header.
Using 'Reset' or 'Count' are not standard rate limit headers.
2fill in blank
medium

Complete the code to add the X-RateLimit-Remaining header with the remaining requests count.

Rest API
response.headers['X-RateLimit-[1]'] = str(remaining_requests)
Drag options to blanks, or click blank then click option'
ARemaining
BLimit
CReset
DCount
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Limit' will show the total allowed, not the remaining.
Using 'Reset' is for the time when the limit resets, not the count.
3fill in blank
hard

Fix the error in setting the X-RateLimit-Reset header with the reset time in seconds.

Rest API
response.headers['X-RateLimit-[1]'] = str(reset_time)
Drag options to blanks, or click blank then click option'
ARemaining
BCount
CLimit
DReset
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Limit' or 'Remaining' will not convey the reset time.
Using 'Count' is not a standard rate limit header.
4fill in blank
hard

Fill both blanks to set the X-RateLimit-Limit and X-RateLimit-Remaining headers correctly.

Rest API
response.headers['X-RateLimit-[1]'] = str(max_requests)
response.headers['X-RateLimit-[2]'] = str(remaining_requests)
Drag options to blanks, or click blank then click option'
ALimit
BRemaining
CReset
DCount
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the header names will cause incorrect rate limit info.
Using 'Reset' or 'Count' here is incorrect.
5fill in blank
hard

Fill all three blanks to set X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset headers properly.

Rest API
response.headers['X-RateLimit-[1]'] = str(max_requests)
response.headers['X-RateLimit-[2]'] = str(remaining_requests)
response.headers['X-RateLimit-[3]'] = str(reset_time)
Drag options to blanks, or click blank then click option'
ALimit
BRemaining
CReset
DCount
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the header names will confuse clients about their rate limits.
Using 'Count' is not a recognized rate limit header.