Skip to main content

Pets API Functions

With these API functions, you can manage the pets in your store's database.

Adding a new pet

Adds a new pet to the store's database.

Endpoint: https://petstore3.swagger.io/api/v3/pet

Operation: POST

Examples

POST "https://petstore3.swagger.io/api/v3/pet" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d '{
"id": 0,
"name": "string",
"category": {
"id": 0,
"name": "string"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}'

Responses

CodeDescription
200Successful operation
400Invalid input
404Pet not found
422Validation exception
defaultUnexpected error
Response example

200: Successful operation

{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}

Parameters

Request body
NameTypeDescription
bodyPet object(Required) The Pet object to add to the store.

Updating an existing pet

Updates an existing pet by its ID.

Endpoint: https://petstore3.swagger.io/api/v3/pet

Operation: PUT

Examples

PUT "https://petstore3.swagger.io/api/v3/pet" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "api_key: <YOUR_API_KEY>" \
-d '{
"id": 210,
"name": "Krypto",
"status": "available"
}'

Responses

CodeDescription
200Successful operation
400Invalid input
404Pet not found
422Validation exception
defaultUnexpected error
Response example

200: Successful operation

{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}

Parameters

Request body
NameTypeDescription
bodyPet object(Required) Pet object to update.

Finding a pet by status

Finds pets by their status.

Endpoint: https://petstore3.swagger.io/api/v3/pet/findByStatus

Operation: GET

Examples

GET "https://petstore3.swagger.io/api/v3/pet/findByStatus?status=available" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

Responses

CodeDescription
200Successful operation
400Invalid input
defaultUnexpected error

Response example

200: Successful operation

[
{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
]

Parameters

Query parameters
NameTypeDescription
statusstringStatus of the pet to find.
Default: available.
Allowed values: available, pending, sold.

Finding pets by tags

Finds pets by their tags.

Endpoint: https://petstore3.swagger.io/api/v3/pet/findByTags

Operation: GET

Examples

GET "https://petstore3.swagger.io/api/v3/pet/findByTags?tags=string" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

Responses

CodeDescription
200Successful operation
400Invalid input
defaultUnexpected error
Response example

200: Successful operation

[
{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
]

Parameters

Query parameters
NameTypeDescription
tagsarrayTags to filter by.
Default: [].
Allowed values: Any valid tag names.

Finding a pet by Id

Finds a pet by its unique ID.

Endpoint: https://petstore3.swagger.io/api/v3/pet/{petId}

Operation: GET

Examples

GET "https://petstore3.swagger.io/api/v3/pet/210" \
-H "accept: application/json" \
-H "api_key: <YOUR_API_KEY>"

Responses

CodeDescription
200Successful operation
400Invalid ID supplied
404Pet not found
defaultUnexpected error

Response example

200: Successful operation

{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}

Parameters

Path p1arameters
NameTypeDescription
petIdintegerID of pet to return

Updating a pet with form data

Updates a pet in the store with form data.

Endpoint: https://petstore3.swagger.io/api/v3/pet/{petId}

Operation: POST

Examples

POST "https://petstore3.swagger.io/api/v3/pet/210" \
-H "api_key: <YOUR_API_KEY>" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "name=Krypto" \
--data-urlencode "status=available"

Responses

CodeDescription
200Successful operation
405Invalid input
defaultUnexpected error
Response example

200: Successful operation

{
"id": 210,
"name": "Krypto",
"category": {
"id": 1,
"name": "Dogs"
},
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}

Parameters

Path parameters
NameTypeDescription
petIdintegerID of pet to update
Query parameters
NameTypeDescription
namestringName of pet to update
statusstringStatus of pet to update

Deleting a pet

Deletes a pet from the database.

Endpoint: https://petstore3.swagger.io/api/v3/pet/{petId}

Operation: DELETE

Examples

DELETE "https://petstore3.swagger.io/api/v3/pet/210" \
-H "api_key: <YOUR_API_KEY>"

Responses

CodeDescription
200Pet deleted
400Invalid ID supplied
404Pet not found

(A successful deletion returns a 200 code with no response body.)

Parameters

Path parameters
NameTypeDescription
petIdintegerID of pet to delete

Uploading an image

Uploads an image for a pet.

Endpoint: https://petstore3.swagger.io/api/v3/pet/{petId}/uploadImage

Operation: POST

Examples

POST "https://petstore3.swagger.io/api/v3/pet/210/uploadImage" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-H "api_key: <YOUR_API_KEY>" \
--form "file=@/path/to/your/file"

Responses

CodeDescription
200Successful operation
defaultUnexpected error
Response examples

200: Successful operation

{
"code": 200,
"type": "unknown",
"message": "additional data"
}

Parameters

Path parameters
NameTypeDescription
petIdintegerID of pet to update
Form data parameters
NameTypeDescription
additionalMetadatastringExtra data to pass to server.
filefileFile to upload.