Petstore API
Interactive OpenAPI 3.0 demonstration with the Swagger Petstore API - Complete API documentation with sidebar navigation, live testing, and comprehensive endpoint coverage
Swagger Petstore - OpenAPI 3.0
This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about Swagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach! You can now help us improve the API whether it's by making changes to the definition itself or to the code. That way, with time, we can improve the API in general, and expose some of the new features in OAS3. Some useful links: - [The Pet Store repository](https://github.com/swagger-api/swagger-petstore) - [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
https://petstore.swagger.io/api/v3
Fast & Reliable
Optimized for speed with CDN caching and 99.9% uptime
CORS Enabled
Use from any frontend application without restrictions
No Authentication
Public endpoints accessible without API keys
Start using the API in minutes
Authenticate Your Requests
Get your API key and start making authenticated requests
// Set up your API key
const API_KEY = 'your-api-key-here';
const baseURL = '/api/v3';
// Make authenticated request
const response = await fetch(`${baseURL}/pet/findByStatus?status=available`, {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
}
});
const pets = await response.json();
console.log('Available pets:', pets);
Basic API authentication and request
# Get available pets
curl -X GET "/api/v3/pet/findByStatus?status=available" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
Command line request with authentication
import requests
# API configuration
API_KEY = "your-api-key-here"
BASE_URL = "/api/v3"
# Make authenticated request
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
response = requests.get(
f"{BASE_URL}/pet/findByStatus",
params={"status": "available"},
headers=headers
)
pets = response.json()
print(f"Found {len(pets)} available pets")
Python example with requests library
Create a New Pet
Add a new pet to the store
// Create a new pet
const newPet = {
id: 123,
category: { id: 1, name: "Dogs" },
name: "Rex",
photoUrls: ["https://example.com/rex.jpg"],
tags: [{ id: 1, name: "friendly" }],
status: "available"
};
const response = await fetch(`${baseURL}/pet`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(newPet)
});
if (response.ok) {
console.log('Pet created successfully!');
} else {
console.error('Failed to create pet');
}
Create a new pet with all required fields
Explore the API
Use the interactive documentation to test all endpoints
API Endpoints
pet
Everything about your Pets
/pet
Add a new pet to the store.
/pet
Update an existing pet.
/pet/findByStatus
Finds Pets by status.
/pet/findByTags
Finds Pets by tags.
/pet/{petId}
Find pet by ID.
/pet/{petId}
Updates a pet in the store with form data.
/pet/{petId}
Deletes a pet.
/pet/{petId}/uploadImage
Uploads an image.
store
Access to Petstore orders
/store/inventory
Returns pet inventories by status.
/store/order
Place an order for a pet.
/store/order/{orderId}
Find purchase order by ID.
/store/order/{orderId}
Delete purchase order by identifier.
user
Operations about user
/user
Create user.
/user/createWithList
Creates list of users with given input array.
/user/login
Logs user into the system.
/user/logout
Logs out current logged in user session.
/user/{username}
Get user by user name.
/user/{username}
Update user resource.
/user/{username}
Delete user resource.
License & Legal
Need Help?
Email: apiteam@swagger.io
Additional Resources
🔧 Developer Tools
- Swagger UI - Interactive testing interface
- OpenAPI Spec (JSON) - Complete API specification
- OpenAPI Spec (YAML) - YAML format specification
📚 Learning Resources
- OpenAPI Specification - Official specification documentation
- Swagger Editor - Online editor for OpenAPI specs
- API Design Best Practices - Industry best practices
⚡ Key Features Demonstrated
🔄 CRUD Operations
Complete Create, Read, Update, Delete functionality across all resources
🔐 Authentication
Multiple authentication methods including API Key, OAuth2, and HTTP Basic
📁 File Uploads
Image upload capabilities for pet photos and attachments
🛡️ Error Handling
Comprehensive error responses with detailed status codes and messages
📊 Response Formats
The API supports multiple response formats to meet different integration needs:
- JSON (default) - Standard REST API format
- XML - Legacy system compatibility
- Form Data - Browser form submissions
🚨 Important Notes
Live Demo Environment
This is a live API maintained by Swagger for demonstration and testing purposes. Data may be reset periodically, so don't rely on it for persistent storage.
🎯 Perfect For
- Learning OpenAPI 3.0 specification and standards
- Testing API tools and client libraries
- Prototyping API integrations and workflows
- Training developers on REST API best practices