Skip to content

Get Pet

The Get Pet endpoint is used to retrieve information about an existing pet from the Petstore system.

This operation returns pet details based on the pet ID provided in the request path.

Endpoint

GET /pet/{petId}

Base URL

https://petstore.swagger.io/v2/pet/{petId}

Path Parameters

Parameter Type Required Description
petId integer Yes Unique identifier of the pet

Request Headers

Header Required Description
accept No Specifies the expected response format
api_key No API key used for authorized requests

Supported Response Formats

The endpoint supports the following response formats:

Content Type Usage
application/json JSON response payload
application/xml XML response payload

Sample Request

curl -X GET "https://petstore.swagger.io/v2/pet/101" \
-H "accept: application/json"
import requests

url = "https://petstore.swagger.io/v2/pet/101"

response = requests.get(url)

print(response.json())
fetch("https://petstore.swagger.io/v2/pet/101", {
  method: "GET",
  headers: {
    "accept": "application/json"
  }
})
.then(response => response.json())
.then(data => console.log(data));

Successful Response

{
  "id": 101,
  "category": {
    "id": 1,
    "name": "Dogs"
  },
  "name": "Rocky",
  "photoUrls": [
    "https://example.com/images/rocky.png"
  ],
  "tags": [
    {
      "id": 10,
      "name": "friendly"
    }
  ],
  "status": "available"
}
<Pet>
  <id>101</id>
  <category>
    <id>1</id>
    <name>Dogs</name>
  </category>
  <name>Rocky</name>
  <photoUrls>
    <photoUrl>https://example.com/images/rocky.png</photoUrl>
  </photoUrls>
  <tags>
    <tag>
      <id>10</id>
      <name>friendly</name>
    </tag>
  </tags>
  <status>available</status>
</Pet>

Response Codes

Status Code Description
200 Pet details retrieved successfully
400 Invalid pet ID supplied
404 Pet not found

Error Response Example

{
  "code": 404,
  "type": "error",
  "message": "Pet not found"
}

Notes

  • The petId value must match an existing pet record.
  • Invalid or non-existing IDs may return an error response.
  • JSON is the preferred response format for most integrations.
  • Authentication may be required for restricted environments or protected resources.