Skip to main content

Quick Protocol Selection


Protocol Details

1. REST API (HTTPS)

The foundation - Standard HTTP-based API following RESTful principles. Base URL: https://api.petstoreapi.com/v1 When to Use:
  • Standard CRUD operations (Create, Read, Update, Delete)
  • Resource-oriented operations
  • Stateful client-server communication
  • When you need caching (HTTP cache headers)
Key Features:
  • ✅ Pure RESTful design (proper HTTP methods, status codes)
  • ✅ Resource-oriented URLs (/pets, /users, /orders)
  • ✅ Collection wrappers with pagination
  • ✅ RFC 9457 error responses
  • ✅ IETF rate limiting headers
Quick Example:
Documentation:

2. Server-Sent Events (SSE)

Real-time streaming - Server pushes data to client over HTTP. Endpoint: https://api.petstoreapi.com/v1/chat/completions (with stream: true) When to Use:
  • Real-time updates from server to client
  • AI chat streaming responses
  • Live notifications
  • When you only need server → client communication
Key Features:
  • ✅ Built on HTTP (no new infrastructure needed)
  • ✅ Automatic reconnection handling
  • ✅ Text-based, easy to debug
  • ✅ One-way communication (server → client)
Quick Example:
Documentation:

3. WebSocket

Full-duplex communication - Persistent connection for bidirectional real-time messaging. Endpoint: wss://api.petstoreapi.com/v1/ws/chat When to Use:
  • Real-time bidirectional communication
  • Customer support chat systems
  • Collaborative applications
  • Low-latency updates required
Key Features:
  • ✅ Full-duplex (send and receive simultaneously)
  • ✅ Low latency
  • ✅ Persistent connection
  • ✅ Binary and text data support
Quick Example:
Documentation:

4. Socket.IO

WebSocket with fallbacks - Real-time communication with automatic fallback. Endpoint: wss://api.petstoreapi.com When to Use:
  • Real-time features that must work everywhere
  • Need automatic fallback (polling) when WebSocket unavailable
  • Building customer support chat
  • Need room-based messaging
Key Features:
  • ✅ Automatic fallback to long-polling
  • ✅ Room-based messaging
  • ✅ Reconnection handling
  • ✅ Broadcast capabilities
Quick Example:
Documentation:

5. MQTT (Message Queuing Telemetry Transport)

Lightweight IoT protocol - Publish/subscribe for resource-constrained devices. Endpoint: mqtts://mqtt.petstoreapi.com:8883 When to Use:
  • IoT devices and sensors
  • Low-bandwidth, unreliable networks
  • Battery-powered devices
  • Many devices publishing data
Key Features:
  • ✅ Extremely lightweight (small packet overhead)
  • ✅ Publish/Subscribe pattern
  • ✅ QoS levels (guaranteed delivery)
  • ✅ Works on unreliable networks
Quick Example:
Documentation:

6. Webhooks

Event-driven HTTP callbacks - Server pushes events to your endpoints. When to Use:
  • Real-time notifications for events
  • Order status updates
  • Payment confirmations
  • Pet adoption notifications
Key Features:
  • ✅ Server initiates the request
  • ✅ Your endpoint receives events
  • ✅ Retry logic on failure
  • ✅ HMAC signature verification
Quick Example:
Documentation:

7. GraphQL

Flexible query language - Request exactly the data you need. Endpoint: https://api.petstoreapi.com/v1/graphql When to Use:
  • Complex, nested data requirements
  • Mobile applications (reduce payload size)
  • Multiple resources in single request
  • Flexible, self-documenting API
Key Features:
  • ✅ Request exactly what you need
  • ✅ Single request for multiple resources
  • ✅ Strongly typed schema
  • ✅ Introspection (self-documenting)
Quick Example:
Documentation:

8. gRPC

High-performance RPC - Binary protocol for microservices. When to Use:
  • High-performance requirements
  • Microservice-to-microservice communication
  • Strongly typed contracts needed
  • Low latency, high throughput
Key Features:
  • ✅ Binary serialization (Protocol Buffers)
  • ✅ High performance
  • ✅ Strong typing with .proto files
  • ✅ Built-in code generation
Quick Example:
Documentation:

9. MCP (Model Context Protocol)

AI assistant integration - Connect Claude Desktop and other AI assistants. When to Use:
  • Building AI-powered tools
  • Claude Desktop integration
  • AI assistant needs to query your data
  • Context-aware AI interactions
Key Features:
  • ✅ Standard protocol for AI tools
  • ✅ Resource and prompt definitions
  • ✅ Native Claude Desktop support
  • ✅ Context-aware responses
Quick Example:
Documentation:

10. WADL (Web Application Description Language)

XML-based API description - Machine-readable format for HTTP-based web services. Specification: https://api.petstoreapi.com/v1/specs/modern-petstore.wadl When to Use:
  • Java/JAX-RS web services
  • Legacy enterprise system integration
  • Client code generation for Java
  • XML-based toolchains
Key Features:
  • ✅ XML Schema type system
  • ✅ Resource-oriented descriptions
  • ✅ Automatic client generation
  • ✅ JAX-RS framework support
Quick Example:
Documentation:

11. WSDL (Web Services Description Language)

SOAP web services - Enterprise integration with formal contracts. Specification: https://api.petstoreapi.com/v1/specs/modern-petstore.wsdl Endpoint: https://api.petstoreapi.com/v1/soap When to Use:
  • Enterprise system integration (SAP, Oracle)
  • Formal service contracts (SLA agreements)
  • .NET or Java enterprise frameworks
  • Built-in security requirements (WS-Security)
  • Transactional operations
Key Features:
  • ✅ XML Schema strong typing
  • ✅ WS-* standards (Security, Transactions)
  • ✅ SOAP envelope messaging
  • ✅ Wide enterprise tooling support
Quick Example:
Documentation:

12. RAML (RESTful API Modeling Language)

Design-first API specification - YAML-based API description with reusable components. Specification: https://api.petstoreapi.com/v1/specs/modern-petstore.raml When to Use:
  • API design before implementation
  • MuleSoft Anypoint Platform integration
  • Highly modular API specifications
  • Strong type validation needed
  • Building APIs with consistent patterns
Key Features:
  • ✅ YAML-based, human-readable
  • ✅ Reusable types, traits, and resource types
  • ✅ Design-first approach
  • ✅ Auto-generated documentation
  • ✅ Modular specifications
Quick Example:
Documentation:

Protocol Comparison

When to Use Each Protocol

Performance Characteristics


Getting Started

For Beginners

  1. Start with REST - It’s the most common and well-documented
  2. Explore the Quick Start Guide
  3. Check out interactive documentation

For Specific Use Cases

  • Web Applications: REST + SSE/WebSocket
  • Mobile Apps: REST + GraphQL
  • IoT Devices: MQTT
  • Microservices: gRPC
  • AI Integration: MCP

Specifications

  • OpenAPI 3.2 (REST, SSE, Webhooks): JSON | YAML
  • AsyncAPI 3.0 (WebSocket, MQTT, Kafka): JSON | YAML
  • WADL (Java/JAX-RS Web Services): XML
  • WSDL (SOAP Web Services): XML
  • RAML 1.0 (API Design): YAML


Need help choosing? Contact us at support@petstoreapi.com