RESTful Design Principles
This post is a definition of terms for RESTful design principles – including exam questions and tags.
In a Nutshell
REST is an architectural approach for APIs based on HTTP and distinguished by clearly defined methods, resources, status codes, and statelessness.
Compact Technical Description
REST is a lightweight, HTTP-based protocol for exchanging resources between client and server. It uses the HTTP methods: GET (read), POST (create), PUT (replace), DELETE (delete), PATCH (partial update). REST follows the principle of statelessness, which means that each request must contain all necessary information; the server stores no session data. Idempotency plays an important role: GET, PUT, and DELETE are idempotent (repeated execution has the same effect), POST and PATCH are not. REST uses standardized status codes (e.g. 200 OK, 201 Created, 404 Not Found, 500 Server Error) to communicate results.
Exam-Relevant Key Points
- GET, POST, PUT, DELETE, PATCH: HTTP methods for CRUD
- REST is stateless – no session tracking on server side
- Idempotency: Repeated requests have effect only once (e.g. with PUT)
- Resource-oriented URIs, e.g. /api/users/123
- Use of HTTP status codes (200, 201, 404, 500 etc.)
- PATCH updates only parts of an object
- Security aspects: Authentication via token, HTTPS, CORS
- Documentation of interfaces with OpenAPI or Swagger
Core Components
- HTTP methods (GET, POST, PUT, DELETE, PATCH)
- URI conventions (resource-based)
- Status codes (2xx, 4xx, 5xx)
- REST conformity (Richardson Maturity Model)
- Idempotency rules
- Stateless architecture
- Content negotiation (Accept/Content-Type headers)
- JSON/XML as data formats
- Authentication (Bearer Token, API Keys)
- OpenAPI/Swagger documentation
Practical Example
// Example: REST API for user management
GET /users → List all users
POST /users → Create new user
GET /users/1 → Display user with ID 1
PUT /users/1 → Replace user completely
PATCH /users/1 → Update only certain fields
DELETE /users/1 → Delete user
Explanation: Each method corresponds to a clearly defined action on a resource. The URI remains constant, the method changes the semantics.
Advantages and Disadvantages
Advantages
- Simple, easy to understand
- Uses standard protocols (HTTP)
- Platform and language independent
- Highly scalable
Disadvantages
- No built-in session management
- Can be inefficient with many API calls
- No standardization for complex operations
Typical Exam Questions (with Short Answer)
- “Stateless” in REST? Server stores no session data – each request must be complete.
- Idempotent HTTP methods? GET, PUT, DELETE.
- Difference between PUT and PATCH? PUT replaces an object completely, PATCH changes only certain fields.
- Status code 201? Resource successfully created.
- REST vs. SOAP? REST is lightweight, uses HTTP directly, SOAP is XML-based and heavyweight.
- Address resource? Via URI, e.g. /users/123.
- Security measures for REST APIs? HTTPS, token authentication, access control.
- Why is idempotency important? Repetitions due to network failures have no unintended consequences.
Most Important Sources
- https://learn.microsoft.com/en-us/azure/architecture/best-practices/api-design
- https://developer.mozilla.org/de/docs/Web/HTTP/Methods
- https://restfulapi.net/
- https://swagger.io/specification/
- https://www.howtographql.com/basics/1-graphql-vs-rest/