---
title: Find pet by ID
slug: docs/demo/find-pet-by-id
description: Learn how to retrieve information about a specific pet from the pet store API using the CURL command. This document provides a code example and shows how to send a GET request with proper headers for accepting and providing JSON format.
docTags: 
createdAt: 2022-11-25T15:11:39.000Z
---

{
  "id": "MjZdnO_SuXmvyKLrOs283",
  "data": {
    "url": "https://petstore.swagger.io/v2/pet/{petId}",
    "name": "Find pet by ID",
    "method": "GET",
    "request": {
      "pathParameters": [
        {
          "kind": "required",
          "name": "petId",
          "type": "integer",
          "description": "ID of pet to return"
        }
      ],
      "queryParameters": [],
      "headerParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": []
    },
    "responses": [
      {
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "schema": [
              {
                "kind": "optional",
                "name": "id",
                "type": "integer<int64>",
                "example": 0
              },
              {
                "kind": "optional",
                "name": "category",
                "type": "object",
                "schema": [
                  {
                    "kind": "optional",
                    "name": "id",
                    "type": "integer<int64>",
                    "example": 0
                  },
                  {
                    "kind": "optional",
                    "name": "name",
                    "type": "string",
                    "example": ""
                  }
                ],
                "modelRef": "#/definitions/Category",
                "customType": "Category"
              },
              {
                "kind": "required",
                "name": "name",
                "type": "string",
                "example": "doggie"
              },
              {
                "kind": "required",
                "name": "photoUrls",
                "type": "array",
                "example": [],
                "itemType": "string",
                "customType": "string[]",
                "itemExample": ""
              },
              {
                "kind": "optional",
                "name": "tags",
                "type": "array",
                "schema": [
                  {
                    "kind": "optional",
                    "name": "id",
                    "type": "integer<int64>",
                    "example": 0
                  },
                  {
                    "kind": "optional",
                    "name": "name",
                    "type": "string",
                    "example": ""
                  }
                ],
                "modelRef": "#/definitions/Tag",
                "customType": "Tag[]"
              },
              {
                "kind": "optional",
                "name": "status",
                "type": "string<available | pending | sold>",
                "example": "",
                "description": "pet status in the store"
              }
            ],
            "modelRef": "#/definitions/Pet",
            "customType": "Pet",
            "isExpanded": true
          }
        ],
        "isExpanded": true,
        "statusCode": "200",
        "description": "successful operation",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "400",
        "description": "Invalid ID supplied",
        "jsonExample": ""
      },
      {
        "isExpanded": true,
        "statusCode": "404",
        "description": "Pet not found",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "Returns a single pet",
    "examples": {
      "languages": [
        {
          "id": "Vzv1ioDODzGHMVtdhHdQb",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url https://petstore.swagger.io/v2/pet/{petId} \\\n     --header 'accept: application/json'"
        },
        {
          "id": "7TlhyiFmEs5bQsai041cQ",
          "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(\"https://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": "CwOw6YyFsidZ4ikxkTJac",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://petstore.swagger.io/v2/pet/{petId}\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\n\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "lALZcBurpsCq621Sn2C73",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://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": "Vzv1ioDODzGHMVtdhHdQb"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// successful operation\n{\n  \"id\": \"\",\n  \"category\": {\n    \"id\": \"\",\n    \"name\": \"\"\n  },\n  \"name\": \"doggie\",\n  \"photoUrls\": [\n    \"\"\n  ],\n  \"tags\": [\n    {\n      \"id\": \"\",\n      \"name\": \"\"\n    }\n  ],\n  \"status\": \"\"\n}"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Invalid ID supplied\n"
        },
        {
          "id": "response-2-404",
          "language": "404",
          "code": "// Pet not found\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}