Skip to main content

Overview

Base URL: https://api.petstoreapi.com/v1 Protocol: HTTPS (REST over HTTP/1.1 or HTTP/2) Content-Type: application/json The REST API follows all REST architectural constraints:
  • Client-Server: Clear separation of concerns
  • Stateless: Each request contains all necessary information
  • Cacheable: Responses include cache headers
  • Uniform Interface: Consistent resource-oriented design
  • Layered System: No client visibility into server architecture

RESTful Design Principles

1. Resource-Oriented URLs

URLs represent resources (nouns), not actions (verbs):

2. Proper HTTP Methods

Example:

3. Correct HTTP Status Codes

Example:

4. Collection Wrappers

Never return bare arrays. Always wrap collections with metadata:

5. Plural Resource Names

Always use plural nouns for collections:

Authentication

Bearer Token (JWT)

Include the token in the Authorization header:

Multi-Tenancy

Isolate data using the X-Tenant-ID header:

Endpoints

Pets

Advanced Search (QUERY Method)

OpenAPI 3.2 introduces the QUERY method for complex searches:

Orders


Error Handling

All errors follow RFC 9457 Problem Details format:

Rate Limiting

The API uses IETF standard rate limiting headers:
When exceeded:

Caching

Resources include cache headers:
Conditional requests:

Resources include HATEOAS-style links:

Code Examples

TypeScript

Python


Best Practices

1. Follow HTTP Semantics

  • Use GET for retrieval (safe, idempotent)
  • Use POST for creation (not idempotent)
  • Use PUT for full replacement (idempotent)
  • Use PATCH for partial updates (idempotent)
  • Use DELETE for removal (idempotent)

2. Handle Status Codes Correctly

3. Respect Rate Limits

4. Use Conditional Requests


Interactive Documentation