Description
Finds Pets by status
Multiple status values can be provided with comma separated strings
Path parameters
None
Query parameters
Name | Type | Description | Required? |
---|---|---|---|
status |
array |
Values:
available
pending
sold
Status values that need to be considered for filter |
true |
Responses
Code | Returns |
---|---|
200 | successful operation |
400 | Invalid status value |
Content types:
-
application/xml
-
application/json
Examples
The example below shows how to request all pets listed as available
. You'll need to install the Requests library into your virtual environment (pip install requests
).
import requests
import json
url = 'http://petstore.swagger.io/v2/pet/findByStatus?status=available'
response = requests.get(url).json()
To display the first three results:
>>> response[:3]
[{'id': 1116,
'category': {'id': 0, 'name': 'string'},
'name': 'doggie',
'photoUrls': ['string'],
'tags': [{'id': 0, 'name': 'string'}],
'status': 'available'},
{'id': 1427504384,
'name': 'Fido',
'photoUrls': [],
'tags': [],
'status': 'available'},
{'id': 1427504385,
'category': {'id': 0, 'name': 'Lions'},
'name': 'Simba',
'photoUrls': ['Simba-photo'],
'tags': [{'id': 0, 'name': 'Sarko'}],
'status': 'available'}]
- In Postman, enter the URL:
http://petstore.swagger.io/v2/pet/findByStatus?status=available
- When you execute the request, the response body will look something like this:
curl -X GET "http://petstore.swagger.io/v2/pet/findByStatus?status=available" -H "accept: application/json" | python -m json.tool
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 3446k 0 3446k 0 0 5989k 0 --:--:-- --:--:-- --:--:-- 5983k
[
{
"category": {
"id": 0,
"name": "string"
},
"id": 1116,
"name": "doggie",
"photoUrls": [
"string"
],
"status": "available",
"tags": [
{
"id": 0,
"name": "string"
}
]
},
{
"id": 1427504384,
"name": "Fido",
"photoUrls": [],
"status": "available",
"tags": []
},
...