Blackhole textureSpace texture

Blog Post

Read this blog post by Sakib U. SiddiQuie.

๐Ÿ”ฅ All The APIs You Should Know as a Developer (Part 1: Theory, Use Cases & Why They Exist)

Hey there ๐Ÿ‘‹

Whether you're a backend engineer, full-stack dev, or someone diving into API architecture, you've probably realizedโ€ฆ
REST and GraphQL are just the tip of the iceberg.

Thereโ€™s a whole world of APIs โ€” each designed to solve a very specific problem โ€” and knowing when and why to use them can seriously level up your backend game.

This post kicks off a 3-part guide where Iโ€™ll break down:

  1. ๐Ÿง  What each type of API does
  2. ๐ŸŽฏ Why it exists and what problem it solves
  3. โš”๏ธ Where it's useful (and where itโ€™s not)
  4. ๐Ÿงฉ Alternatives, pros, and cons

Letโ€™s dive in. โ˜•๏ธ

๐Ÿงฑ 1. REST API โ€“ The OG

๐Ÿง  What is it?

REST (Representational State Transfer) is the โ€œstandardโ€ HTTP API.
You hit URLs like /users/123 using verbs like GET, POST, PUT, DELETE.

๐ŸŽฏ Why it came in:

SOAP was too complex. REST simplified data exchange by using simple HTTP verbs and stateless interactions.

๐Ÿ› ๏ธ Common Use Cases:

  • CRUD APIs (users, products, orders)
  • Mobile app backends
  • Public developer APIs (e.g., GitHub, Stripe)

โœ… Pros:

  • Easy to use
  • Cacheable
  • Works anywhere

โŒ Gotchas:

  • Over-fetching or under-fetching data
  • Multiple requests for nested data

๐Ÿ”ฎ 2. GraphQL โ€“ Query What You Want

๐Ÿง  What is it?

A query language for APIs. Instead of multiple endpoints, you hit a single /graphql endpoint and ask for exactly what you need.

๐ŸŽฏ Why it came in:

Frontend devs were tired of REST giving them either too much or too little data. GraphQL fixed that.

๐Ÿ› ๏ธ Use Cases:

  • Modern SPAs (React/Angular)
  • Mobile apps with weak connections
  • APIs with complex data structures

โœ… Pros:

  • One request, custom data
  • Strong typing
  • Awesome dev tooling

โŒ Gotchas:

  • Caching is tricky
  • Can be overkill for simple apps

๐Ÿ”Œ 3. WebSockets โ€“ For Real-Time Vibes

๐Ÿง  What is it?

A persistent, bi-directional connection between client and server. Think chat, live games, or real-time dashboards.

๐ŸŽฏ Why it came in:

Polling the server every 2 seconds is just sad ๐Ÿ˜ข. WebSockets let both sides talk freely.

๐Ÿ› ๏ธ Use Cases:

  • Live chat
  • Multiplayer games
  • Real-time notifications

โœ… Pros:

  • Low latency
  • Push and pull data anytime

โŒ Gotchas:

  • Harder to scale
  • Can break over flaky networks

๐Ÿ“ฌ 4. Webhooks โ€“ "Ping Me When Stuff Happens"

๐Ÿง  What is it?

A simple way to get notified when an event occurs โ€” like Stripe telling you a payment succeeded.

๐ŸŽฏ Why it came in:

Nobody wants to poll an API constantly just to know if something happened. Let the server notify you.

๐Ÿ› ๏ธ Use Cases:

  • Stripe payment events
  • GitHub repo pushes
  • Slack bot commands

โœ… Pros:

  • Easy to implement
  • Decouples systems

โŒ Gotchas:

  • You need retry logic
  • Signature verification is important

๐Ÿš€ 5. gRPC โ€“ Blazing Fast for Backend-to-Backend

๐Ÿง  What is it?

A high-performance RPC (Remote Procedure Call) framework using Protocol Buffers and HTTP/2.

๐ŸŽฏ Why it came in:

REST was too chatty and slow for microservices in big systems. gRPC is faster, typed, and more efficient.

๐Ÿ› ๏ธ Use Cases:

  • Internal microservice communication
  • Backend-to-backend APIs
  • Real-time systems

โœ… Pros:

  • Super fast
  • Strong typing
  • Codegen in many languages

โŒ Gotchas:

  • Browser support is meh (needs proxy)
  • Debugging binary payloads is rough

๐ŸŽฅ 6. WebRTC โ€“ For Video & P2P Goodness

๐Ÿง  What is it?

Peer-to-peer communication directly between browsers. WebRTC lets you build video chat, file sharing, and low-latency streaming apps.

๐ŸŽฏ Why it came in:

To skip servers for real-time audio, video, and data โ€” and reduce latency big time.

๐Ÿ› ๏ธ Use Cases:

  • Video calling
  • P2P file transfers
  • Interactive media apps

โœ… Pros:

  • Peer-to-peer = low latency
  • Secure by default
  • No middleman servers

โŒ Gotchas:

  • Signaling is required (e.g., via WebSocket)
  • STUN/TURN servers can get complex

๐Ÿ“ก 7. SSE (Server-Sent Events) โ€“ Push-Only Simplicity

๐Ÿง  What is it?

A simple way for servers to push real-time updates to the browser over HTTP.

๐ŸŽฏ Why it came in:

WebSockets were overkill for simple "push-only" updates.

๐Ÿ› ๏ธ Use Cases:

  • Live notifications
  • Dashboards
  • Monitoring systems

โœ… Pros:

  • Super easy
  • Auto-reconnect
  • Works over HTTP/1.1

โŒ Gotchas:

  • Only one-way (server โ†’ client)
  • Browser support isnโ€™t 100%

๐Ÿ“จ 8. Message Queues โ€“ Async Everything

๐Ÿง  What is it?

MQs like RabbitMQ, Kafka, or SQS handle async comms between services.

๐ŸŽฏ Why it came in:

Tight coupling between services = bad. MQs let them talk without waiting.

๐Ÿ› ๏ธ Use Cases:

  • Background jobs (emails, payments)
  • Event-driven systems
  • Decoupled microservices

โœ… Pros:

  • Decouples systems
  • Supports retries, durability

โŒ Gotchas:

  • More infra to manage
  • Debugging async failures can be tricky

๐Ÿ’ง BONUS: SOAP โ€“ The XML Dinosaur

๐Ÿง  What is it?

SOAP (Simple Object Access Protocol) is an old-school protocol that uses XML for messaging and runs over HTTP, SMTP, or other protocols.

๐ŸŽฏ Why it came in:

Back in the early 2000s, enterprises needed a standardized, secure, and strict way to communicate between systems โ€” especially in banking, healthcare, and other regulated industries.

SOAP provided:

  • Strongly-typed interfaces (WSDL)
  • Built-in support for security (WS-Security)
  • Message validation
  • Complex data types

๐Ÿ› ๏ธ Use Cases:

  • Enterprise systems (ERP, banking, healthcare)
  • B2B APIs that need strict contracts
  • Legacy systems still running SOAP services

โœ… Pros:

  • Very strict (good for contracts)
  • Security baked in
  • Extensible headers and envelopes

โŒ Gotchas:

  • Heavy XML payloads
  • Verbose and slow
  • Harder to work with in modern apps

๐Ÿ‘€ Real Talk:

Most modern APIs don't use SOAP unless they're dealing with legacy enterprise systems.
Youโ€™ll mostly encounter SOAP when:

  • Integrating with old banking software
  • Using legacy .NET or Java enterprise services
  • Building government or healthcare systems

REST vs SOAP at a Glance

Feature REST SOAP Format JSON, XML XML only Transport HTTP HTTP, SMTP, more Flexibility Loose Very strict Speed Fast Slower (XML bloat) Used Today? Widely Rare (only legacy/enterprise) Spec Defined? Informal WSDL + XSD formal spec

๐Ÿงฉ Quick Recap

API Type Real-Time Two-Way Best For REST โŒ โŒ Classic CRUD APIs GraphQL โŒ โŒ Frontend-flexible queries WebSockets โœ… โœ… Real-time chat/games Webhooks โœ… โŒ Event push (payments, etc.) gRPC โŒ โŒ Internal microservices WebRTC โœ… โœ… Video, audio, P2P data SSE โœ… โŒ Notifications & dashboards MQ / PubSub โŒ โŒ Async event processing

๐Ÿ‘€ Coming Up Next: Code Everything

Thatโ€™s it for the theory ๐Ÿฟ
In Part 2, weโ€™ll jump into real working examples:

  • Node.js for building APIs
  • React or Angular clients
  • WebSockets, GraphQL, Webhooks, and more