İçeriğe Atla
Mustafa Erbay
Tutorials · 9 min read · görüntülenme Türkçe oku
100%

REST API Design Principles

Practical rules for sustainable REST API design in production — from resource modelling to idempotency, pagination, and the error contract.

REST API Design Principles — cover image

Designing a REST API is much less about writing endpoints and much more about designing a contract. Once the contract is bad, after a while everything turns into backwards-compat hacks “so the clients don’t break.”

In this post I’ve collected the principles I use for sustainable REST APIs in production: resource modelling, HTTP semantics, idempotency, pagination, the error model, and versioning.

1) Resource model: nouns, not verbs

URIs should describe “things,” not “actions”:

  • /users/{id}
  • /getUser

HTTP methods carry semantics:

  • GET: read (idempotent)
  • POST: create/command (may not be idempotent)
  • PUT: replace (idempotent)
  • PATCH: partial update (typically designed to be idempotent)
  • DELETE: delete (idempotent)

2) Idempotency: surviving retries

Retries happen in production. That’s why an idempotency key — particularly for POST — makes a serious difference.

3) Pagination: cursor over OFFSET

As OFFSET grows, costs rise and consistency degrades. Cursor-based pagination is healthier in production.

4) Error contract: one format, actionable message

Use a single error model:

{
  "error": {
    "code": "INVALID_ARGUMENT",
    "message": "email is required",
    "requestId": "..."
  }
}

5) Versioning: evolve without breaking

The rule: if there’s a breaking change, bump the version. Where possible, move forward through “additive change” — add new fields and deprecate the old ones.

Conclusion

The goal in REST API design: make correct usage easy for the client and incorrect usage hard. Details like idempotency, the error contract, and pagination are the places that cause the most problems in production.

Paylaş:

Bu yazı faydalı oldu mu?

Yükleniyor...

Bu yazı nasıldı?

ME

Mustafa Erbay

Sistem Mimarisi · Network Uzmanı · Altyapı, Güvenlik ve Yazılım

2006'dan bu yana sistem mimarisi, network, sunucu altyapıları, büyük yapıların kurulumu, yazılım ve sistem güvenliği ekseninde çalışıyorum. Bu blogda sahada karşılığı olan teknik deneyimlerimi paylaşıyorum.

Kişisel Notlar

Bu notlar sadece sizde saklanır. Tarayıcınızda yerel olarak tutulur.

Hazır 0 karakter

Comments

Server-side AI Moderation

Comments are AI-moderated server-side and stored permanently.

?
0/2000

Server-side AI moderation

✉️ Free · No spam · Unsubscribe anytime

Curated digest, hand-picked by me — not the AI

Once a week: the most important post of the week, behind-the-scenes notes, and a "what I actually used this week" section. Less noise, more signal.

  • 📌
    Best of the week Single most-worth-reading post
  • 🔧
    Toolbox notes Real tools I used this week
  • 🧠
    Behind-the-scenes Notes that don't make it to blog

We don't spam. Unsubscribe anytime. · Tracked only by Umami (self-hosted, no Google).

Your Reading Stats

0

Posts Read

0m

Reading Time

0

Day Streak

-

Favorite Category

Related Posts