Skip to content
System Design Fundamentals

Lesson 7 of 12 · 22 min

x
7/12

Lesson position in the course — not completion. Use Mark Complete to track finished lessons (saved in this browser).

API Design Patterns

REST, GraphQL, and gRPC are the three dominant API styles, each optimised for a different context. REST is the standard for public APIs and browser clients — stateless, cacheable, and universally understood. GraphQL solves over-fetching for complex UIs — clients declare exactly the fields they need. gRPC uses Protocol Buffers over HTTP/2 for high-performance service-to-service calls — binary encoding is smaller and faster than JSON, with first-class streaming support.

API versioning prevents breaking changes from reaching existing clients. URL versioning (/v1/, /v2/) is explicit and easy to route. Deprecation requires a sunset period — announce the timeline, log usage of old endpoints, and monitor adoption before removal.

Before
REST — over-fetching on a mobile card
1// Client needs: name, avatar, follower_count2// REST returns the entire user object — 40 fields3GET /api/users/1234→ { id, name, email, bio, location, website,5    avatar, follower_count, following_count,6    created_at, updated_at, preferences, ... }
After
GraphQL — client declares exactly what it needs
1query {2  user(id: "123") {3    name4    avatar5    followerCount6  }7}8// Response: exactly 3 fields — nothing wasted9→ { name: "Alice", avatar: "...", followerCount: 1204 }

Check your understanding

  • REST vs GraphQL vs gRPC — one typical fit each?Show answer

    Answer

    REST: public/browser APIs. GraphQL: UIs with varying field needs. gRPC: internal typed service calls.
  • Why version public APIs?Show answer

    Answer

    So breaking changes do not strand existing clients — with a documented deprecation window.
  • What does over-fetching mean?Show answer

    Answer

    Returning many fields the client does not need for the current view — costly on mobile networks.
Previous

Progress is saved in this browser.

Next Lesson