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
| Method | Safe | Idempotent | Purpose |
|---|---|---|---|
| GET | ✅ | ✅ | Retrieve resources |
| POST | ❌ | ❌ | Create resources or submit forms |
| PUT | ❌ | ✅ | Full update (replace) |
| PATCH | ❌ | ✅ | Partial update |
| DELETE | ❌ | ✅ | Delete resources |
| QUERY | ✅ | ✅ | Complex queries with body (OpenAPI 3.2) |
3. Correct HTTP Status Codes
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 theAuthorization header:
Multi-Tenancy
Isolate data using theX-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:Caching
Resources include cache headers:Navigation Links
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
- Apidog UI: https://docs.petstoreapi.com
- Swagger UI: https://api.petstoreapi.com/v1/swagger-ui.html
- OpenAPI Spec: https://api.petstoreapi.com/v1/openapi.json