NAV
shell javascript python

Swagger Petstore

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.

pet

Add a new pet to the store

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action pet addPet -p category=... -p status=... -p name=... -p tags=... -p photoUrls=... -p id=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["pet", "addPet"]
params = {
    "category": ...,
    "status": ...,
    "name": ...,
    "tags": ...,
    "photoUrls": ...,
    "id": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["pet", "addPet"]
var params = {
    category: ...,
    status: ...,
    name: ...,
    tags: ...,
    photoUrls: ...,
    id: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

POST http://petstore.swagger.io/v2/pet

Request Body

The request body should be a "application/json" encoded object, containing the following items.

ParameterDescription
category
statuspet status in the store
name required
tags
photoUrls required
id

Update an existing pet

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action pet updatePet -p category=... -p status=... -p name=... -p tags=... -p photoUrls=... -p id=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["pet", "updatePet"]
params = {
    "category": ...,
    "status": ...,
    "name": ...,
    "tags": ...,
    "photoUrls": ...,
    "id": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["pet", "updatePet"]
var params = {
    category: ...,
    status: ...,
    name: ...,
    tags: ...,
    photoUrls: ...,
    id: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

PUT http://petstore.swagger.io/v2/pet

Request Body

The request body should be a "application/json" encoded object, containing the following items.

ParameterDescription
category
statuspet status in the store
name required
tags
photoUrls required
id

Finds Pets by status

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action pet findPetsByStatus -p status=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["pet", "findPetsByStatus"]
params = {
    "status": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["pet", "findPetsByStatus"]
var params = {
    status: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

Multiple status values can be provided with comma separated strings

HTTP Request

GET http://petstore.swagger.io/v2/pet/findByStatus

Query Parameters

The following parameters should be included as part of a URL query string.

ParameterDescription
status requiredStatus values that need to be considered for filter

Finds Pets by tags

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action pet findPetsByTags -p tags=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["pet", "findPetsByTags"]
params = {
    "tags": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["pet", "findPetsByTags"]
var params = {
    tags: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

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

HTTP Request

GET http://petstore.swagger.io/v2/pet/findByTags

Query Parameters

The following parameters should be included as part of a URL query string.

ParameterDescription
tags requiredTags to filter by

Find pet by ID

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action pet getPetById -p petId=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["pet", "getPetById"]
params = {
    "petId": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["pet", "getPetById"]
var params = {
    petId: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

Returns a single pet

HTTP Request

GET http://petstore.swagger.io/v2/pet/{petId}

Path Parameters

The following parameters should be included in the URL path.

ParameterDescription
petId requiredID of pet to return

Updates a pet in the store with form data

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action pet updatePetWithForm -p petId=... -p name=... -p status=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["pet", "updatePetWithForm"]
params = {
    "petId": ...,
    "name": ...,
    "status": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["pet", "updatePetWithForm"]
var params = {
    petId: ...,
    name: ...,
    status: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

POST http://petstore.swagger.io/v2/pet/{petId}

Path Parameters

The following parameters should be included in the URL path.

ParameterDescription
petId requiredID of pet that needs to be updated

Request Body

The request body should be a "application/x-www-form-urlencoded" encoded object, containing the following items.

ParameterDescription
nameUpdated name of the pet
statusUpdated status of the pet

Deletes a pet

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action pet deletePet -p api_key=... -p petId=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["pet", "deletePet"]
params = {
    "api_key": ...,
    "petId": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["pet", "deletePet"]
var params = {
    api_key: ...,
    petId: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

DELETE http://petstore.swagger.io/v2/pet/{petId}

Path Parameters

The following parameters should be included in the URL path.

ParameterDescription
petId requiredPet id to delete

Header Parameters

The following parameters should be included as HTTP headers.

ParameterDescription
api_key

uploads an image

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action pet uploadFile -p petId=... -p additionalMetadata=... -p file=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["pet", "uploadFile"]
params = {
    "petId": ...,
    "additionalMetadata": ...,
    "file": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["pet", "uploadFile"]
var params = {
    petId: ...,
    additionalMetadata: ...,
    file: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

POST http://petstore.swagger.io/v2/pet/{petId}/uploadImage

Path Parameters

The following parameters should be included in the URL path.

ParameterDescription
petId requiredID of pet to update

Request Body

The request body should be a "multipart/form-data" encoded object, containing the following items.

ParameterDescription
additionalMetadataAdditional data to pass to server
filefile to upload

store

Returns pet inventories by status

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action store getInventory
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["store", "getInventory"]
result = client.action(document, action)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["store", "getInventory"]
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

Returns a map of status codes to quantities

HTTP Request

GET http://petstore.swagger.io/v2/store/inventory

Place an order for a pet

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action store placeOrder -p status=... -p shipDate=... -p complete=... -p petId=... -p id=... -p quantity=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["store", "placeOrder"]
params = {
    "status": ...,
    "shipDate": ...,
    "complete": ...,
    "petId": ...,
    "id": ...,
    "quantity": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["store", "placeOrder"]
var params = {
    status: ...,
    shipDate: ...,
    complete: ...,
    petId: ...,
    id: ...,
    quantity: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

POST http://petstore.swagger.io/v2/store/order

Request Body

The request body should be a "application/json" encoded object, containing the following items.

ParameterDescription
statusOrder Status
shipDate
complete
petId
id
quantity

Find purchase order by ID

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action store getOrderById -p orderId=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["store", "getOrderById"]
params = {
    "orderId": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["store", "getOrderById"]
var params = {
    orderId: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

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

HTTP Request

GET http://petstore.swagger.io/v2/store/order/{orderId}

Path Parameters

The following parameters should be included in the URL path.

ParameterDescription
orderId requiredID of pet that needs to be fetched

Delete purchase order by ID

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action store deleteOrder -p orderId=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["store", "deleteOrder"]
params = {
    "orderId": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["store", "deleteOrder"]
var params = {
    orderId: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

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

HTTP Request

DELETE http://petstore.swagger.io/v2/store/order/{orderId}

Path Parameters

The following parameters should be included in the URL path.

ParameterDescription
orderId requiredID of the order that needs to be deleted

user

Create user

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action user createUser -p username=... -p firstName=... -p lastName=... -p userStatus=... -p email=... -p phone=... -p password=... -p id=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["user", "createUser"]
params = {
    "username": ...,
    "firstName": ...,
    "lastName": ...,
    "userStatus": ...,
    "email": ...,
    "phone": ...,
    "password": ...,
    "id": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["user", "createUser"]
var params = {
    username: ...,
    firstName: ...,
    lastName: ...,
    userStatus: ...,
    email: ...,
    phone: ...,
    password: ...,
    id: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

This can only be done by the logged in user.

HTTP Request

POST http://petstore.swagger.io/v2/user

Request Body

The request body should be a "application/json" encoded object, containing the following items.

ParameterDescription
username
firstName
lastName
userStatusUser Status
email
phone
password
id

Creates list of users with given input array

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action user createUsersWithArrayInput -p body=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["user", "createUsersWithArrayInput"]
params = {
    "body": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["user", "createUsersWithArrayInput"]
var params = {
    body: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

POST http://petstore.swagger.io/v2/user/createWithArray

Request Body

The request body should be "application/json" encoded, and should contain a single item.

ParameterDescription
body requiredList of user object

Creates list of users with given input array

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action user createUsersWithListInput -p body=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["user", "createUsersWithListInput"]
params = {
    "body": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["user", "createUsersWithListInput"]
var params = {
    body: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

POST http://petstore.swagger.io/v2/user/createWithList

Request Body

The request body should be "application/json" encoded, and should contain a single item.

ParameterDescription
body requiredList of user object

Logs user into the system

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action user loginUser -p username=... -p password=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["user", "loginUser"]
params = {
    "username": ...,
    "password": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["user", "loginUser"]
var params = {
    username: ...,
    password: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

GET http://petstore.swagger.io/v2/user/login

Query Parameters

The following parameters should be included as part of a URL query string.

ParameterDescription
username requiredThe user name for login
password requiredThe password for login in clear text

Logs out current logged in user session

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action user logoutUser
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["user", "logoutUser"]
result = client.action(document, action)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["user", "logoutUser"]
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

GET http://petstore.swagger.io/v2/user/logout

Get user by user name

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action user getUserByName -p username=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["user", "getUserByName"]
params = {
    "username": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["user", "getUserByName"]
var params = {
    username: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

HTTP Request

GET http://petstore.swagger.io/v2/user/{username}

Path Parameters

The following parameters should be included in the URL path.

ParameterDescription
username requiredThe name that needs to be fetched. Use user1 for testing.

Updated user

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action user updateUser -p username=... -p firstName=... -p lastName=... -p userStatus=... -p email=... -p phone=... -p password=... -p id=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["user", "updateUser"]
params = {
    "username": ...,
    "firstName": ...,
    "lastName": ...,
    "userStatus": ...,
    "email": ...,
    "phone": ...,
    "password": ...,
    "id": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["user", "updateUser"]
var params = {
    username: ...,
    firstName: ...,
    lastName: ...,
    userStatus: ...,
    email: ...,
    phone: ...,
    password: ...,
    id: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

This can only be done by the logged in user.

HTTP Request

PUT http://petstore.swagger.io/v2/user/{username}

Path Parameters

The following parameters should be included in the URL path.

ParameterDescription
username requiredname that need to be updated

Request Body

The request body should be a "application/json" encoded object, containing the following items.

ParameterDescription
firstName
lastName
userStatusUser Status
email
phone
password
id

Delete user

# Load the schema document
$ coreapi get http://petstore.swagger.io/v2/swagger.json --format openapi

# Interact with the API endpoint
$ coreapi action user deleteUser -p username=...
import coreapi

# Initialize a client & load the schema document
client = coreapi.Client()
document = client.get("http://petstore.swagger.io/v2/swagger.json", format="openapi")

# Interact with the API endpoint
action = ["user", "deleteUser"]
params = {
    "username": ...
}
result = client.action(document, action, params=params)
var coreapi = window.coreapi

// Initialize a client & load the schema document
var client = new coreapi.Client()
var document = null
client.get("http://petstore.swagger.io/v2/swagger.json").then(function(result) {
    document = result
})

// Interact with the API endpoint
var action = ["user", "deleteUser"]
var params = {
    username: ...
}
client.action(document, action, params=params).then(function(result) {
    // Return value is in 'result'
})

This can only be done by the logged in user.

HTTP Request

DELETE http://petstore.swagger.io/v2/user/{username}

Path Parameters

The following parameters should be included in the URL path.

ParameterDescription
username requiredThe name that needs to be deleted