Restful API design Flashcards

1
Q

What

A

Identify the Goal: What problem does the API solve? What resources will it manage?
Set Functionalities: List actions the API will support, like creating, reading, updating, or deleting resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Identify Resources

A

Resources represent the main entities in your API and are typically nouns.
Users
Orders
Products

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Use Resource URIs

A

Design resource URLs that are hierarchical, predictable, and meaningful.
Use nouns to represent resources.
Use plural for resource names (e.g., /users instead of /user).
/users – Get all users or create a new user.
/users/{id} – Access a specific user by ID.
/users/{id}/orders – Access orders for a specific user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Map to HTTP Methods

A

GET: Retrieve resources.
POST: Create new resources.
PUT: Update an existing resource (replace the whole).
PATCH: Partially update a resource.
DELETE: Remove a resource.

GET /users – Fetch all users.
POST /users – Create a new user.
PUT /users/{id} – Update user details.
DELETE /users/{id} – Delete a user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Versioning Handling

A

API versions ensure backward compatibility when introducing changes
GET /v1/users

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Error Codes

A

200 OK: Successful GET or PUT request.
201 Created: Resource successfully created.
204 No Content: Successful DELETE request.
400 Bad Request: Invalid input.
401 Unauthorized: Authentication failure.
404 Not Found: Resource not found.
500 Internal Server Error: Server failure.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly