Skip to content

API Protocols — HTTP, gRPC, and GraphQL Compared

DodaTech Updated 2026-06-28 2 min read

In this tutorial, you will learn about API Protocols. We cover key concepts, practical examples, and best practices to help you master this topic.

API protocols are the rules and formats that govern communication between services, with HTTP powering REST and SOAP, gRPC enabling high-performance RPC, and GraphQL providing flexible client-driven queries.

What You'll Learn

  • The strengths and weaknesses of each major API protocol
  • When to choose HTTP/REST vs gRPC vs GraphQL
  • How protocol choice affects performance and developer experience

Why It Matters

Choosing the wrong protocol leads to over-engineered systems or performance bottlenecks. DodaTech's Durga Antivirus Pro uses REST for public APIs, gRPC for internal Microservices, and plans GraphQL for the dashboard.

flowchart TD
    A["API Protocols"] --> B["HTTP/REST"]
    A --> C["gRPC"]
    A --> D["GraphQL"]
    B --> E["Readable, cacheable,\nstandard status codes"]
    C --> F["High performance,\nstrongly typed, streaming"]
    D --> G["Flexible queries,\nsingle endpoint, real-time"]
    style A fill:#dbeafe,stroke:#2563eb

Code Examples

# HTTP/REST
import requests
response = requests.get("https://api.example.com/v1/users")
print(response.json())
// GraphQL
const query = `
  query {
    users {
      id
      name
      email
    }
  }
`;
fetch('https://api.example.com/graphql', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({query})
})
.then(res => res.json())
.then(data => console.log(data));
# gRPC using grpcurl
grpcurl -d '{"user_id": 1}' \
  -H "Authorization: Bearer token" \
  api.example.com:443 UserService/GetUser

Common Mistakes

1. Using REST for High-Throughput Internal Calls

gRPC is 5-10x faster for internal microservice communication.

2. Using GraphQL Without Caching

GraphQL responses are hard to cache because queries vary per client.

3. Choosing gRPC for Public APIs

gRPC requires HTTP/2 and protobuf, which browser support is limited.

4. Assuming REST is Always the Best Choice

Each protocol has trade-offs. Pick based on your use case.

5. Ignoring Protocol Limitations

Websocket doesn't do request-response; gRPC doesn't do browser clients easily.

Practice Questions

  1. What protocol does REST typically use?
  2. Why is gRPC faster than REST for internal services?
  3. What problem does GraphQL solve that REST doesn't?
  4. Can you use HTTP/2 with REST?
  5. Which protocol is best for real-time bidirectional communication?

Answers:

  1. HTTP/HTTPS.
  2. gRPC uses HTTP/2, binary encoding (protobuf), and persistent connections.
  3. GraphQL lets clients request only the fields they need, preventing over-fetching.
  4. Yes, REST works over any HTTP version, but HTTP/2 improves performance.
  5. WebSocket for real-time; gRPC streaming for high-throughput server-to-server.

Challenge: Design a system where REST handles public CRUD endpoints, gRPC handles internal microservice communication, and GraphQL powers a dashboard UI. Explain the data flow.

FAQ

Can you use gRPC from a browser?

: Not directly. Browsers don't fully support HTTP/2 trailers. Use gRPC-Web or a proxy.

Is SOAP still a valid API protocol?

: Yes. SOAP is still used in banking, healthcare, and enterprise systems requiring formal contracts.

What is the slowest part of an API call?

: Network latency, not the protocol. Protocol choice matters most for high-volume internal calls.

What's Next

Dive into REST Introduction to learn the most popular API protocol in depth, or explore SOAP Protocol for enterprise patterns.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro