Skip to content
UniCircle
MediumConceptualREST APIs

REST principles and HTTP methods

Question NODE-RST-001

What is a RESTful API? Explain GET, POST, PUT, PATCH and DELETE, which of them are idempotent, and which status codes you would return for common cases.

Show the explanation

Model answer. REST is an architectural style for APIs over HTTP. Its key ideas: resources identified by URLs (/students/42), standard HTTP methods as verbs, stateless requests (each one carries everything needed, such as a token), and representations such as JSON.

  • GET /students/42: read. Safe (no changes) and idempotent.
  • POST /students: create. Not idempotent: sending twice creates two students.
  • PUT /students/42: replace the whole resource. Idempotent.
  • PATCH /students/42: change some fields. Not guaranteed idempotent.
  • DELETE /students/42: remove. Idempotent: deleting twice leaves the same end state.

Idempotent means making the same request several times has the same effect on the server as making it once, which makes retries after a network failure safe.

Typical status codes: 200 OK, 201 Created (with a Location header), 204 No Content, 400 Bad Request (invalid input), 401 Unauthorized (not signed in), 403 Forbidden (signed in, not allowed), 404 Not Found, 409 Conflict, 422 Unprocessable Entity, 429 Too Many Requests, 500 Internal Server Error.

Good REST guidelines: plural nouns for collections, no verbs in URLs, consistent error bodies, pagination for lists, and versioning.

Original UniCircle question. Last reviewed 22 Oct 2026.