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.