---
title: Finds Pets by tags
slug: docs/demo/finds-pets-by-tags
description: Learn how to use the powerful curl command to effortlessly execute a GET request in this informative document. Explore a code example that demonstrates how to specify URL, headers for Accept and Content-Type, and find pets based on tags. Enhance your prog
docTags: 
createdAt: 2022-11-25T15:11:39.000Z
---

{
  "id": "ay2n5JEGrmVRO8FKUoKuw",
  "data": {
    "url": "https://petstore.swagger.io/v2/pet/findByTags",
    "name": "Finds Pets by tags",
    "method": "GET",
    "request": {
      "pathParameters": [],
      "queryParameters": [
        {
          "kind": "required",
          "name": "tags",
          "type": "array",
          "itemType": "string",
          "customType": "string[]",
          "description": "Tags to filter by"
        }
      ],
      "headerParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": []
    },
    "responses": [
      {
        "schema": [
          {
            "kind": "optional",
            "type": "array",
            "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 tag value",
        "jsonExample": ""
      }
    ],
    "contentType": "application/json",
    "description": "<p>Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.</p>",
    "examples": {
      "languages": [
        {
          "id": "9f4VBTKRrvMNZko_cej9m",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request GET \\\n     --url 'https://petstore.swagger.io/v2/pet/findByTags?tags=array' \\\n     --header 'accept: application/json'"
        },
        {
          "id": "_2IthH6fA5BoQRF4dSl0w",
          "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/findByTags?tags=array\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "lKFqdzCNzlclnPuEWx60H",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"https://petstore.swagger.io/v2/pet/findByTags?tags=array\")\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": "B3K5sQqupCPRklTpc_82j",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"https://petstore.swagger.io/v2/pet/findByTags?tags=array\"\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": "9f4VBTKRrvMNZko_cej9m"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// successful operation\n[\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  }\n]"
        },
        {
          "id": "response-1-400",
          "language": "400",
          "code": "// Invalid tag value\n"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "type": "api-oas-v2",
  "children": [
    {
      "text": ""
    }
  ]
}