---
title: Find pet by ID
slug: custom-main-prod/find-pet-by-id
createdAt: 2025-06-24T07:41:50.934Z
---

{
  "id": "GOHqAiiGfiqjmam2jmy62",
  "type": "api-oas-v2",
  "data": {
    "method": "GET",
    "url": "//petstore.swagger.io/v2/pet/{petId}",
    "servers": [
      {
        "url": "//petstore.swagger.io/v2/pet/{petId}",
        "description": "Default server"
      },
      {
        "url": "//petstore.swagger.io/sandbox/pet/{petId}",
        "description": "Sandbox server"
      }
    ],
    "name": "Find pet by ID",
    "description": "Returns a single pet",
    "contentType": "application/json",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "petId",
          "type": "integer<int64>",
          "description": "<p>Warning: Deprecated\nID of pet to return</p>",
          "deprecated": true
        }
      ],
      "headerParameters": [],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [],
      "oAuthParameters": [
        {
          "id": "api_key",
          "name": "api_key",
          "kind": "optional",
          "type": "apiKey",
          "description": "<p>For this sample, you can use the api key <code>special-key</code> to test the authorization filters.</p>",
          "in": "header"
        }
      ]
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "successful operation",
        "jsonExample": "",
        "isExpanded": true,
        "subExamples": [
          {
            "label": "Super Awesome Spren Userww",
            "code": "{\"user\": \"SuperAwesomeSprenUsewww00200r\", \"readingData\": \"spren_finger_camera_sdk_reading_data\"}"
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Pet",
            "schema": [
              {
                "name": "id",
                "kind": "optional",
                "type": "integer",
                "readOnly": true,
                "description": "Pet ID",
                "modelRef": "#/components/schemas/Id",
                "customType": "Id",
                "schema": []
              },
              {
                "name": "category",
                "kind": "optional",
                "type": "object",
                "description": "Categories this pet belongs to",
                "modelRef": "#/components/schemas/Category",
                "customType": "Category",
                "schema": [
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "integer",
                    "readOnly": true,
                    "description": "Category ID",
                    "modelRef": "#/components/schemas/Id",
                    "customType": "Id",
                    "schema": []
                  },
                  {
                    "name": "name",
                    "kind": "optional",
                    "type": "string",
                    "description": "Category name",
                    "example": ""
                  },
                  {
                    "name": "sub",
                    "kind": "optional",
                    "type": "object",
                    "description": "Test Sub Category",
                    "example": "",
                    "schema": [
                      {
                        "name": "prop1",
                        "kind": "optional",
                        "type": "string",
                        "description": "Dumb Property",
                        "example": ""
                      }
                    ]
                  }
                ]
              },
              {
                "name": "name",
                "kind": "required",
                "type": "string",
                "description": "The name given to a pet",
                "example": "GuruIsExample",
                "default": "FluffyIsDefault"
              },
              {
                "name": "photoUrls",
                "kind": "required",
                "type": "string,integer,null",
                "description": "The list of URL to a cute photos featuring pet",
                "example": ""
              },
              {
                "name": "friend",
                "kind": "optional",
                "type": "object",
                "description": "",
                "modelRef": "#/components/schemas/Pet",
                "customType": "Pet",
                "schema": [
                  {
                    "name": "",
                    "description": "",
                    "customType": "Circular-Reference"
                  }
                ]
              },
              {
                "name": "tags",
                "kind": "optional",
                "type": "array",
                "description": "Tags attached to the pet",
                "modelRef": "#/components/schemas/Tag",
                "customType": "Tag[]",
                "schema": [
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "integer",
                    "readOnly": true,
                    "description": "Tag ID",
                    "modelRef": "#/components/schemas/Id",
                    "customType": "Id",
                    "schema": []
                  },
                  {
                    "name": "name",
                    "kind": "optional",
                    "type": "string",
                    "description": "Tag name",
                    "example": ""
                  }
                ]
              },
              {
                "name": "status",
                "kind": "optional",
                "type": "string<available | pending | sold>",
                "description": "Pet status in the store",
                "example": "",
                "default": "pending"
              },
              {
                "name": "petType",
                "kind": "optional",
                "type": "string",
                "description": "Type of a pet",
                "example": "k9"
              },
              {
                "name": "huntingSkill",
                "kind": "optional",
                "type": "integer",
                "example": ""
              }
            ],
            "modelRef": "#/components/schemas/Pet",
            "isExpanded": true
          }
        ]
      },
      {
        "statusCode": "400",
        "description": "Invalid ID supplied",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "404",
        "description": "Pet not found",
        "jsonExample": "",
        "isExpanded": true
      },
      {
        "statusCode": "405",
        "description": "Invalid input",
        "jsonExample": "",
        "isExpanded": true,
        "subExamples": [
          {
            "label": "user",
            "code": "// User example in XML\n// https://foo.bar/examples/user-example.xml"
          },
          {
            "label": "use2r",
            "code": "// User example in XML\n{\n  \"name\": \"Fluffy\",\n  \"petType\": \"Cat\",\n  \"color\": \"White\",\n  \"gender\": \"male\",\n  \"breed\": \"Persian\"\n}"
          },
          {
            "label": "Super Awesome Spren User",
            "code": "{\"user\": \"SuperAwesomeSprenUser\", \"readingData\": \"spren_finger_camera_sdk_reading_data\"}"
          }
        ],
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "customType": "Tag",
            "schema": [
              {
                "name": "id",
                "kind": "optional",
                "type": "integer",
                "readOnly": true,
                "description": "Tag ID",
                "modelRef": "#/components/schemas/Id",
                "customType": "Id",
                "schema": []
              },
              {
                "name": "name",
                "kind": "optional",
                "type": "string",
                "description": "Tag name",
                "example": ""
              }
            ],
            "modelRef": "#/components/schemas/Tag",
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url //petstore.swagger.io/v2/pet/{petId} \\\n     --header 'accept: application/json'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar requestOptions = {\n   method: 'GET',\n   headers: myHeaders,\n   redirect: 'follow'\n};\n\nfetch(\"//petstore.swagger.io/v2/pet/{petId}\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"//petstore.swagger.io/v2/pet/{petId}\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"//petstore.swagger.io/v2/pet/{petId}\"\n\npayload = {}\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"GET\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// successful operation\n{\n  \"id\": 0,\n  \"category\": {\n    \"id\": 0,\n    \"name\": \"\",\n    \"sub\": {\n      \"prop1\": \"\"\n    }\n  },\n  \"name\": \"GuruIsExample\",\n  \"photoUrls\": \"\",\n  \"friend\": {\n    \"\": \"\"\n  },\n  \"tags\": [\n    {\n      \"id\": 0,\n      \"name\": \"\"\n    }\n  ],\n  \"status\": \"\",\n  \"petType\": \"k9\",\n  \"huntingSkill\": 0\n}",
          "subExamples": [
            {
              "label": "GENERATED",
              "code": "// successful operation\n{\n  \"id\": 0,\n  \"category\": {\n    \"id\": 0,\n    \"name\": \"\",\n    \"sub\": {\n      \"prop1\": \"\"\n    }\n  },\n  \"name\": \"GuruIsExample\",\n  \"photoUrls\": \"\",\n  \"friend\": {\n    \"\": \"\"\n  },\n  \"tags\": [\n    {\n      \"id\": 0,\n      \"name\": \"\"\n    }\n  ],\n  \"status\": \"\",\n  \"petType\": \"k9\",\n  \"huntingSkill\": 0\n}"
            },
            {
              "label": "Super Awesome Spren Userww",
              "code": "{\"user\": \"SuperAwesomeSprenUsewww00200r\", \"readingData\": \"spren_finger_camera_sdk_reading_data\"}"
            }
          ]
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Invalid ID supplied\n"
        },
        {
          "id": "response-2-404",
          "language": "404",
          "code": "// Pet not found\n"
        },
        {
          "id": "response-3-405",
          "language": "405",
          "code": "// Invalid input\n{\n  \"id\": 0,\n  \"name\": \"\"\n}",
          "subExamples": [
            {
              "label": "GENERATED",
              "code": "// Invalid input\n{\n  \"id\": 0,\n  \"name\": \"\"\n}"
            },
            {
              "label": "user",
              "code": "// User example in XML\n// https://foo.bar/examples/user-example.xml"
            },
            {
              "label": "use2r",
              "code": "// User example in XML\n{\n  \"name\": \"Fluffy\",\n  \"petType\": \"Cat\",\n  \"color\": \"White\",\n  \"gender\": \"male\",\n  \"breed\": \"Persian\"\n}"
            },
            {
              "label": "Super Awesome Spren User",
              "code": "{\"user\": \"SuperAwesomeSprenUser\", \"readingData\": \"spren_finger_camera_sdk_reading_data\"}"
            }
          ]
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "id": "FL-wGNUbl5Tu2V21A-ZHy",
      "type": "paragraph",
      "children": [
        {
          "text": "Returns a single pet"
        }
      ]
    }
  ]
}