Mastering RESTful API Design: When to Use Each HTTP Method
This guide demystifies RESTful API design by explaining the role of each HTTP method, resource types, URL conventions, and best‑practice principles, using clear diagrams so beginners can grasp how to build scalable, maintainable backend services.
What is RESTful API?
In simple terms, a RESTful API is an HTTP‑based, stateless design where every action operates on a resource; the API manages these resources through HTTP verbs.
HTTP Method Semantics
In a RESTful system the client interacts with the server using HTTP semantics. The five most common methods are:
GET: retrieve one or more resources from the server.
POST: create a new resource on the server.
PUT: update an existing resource (client provides the full representation).
DELETE: remove a resource from the server.
HEAD: fetch header information only (no resource body).
Some API designers misuse these verbs, e.g., using GET for actions that should be PUT.
Web Service Resource Types
Clients and servers must agree on media types. Common types that start with application include:
application/json – JSON data format
application/xhtml+xml – XHTML format
application/xml – XML data format
application/atom+xml – Atom XML aggregation format
API Design Principles
URL
Use nouns, avoid verbs.
Deploy APIs under a dedicated domain (e.g., https://api.example.com).
Include version numbers in the URL or HTTP headers.
Path (Endpoint)
Endpoints represent resources; use plural nouns that often match database table names.
Example URLs for a zoo API:
https://api.example.com/v1/zoos
https://api.example.com/v1/animals
https://api.example.com/v1/employees
Media Types
Choose domain‑specific media types and avoid reinventing the wheel.
Typical responses are JSON or XML; some services also provide PHP or Atom formats.
Other Considerations
Extensibility – design so new features can be added later.
Flexibility – support UI requirements.
Portability – run on any operating system.
Developer friendliness – easy to type in a browser.
API Design Process
Source: “RESTful Web APIs” book.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Huawei Cloud Developer Alliance
The Huawei Cloud Developer Alliance creates a tech sharing platform for developers and partners, gathering Huawei Cloud product knowledge, event updates, expert talks, and more. Together we continuously innovate to build the cloud foundation of an intelligent world.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
