Find pet by ID
1 min
GET
//petstore.swagger.io/v2/pet/{petId}
Path Parameters
- petIdintegerrequiredDescription
Responses
200
- Pet
- idIdDescription
- categoryCategoryDescription
- idIdDescription
- namestringDescription
- subobjectDescription
- prop1stringDescription
- namestringrequiredExampleDescription
- photoUrlsstring,integer,nullrequiredDescription
- friendPet
- Circular-Reference
- tagsTag[]Description
- idIdDescription
- namestringDescription
- statusstring<available | pending | sold>DescriptionDefaultpending
- petTypestringDescription
- huntingSkillinteger
400
404
405
- Tag
- idIdDescription
- namestringDescription
curl
curl --location '//petstore.swagger.io/v2/pet/8' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json'javascript
var myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Content-Type", "application/json");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("//petstore.swagger.io/v2/pet/8", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));ruby
require "uri"
require "json"
require "net/http"
url = URI("//petstore.swagger.io/v2/pet/8")
http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["Accept"] = "application/json"
request["Content-Type"] = "application/json"
response = http.request(request)
puts response.read_body
python
import requests
import json
url = "//petstore.swagger.io/v2/pet/8"
payload = {}
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
200
// successful operation
{
"id": 0,
"category": {
"id": 0,
"name": "",
"sub": {
"prop1": ""
}
},
"name": "Guru",
"photoUrls": "",
"friend": {
"": ""
},
"tags": [
{
"id": 0,
"name": ""
}
],
"status": "",
"petType": "",
"huntingSkill": 0
}GENERATED
// successful operation
{
"id": 0,
"category": {
"id": 0,
"name": "",
"sub": {
"prop1": ""
}
},
"name": "Guru",
"photoUrls": "",
"friend": {
"": ""
},
"tags": [
{
"id": 0,
"name": ""
}
],
"status": "",
"petType": "",
"huntingSkill": 0
}GENERATED
// successful operation
{
"id": 0,
"category": {
"id": 0,
"name": "",
"sub": {
"prop1": ""
}
},
"name": "Guru",
"photoUrls": "",
"friend": {
"": ""
},
"tags": [
{
"id": 0,
"name": ""
}
],
"status": "",
"petType": "",
"huntingSkill": 0
}GENERATED
// successful operation
{
"id": 0,
"category": {
"id": 0,
"name": "",
"sub": {
"prop1": ""
}
},
"name": "Guru",
"photoUrls": "",
"friend": {
"": ""
},
"tags": [
{
"id": 0,
"name": ""
}
],
"status": "",
"petType": "",
"huntingSkill": 0
}Super Awesome Spren Userww
{"user": "SuperAwesomeSprenUsewww00200r", "readingData": "spren_finger_camera_sdk_reading_data"}400
// Invalid ID supplied
404
// Pet not found
405
// Invalid input
{
"id": 0,
"name": ""
}GENERATED
// Invalid input
{
"id": 0,
"name": ""
}GENERATED
// Invalid input
{
"id": 0,
"name": ""
}GENERATED
// Invalid input
{
"id": 0,
"name": ""
}user
// User example in XML
// https://foo.bar/examples/user-example.xmluse2r
// User example in XML
{
"name": "Fluffy",
"petType": "Cat",
"color": "White",
"gender": "male",
"breed": "Persian"
}Super Awesome Spren User
{"user": "SuperAwesomeSprenUser", "readingData": "spren_finger_camera_sdk_reading_data"}Returns a single pet
Have a question?
Our super-smart AI, knowledgeable support team and an awesome community will get you an answer in a flash.
To ask a question or participate in discussions, you'll need to authenticate first.