REST API

REST (Representational State Transfer) maps CRUD operations onto HTTP methods. Each method has well-defined semantics that clients and servers can rely on — using the right method makes your API predictable and cache-friendly.

HTTP Methods

MethodPurposeIdempotentSafe
GETRead a resourceYesYes
POSTCreate a resourceNoNo
PUTReplace a resourceYesNo
PATCHPartially updateNoNo
DELETERemove a resourceYesNo

Idempotent means calling the method multiple times has the same effect as calling it once. Safe means the method should not modify server state.

Try It

Select a method below to see a sample request and response:

GET /api/posts/1

HTTP/1.1 200

{ "id": 1, "title": "Hello" }

Design Principles

Good REST APIs use nouns for resource paths (/posts/1) and verbs via HTTP methods, not in the URL (/getPost/1). Status codes communicate outcome: 200 for success, 201 for created, 204 for deleted with no body, 404 for not found.

Keep responses consistent in shape, version your API when breaking changes are unavoidable, and document the contract so clients can integrate without guessing.

Back to Tawny