Blackhole textureSpace texture

Blog Post

Read this blog post by Sakib U. SiddiQuie.

๐Ÿ’ป All the APIs You Should Know (Part 2: Real Code Examples in Node.js + React)

#web-development#react.js#fullstack#api

Awesome โ€” let's roll into Part 2: Code Examples ๐Ÿ’ป

๐Ÿ’ป All the APIs You Should Know (Part 2: Real Code Examples in Node.js + React)

In this section, weโ€™re not just talking theory โ€” we're going hands-on.

Youโ€™ll see how to:

  • Build each API type in Node.js (Express/Apollo/ws)
  • Connect to it from React (or Angular if noted)
  • Understand where each API shines through code

If you missed Part 1 (theory + concepts), go back here โ€” but if you're ready to get your hands dirty, letโ€™s start!

๐Ÿงฑ REST API โ€“ Node + React

๐Ÿ›  Backend (Node.js + Express)

Detecting language...

๐Ÿ–ฅ Frontend (React)

Detecting language...

๐Ÿ”ฎ GraphQL โ€“ Node + React

๐Ÿ›  Backend (Apollo Server)

Detecting language...

๐Ÿ–ฅ Frontend (React + Apollo Client)

Detecting language...
Detecting language...

๐Ÿ”Œ WebSockets โ€“ Node + React

๐Ÿ›  Backend (WebSocket Server)

Detecting language...

๐Ÿ–ฅ Frontend (React)

Detecting language...

๐Ÿ“ฌ Webhooks โ€“ Node.js

๐Ÿ›  Webhook Listener (Server)

Detecting language...

๐Ÿงช To Test It:

You can POST to it manually or use Webhook.site or tools like curl or Postman:

Detecting language...

๐Ÿ“ก Server-Sent Events (SSE)

๐Ÿ›  Node.js SSE Server

Detecting language...

๐Ÿ–ฅ React SSE Client

Detecting language...

๐Ÿ’ง SOAP โ€“ Node.js (With soap Package)

SOAP is XML-based and contract-driven. We'll use a mock SOAP service with Node.js using the soap package.

๐Ÿงช This is rare in new projects but shows up in legacy & enterprise integrations.

๐Ÿ›  SOAP Server (Node.js)

Detecting language...
Detecting language...

๐ŸŽฅ WebRTC โ€“ Browser Only (P2P)

WebRTC works peer-to-peer in the browser but needs signaling (like WebSocket) to exchange info first.

Hereโ€™s a simple demo setup:

๐Ÿ–ฅ Frontend (React or Vanilla JS)

Detecting language...

โš™๏ธ gRPC โ€“ Node.js (Protocol Buffers)

We'll use @grpc/grpc-js and @grpc/proto-loader.

๐Ÿ“„ hello.proto

Detecting language...

๐Ÿ›  Server

Detecting language...
Detecting language...

๐Ÿ–ฅ Client

Detecting language...

๐Ÿ“จ Message Queue โ€“ RabbitMQ with Node.js

๐Ÿ›  Producer (Sender)

Detecting language...
Detecting language...

๐Ÿ›  Consumer (Worker)

Detecting language...

๐Ÿ” Streaming API โ€“ Kafka-Style (Simulated)

Kafka is too heavy to set up here, so weโ€™ll simulate a stream using a basic EventEmitter to represent continuous data streaming.

Detecting language...

๐Ÿ” OAuth2 + JWT Authentication

๐Ÿ›  Backend: JWT Auth with Express

Detecting language...
Detecting language...

โœ… we now have working examples code :

โšก Coming Up: Part 3 โ€” Final Recommendations, Architecture Tips & Cheatsheets

Next up, Iโ€™ll wrap this series with:

  • ๐Ÿ”ง When to use each API (real-world context)
  • โš”๏ธ REST vs GraphQL vs gRPC vs Webhooks โ€” when to choose what
  • ๐Ÿ“‹ Full cheatsheets and decision trees
  • ๐Ÿ“ฆ Extra tools and packages to use per API type