Code-Memo

API Fundamentals

What an API is

  1. An API (Application Programming Interface) is a contract that defines how one piece of software asks another for work or data and what responses look like.
  2. APIs hide implementation details so clients can stay stable while servers evolve.
  3. Common shapes: HTTP/REST, RPC, GraphQL, message queues, and webhooks.

Client-server communication model

  1. A client initiates requests (browser, mobile app, another service); a server exposes endpoints and enforces policy.
  2. The model scales by adding more servers, load balancers, and caches behind a stable API surface.
  3. In microservices, “client” and “server” are often both backend services calling each other.

API vs SDK vs library

  1. API: the interface (protocol, URLs, schemas, rules), not necessarily shipped code.
  2. SDK: generated or hand-written client libraries that wrap the API for a language (e.g., official AWS SDKs).
  3. Library: reusable code; may or may not target a specific remote API (could be purely local helpers).

REST vs RPC vs GraphQL overview

  1. REST: resource-oriented HTTP; verbs map to methods; good caching and broad tooling; can cause over/under-fetching.
  2. RPC (e.g., JSON-RPC, gRPC): action-oriented “call this procedure”; strong for internal low-latency service-to-service calls.
  3. GraphQL: client-driven field selection on one endpoint; flexible for UIs; needs discipline on complexity limits and caching.