Get user by user name
1 min
GET
//petstore.swagger.io/v2/user/{username}
Path Parameters
- usernamestringrequiredDescription
Responses
200
- User
- idId
- petobject
- Pet
- idIdDescription
- categoryCategoryDescription
- idIdDescription
- namestringDescription
- subobjectDescription
- prop1stringDescription
- namestringrequiredExampleDescriptionDefaultFluffyIsDefault
- photoUrlsstring,integer,nullrequiredDescription
- friendPet
- Circular-Reference
- tagsTag[]Description
- idIdDescription
- namestringDescription
- statusstring<available | pending | sold>DescriptionDefaultpending
- petTypestringExampleDescription
- huntingSkillinteger
- Tag
- idIdDescription
- namestringDescription
- usernamestringExampleDescription
- firstNamestringExampleDescription
- lastNamestringExampleDescription
- emailstring<email>ExampleDescription
- passwordstring<password>ExampleDescription
- phonestringExampleDescription
- userStatusinteger<int32>Description
- imagestringDescription
- addressesstring[]
400
404
curl
curl --request GET \
--url //petstore.swagger.io/v2/user/{username} \
--header 'accept: 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/user/{username}", 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/user/{username}")
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/user/{username}"
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,
"pet": {},
"username": "John78",
"firstName": "John",
"lastName": "Smith",
"email": "[email protected]",
"password": "drowssaP123",
"phone": "+1-202-555-0192",
"userStatus": "",
"image": "",
"addresses": [
""
]
}400
// Invalid username supplied
404
// User not found