0
0
HLDsystem_design~10 mins

REST API best practices in HLD - Interactive Code Practice

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

Complete the code to specify the HTTP method used to retrieve data in a REST API.

HLD
Use the [1] method to fetch resources in REST APIs.
Drag options to blanks, or click blank then click option'
APUT
BPOST
CDELETE
DGET
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST instead of GET to retrieve data.
Confusing GET with DELETE or PUT methods.
2fill in blank
medium

Complete the code to indicate the recommended format for REST API responses.

HLD
REST APIs should return data in [1] format for easy parsing.
Drag options to blanks, or click blank then click option'
AXML
BJSON
CHTML
DCSV
Attempts:
3 left
💡 Hint
Common Mistakes
Using XML which is more verbose and less preferred.
Returning HTML which is for web pages, not API data.
3fill in blank
hard

Fix the error in the REST API URL design to follow best practices.

HLD
The URL to get a user by ID should be '/api/users/[1]' instead of '/api/getUser?id=[1]'.
Drag options to blanks, or click blank then click option'
AuserId
B{id}
C:id
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using query parameters instead of path parameters for resource IDs.
Using curly braces '{}' which are not standard in URLs.
4fill in blank
hard

Fill both blanks to correctly implement pagination parameters in a REST API endpoint.

HLD
GET /api/items?[1]=10&[2]=2
Drag options to blanks, or click blank then click option'
Alimit
Boffset
Cpage
Dsize
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing 'offset' with 'page' parameters.
Using 'size' instead of 'limit' which is less common.
5fill in blank
hard

Fill all three blanks to correctly set HTTP status codes for REST API responses.

HLD
Return status [1] for a successful GET, [2] when a resource is created, and [3] when a resource is not found.
Drag options to blanks, or click blank then click option'
A200
B201
C404
D500
Attempts:
3 left
💡 Hint
Common Mistakes
Using 500 for client errors instead of server errors.
Mixing up 404 and 400 status codes.