Skip to main content

API Documentation

Official Specifications

  • OpenAPI 3.2 Spec (REST, SSE): JSON | YAML
  • AsyncAPI 3.0 Spec (WebSocket, Socket.IO, MQTT): JSON | YAML

Interactive Documentation


API Endpoints by Protocol

REST API (HTTPS)

Base URL: https://api.petstoreapi.com/v1

Server-Sent Events (SSE)

Endpoint: https://api.petstoreapi.com/v1/chat/completions (with stream: true)

WebSocket

Endpoint: wss://api.petstoreapi.com/v1/ws/chat

Socket.IO

Endpoint: wss://api.petstoreapi.com

MQTT (IoT)

Endpoint: mqtts://mqtt.petstoreapi.com:8883

Quick Examples

1. REST API

List Available Pets

Get a Specific Pet

Create a New Pet (Authenticated)

Search Pets with Filters

Advanced Search with QUERY Method

Create an Order


2. Server-Sent Events (SSE)

AI Chat with Streaming Response

JavaScript Example:
cURL Example:

3. WebSocket

Customer Support Chat

JavaScript Example:
Python Example:

4. Socket.IO

Real-time Support Chat

JavaScript Example:
Node.js Example:

5. MQTT (IoT Devices)

Order Status Updates

Python Example (paho-mqtt):
JavaScript Example (MQTT.js):

Authentication

All authenticated endpoints require either OAuth 2.0 or Bearer Token (JWT) authentication.

Getting an Access Token

Response:

Using the Token

Include the token in the Authorization header:

Multi-Tenancy

Isolate your data using the X-Tenant-ID header:
Important:
  • The tenant ID must be a valid UUID (v4 or v7)
  • Use the same tenant ID consistently for all related operations
  • Without a tenant ID, data is shared across all users

Rate Limits

The API uses IETF standard rate limiting headers:
When you exceed the rate limit, you’ll receive a 429 Too Many Requests response:

Error Handling

All errors follow RFC 9457 Problem Details format:

Next Steps


Common Use Cases

Browse Available Pets

Get Pet Details

Create an Adoption Application

Chat with AI Pet Advisor


Ready to build something amazing? Start exploring the Modern Petstore API today!