Go

REST API Design

REST principles, versioning, pagination, filtering, HATEOAS, status codes, OpenAPI/Swagger

20 interview questionsยท
Mid-Level
1

What is the fundamental principle of REST?

Answer

REST is based on the principle of representing resources accessible via unique URIs. Each resource (user, product, order) has a URI and can be manipulated through standard HTTP verbs (GET, POST, PUT, DELETE). This resource-oriented paradigm enables a scalable and decoupled architecture where the server does not store client session state.

2

Which HTTP method should be used for an idempotent full update of a resource?

Answer

PUT is idempotent and completely replaces the resource. Calling PUT multiple times with the same data produces the same result as a single call. In contrast, POST is not idempotent (would create multiple resources), PATCH performs partial updates, and DELETE removes the resource. PUT's idempotence guarantees retry safety in case of network errors.

3

Which HTTP code should be returned after successful creation of a new resource?

Answer

The 201 Created code indicates that a resource was successfully created. It is accompanied by a Location header pointing to the URI of the new resource. The 200 OK code is too generic for creation, 204 No Content is used when there is no response body, and 202 Accepted signals asynchronous processing not yet complete.

4

What major difference distinguishes a REST API from an RPC API?

5

What does the statelessness principle mean in REST?

+17 interview questions

Master Go for your next interview

Access all questions, flashcards, technical tests, code review exercises and interview simulators.

Start for free