API Fundamentals
What an API is
- 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.
- APIs hide implementation details so clients can stay stable while servers evolve.
- Common shapes: HTTP/REST, RPC, GraphQL, message queues, and webhooks.
Client-server communication model
- A client initiates requests (browser, mobile app, another service); a server exposes endpoints and enforces policy.
- The model scales by adding more servers, load balancers, and caches behind a stable API surface.
- In microservices, “client” and “server” are often both backend services calling each other.
API vs SDK vs library
- API: the interface (protocol, URLs, schemas, rules), not necessarily shipped code.
- SDK: generated or hand-written client libraries that wrap the API for a language (e.g., official AWS SDKs).
- Library: reusable code; may or may not target a specific remote API (could be purely local helpers).
REST vs RPC vs GraphQL overview
- REST: resource-oriented HTTP; verbs map to methods; good caching and broad tooling; can cause over/under-fetching.
- RPC (e.g., JSON-RPC, gRPC): action-oriented “call this procedure”; strong for internal low-latency service-to-service calls.
- GraphQL: client-driven field selection on one endpoint; flexible for UIs; needs discipline on complexity limits and caching.