Swagger Petstore example

This page renders the Swagger Petstore sample API, a larger reference than the short OpenAPI Spec example. The specification uses the Swagger 2.0 format and contains pets, store orders, and users with path, query, header, and form parameters, enums, and file uploads. The OpenAPI 3.0 Petstore example shows the same API in the newer format.

The page needs only this front matter:

---
openapi: ./openapi-petstore.json
---

openapi-petstore.json is the specification from https://petstore.swagger.io/v2/swagger.json, formatted with indentation. The specification declares the Apache License 2.0.

API overview

Swagger Petstore

Version 1.0.7

License Apache 2.0Contact apiteam@swagger.ioTerms of service

This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.

Servers
  • https://petstore.swagger.io/v2
  • http://petstore.swagger.io/v2
Authentication
  • api_keyAPI key api_key in header
  • petstore_authOAuth 2.0
pet3 3 1 1 Everything about your Pets
GET /pet/findByStatus Finds Pets by status

Operation ID findPetsByStatus

Multiple status values can be provided with comma separated strings

Authorization
  • petstore_authOAuth 2.0write:petsread:pets

Query Parameters

Parameter Description
status: [string]availablependingsold Status values that need to be considered for filter
Response 1 of 2

successful operation

Media Type 1 of 2
GET /pet/findByTags Deprecated Finds Pets by tags

This operation is deprecated and should no longer be used.

Operation ID findPetsByTags

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

Authorization
  • petstore_authOAuth 2.0write:petsread:pets

Query Parameters

Parameter Description
tags: [string] Tags to filter by
Response 1 of 2

successful operation

Media Type 1 of 2
GET /pet/{petId} Find pet by ID

Operation ID getPetById

Returns a single pet

Authorization
  • api_keyAPI key api_key in header

Path Parameters

Parameter Description
petId: int64 ID of pet to return
Response 1 of 3

successful operation

Media Type 1 of 2
POST /pet Add a new pet to the store

Operation ID addPet

Authorization
  • petstore_authOAuth 2.0write:petsread:pets

Request body Required

Pet object that needs to be added to the store

Media Type 1 of 2
Response 1 of 1

Invalid input

Media Type 1 of 2
POST /pet/{petId} Updates a pet in the store with form data

Operation ID updatePetWithForm

Authorization
  • petstore_authOAuth 2.0write:petsread:pets

Path Parameters

Parameter Description
petId: int64 ID of pet that needs to be updated

Request body

Media Type 1 of 1

object

{
  "name": "string",
  "status": "string"
}
Response 1 of 1

Invalid input

Media Type 1 of 2
POST /pet/{petId}/uploadImage uploads an image

Operation ID uploadFile

Authorization
  • petstore_authOAuth 2.0write:petsread:pets

Path Parameters

Parameter Description
petId: int64 ID of pet to update

Request body

Media Type 1 of 1

object

{
  "additionalMetadata": "string",
  "file": "string"
}
Response 1 of 1

successful operation

Media Type 1 of 1

ApiResponse

{
  "code": 0,
  "type": "string",
  "message": "string"
}
PUT /pet Update an existing pet

Operation ID updatePet

Authorization
  • petstore_authOAuth 2.0write:petsread:pets

Request body Required

Pet object that needs to be added to the store

Media Type 1 of 2
Response 1 of 3

Invalid ID supplied

Media Type 1 of 2
DELETE /pet/{petId} Deletes a pet

Operation ID deletePet

Authorization
  • petstore_authOAuth 2.0write:petsread:pets

Path Parameters

Parameter Description
petId: int64 Pet id to delete

Header Parameters

Parameter Description
api_key: string
Response 1 of 2

Invalid ID supplied

Media Type 1 of 2
store2 1 1 Access to Petstore orders
GET /store/inventory Returns pet inventories by status

Operation ID getInventory

Returns a map of status codes to quantities

Authorization
  • api_keyAPI key api_key in header
Response 1 of 1

successful operation

Media Type 1 of 1

[string: int32]

{
  "additionalProp1": 0
}
GET /store/order/{orderId}Find purchase order by ID

Operation ID getOrderById

For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions

Path Parameters

Parameter Description
orderId: int64≥ 1≤ 10 ID of pet that needs to be fetched
Response 1 of 3

successful operation

Media Type 1 of 2
POST /store/orderPlace an order for a pet

Operation ID placeOrder

Request body Required

order placed for purchasing the pet

Media Type 1 of 1
Response 1 of 2

successful operation

Media Type 1 of 2
DELETE /store/order/{orderId}Delete purchase order by ID

Operation ID deleteOrder

For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors

Path Parameters

Parameter Description
orderId: int64≥ 1 ID of the order that needs to be deleted
Response 1 of 2

Invalid ID supplied

Media Type 1 of 2
user3 3 1 1 Operations about user
GET /user/loginLogs user into the system

Operation ID loginUser

Query Parameters

Parameter Description
username: string The user name for login
password: string The password for login in clear text
Response 1 of 2

successful operation

Response headers

Header Description
X-Expires-After: dateTime date in UTC when token expires
X-Rate-Limit: int32 calls per hour allowed by the user
Media Type 1 of 2

string

"string"
GET /user/logoutLogs out current logged in user session

Operation ID logoutUser

Response 1 of 1

successful operation

Media Type 1 of 2
GET /user/{username}Get user by user name

Operation ID getUserByName

Path Parameters

Parameter Description
username: string The name that needs to be fetched. Use user1 for testing.
Response 1 of 3

successful operation

Media Type 1 of 2
POST /userCreate user

Operation ID createUser

This can only be done by the logged in user.

Request body Required

Created user object

Media Type 1 of 1
Response 1 of 1

successful operation

Media Type 1 of 2
POST /user/createWithArrayCreates list of users with given input array

Operation ID createUsersWithArrayInput

Request body Required

List of user object

Media Type 1 of 1
Response 1 of 1

successful operation

Media Type 1 of 2
POST /user/createWithListCreates list of users with given input array

Operation ID createUsersWithListInput

Request body Required

List of user object

Media Type 1 of 1
Response 1 of 1

successful operation

Media Type 1 of 2
PUT /user/{username}Updated user

Operation ID updateUser

This can only be done by the logged in user.

Path Parameters

Parameter Description
username: string name that need to be updated

Request body Required

Updated user object

Media Type 1 of 1
Response 1 of 2

Invalid user supplied

Media Type 1 of 2
DELETE /user/{username}Delete user

Operation ID deleteUser

This can only be done by the logged in user.

Path Parameters

Parameter Description
username: string The name that needs to be deleted
Response 1 of 2

Invalid username supplied

Media Type 1 of 2
Last updated on

Search documentation

Press Esc to close

Start typing to search the documentation.

Media settings

Choose which providers may load videos automatically across this site. Your choices are stored in this browser.