| title | language_tabs | toc_footers | includes | search | highlight_theme | headingLevel | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Swagger Petstore |
|
|
true |
darkula |
2 |
Scroll down for code samples, example requests and responses. Select a language for code samples from the tabs above or the mobile navigation menu.
This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on irc.freenode.net, #swagger. For this sample, you can use the api key special-key to test the authorization filters.
Base URLs:
Terms of service Email: Support License: Apache 2.0
- API Key (api_key)
- Parameter Name: api_key, in: header.
-
oAuth2 authentication.
- Flow: implicit
- Authorization URL = https://petstore.swagger.io/oauth/authorize
| Scope | Scope Description |
|---|---|
| read:pets | read your pets |
| write:pets | modify pets in your account |
Everything about your Pets
Code samples
# You can also use wget
curl -X GET https://petstore.swagger.io/v2/pet/{petId} \
-H 'Accept: application/json' \
-H 'api_key: API_KEY'
GET https://petstore.swagger.io/v2/pet/{petId} HTTP/1.1
Host: petstore.swagger.io
Accept: application/json
var headers = {
'Accept':'application/json',
'api_key':'API_KEY'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/pet/{petId}',
method: 'get',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const headers = {
'Accept':'application/json',
'api_key':'API_KEY'
};
fetch('https://petstore.swagger.io/v2/pet/{petId}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Accept' => 'application/json',
'api_key' => 'API_KEY'
}
result = RestClient.get 'https://petstore.swagger.io/v2/pet/{petId}',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Accept': 'application/json',
'api_key': 'API_KEY'
}
r = requests.get('https://petstore.swagger.io/v2/pet/{petId}', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/pet/{petId}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
"api_key": []string{"API_KEY"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://petstore.swagger.io/v2/pet/{petId}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}GET /pet/{petId}
Find pet by ID
Returns a single pet
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| petId | path | integer(int64) | true | ID of pet to return |
Example responses
200 Response
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}<?xml version="1.0" encoding="UTF-8" ?>
<Pet>
<id>0</id>
<category>
<id>0</id>
<name>string</name>
</category>
<name>doggie</name>
<photoUrls>string</photoUrls>
<tags>
<id>0</id>
<name>string</name>
</tags>
<status>available</status>
</Pet>| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | successful operation | Pet |
| 400 | Bad Request | Invalid ID supplied | None |
| 404 | Not Found | Pet not found | None |
Code samples
# You can also use wget
curl -X POST https://petstore.swagger.io/v2/pet/{petId} \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Bearer {access-token}'
POST https://petstore.swagger.io/v2/pet/{petId} HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/x-www-form-urlencoded
var headers = {
'Content-Type':'application/x-www-form-urlencoded',
'Authorization':'Bearer {access-token}'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/pet/{petId}',
method: 'post',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const inputBody = '{
"name": "string",
"status": "string"
}';
const headers = {
'Content-Type':'application/x-www-form-urlencoded',
'Authorization':'Bearer {access-token}'
};
fetch('https://petstore.swagger.io/v2/pet/{petId}',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.post 'https://petstore.swagger.io/v2/pet/{petId}',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer {access-token}'
}
r = requests.post('https://petstore.swagger.io/v2/pet/{petId}', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/pet/{petId}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/x-www-form-urlencoded"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "https://petstore.swagger.io/v2/pet/{petId}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}POST /pet/{petId}
Updates a pet in the store with form data
Body parameter
name: string
status: string
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| petId | path | integer(int64) | true | ID of pet that needs to be updated |
| body | body | object | false | none |
| » name | body | string | false | Updated name of the pet |
| » status | body | string | false | Updated status of the pet |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 405 | Method Not Allowed | Invalid input | None |
Code samples
# You can also use wget
curl -X DELETE https://petstore.swagger.io/v2/pet/{petId} \
-H 'api_key: string' \
-H 'Authorization: Bearer {access-token}'
DELETE https://petstore.swagger.io/v2/pet/{petId} HTTP/1.1
Host: petstore.swagger.io
api_key: string
var headers = {
'api_key':'string',
'Authorization':'Bearer {access-token}'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/pet/{petId}',
method: 'delete',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const headers = {
'api_key':'string',
'Authorization':'Bearer {access-token}'
};
fetch('https://petstore.swagger.io/v2/pet/{petId}',
{
method: 'DELETE',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'api_key' => 'string',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.delete 'https://petstore.swagger.io/v2/pet/{petId}',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'api_key': 'string',
'Authorization': 'Bearer {access-token}'
}
r = requests.delete('https://petstore.swagger.io/v2/pet/{petId}', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/pet/{petId}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("DELETE");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"api_key": []string{"string"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("DELETE", "https://petstore.swagger.io/v2/pet/{petId}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}DELETE /pet/{petId}
Deletes a pet
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| api_key | header | string | false | none |
| petId | path | integer(int64) | true | Pet id to delete |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 400 | Bad Request | Invalid ID supplied | None |
| 404 | Not Found | Pet not found | None |
Code samples
# You can also use wget
curl -X POST https://petstore.swagger.io/v2/pet/{petId}/uploadImage \
-H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access-token}'
POST https://petstore.swagger.io/v2/pet/{petId}/uploadImage HTTP/1.1
Host: petstore.swagger.io
Content-Type: multipart/form-data
Accept: application/json
var headers = {
'Content-Type':'multipart/form-data',
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/pet/{petId}/uploadImage',
method: 'post',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const inputBody = '{
"additionalMetadata": "string",
"file": "string"
}';
const headers = {
'Content-Type':'multipart/form-data',
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('https://petstore.swagger.io/v2/pet/{petId}/uploadImage',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'multipart/form-data',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.post 'https://petstore.swagger.io/v2/pet/{petId}/uploadImage',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Content-Type': 'multipart/form-data',
'Accept': 'application/json',
'Authorization': 'Bearer {access-token}'
}
r = requests.post('https://petstore.swagger.io/v2/pet/{petId}/uploadImage', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/pet/{petId}/uploadImage");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"multipart/form-data"},
"Accept": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "https://petstore.swagger.io/v2/pet/{petId}/uploadImage", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}POST /pet/{petId}/uploadImage
uploads an image
Body parameter
additionalMetadata: string
file: string
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| petId | path | integer(int64) | true | ID of pet to update |
| body | body | object | false | none |
| » additionalMetadata | body | string | false | Additional data to pass to server |
| » file | body | string(binary) | false | file to upload |
Example responses
200 Response
{
"code": 0,
"type": "string",
"message": "string"
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | successful operation | ApiResponse |
Code samples
# You can also use wget
curl -X POST https://petstore.swagger.io/v2/pet \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {access-token}'
POST https://petstore.swagger.io/v2/pet HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
var headers = {
'Content-Type':'application/json',
'Authorization':'Bearer {access-token}'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/pet',
method: 'post',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const inputBody = '{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}';
const headers = {
'Content-Type':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('https://petstore.swagger.io/v2/pet',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.post 'https://petstore.swagger.io/v2/pet',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {access-token}'
}
r = requests.post('https://petstore.swagger.io/v2/pet', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/pet");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "https://petstore.swagger.io/v2/pet", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}POST /pet
Add a new pet to the store
Body parameter
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}<?xml version="1.0" encoding="UTF-8" ?>
<Pet>
<id>0</id>
<category>
<id>0</id>
<name>string</name>
</category>
<name>doggie</name>
<photoUrls>string</photoUrls>
<tags>
<id>0</id>
<name>string</name>
</tags>
<status>available</status>
</Pet>| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | Pet | true | Pet object that needs to be added to the store |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 405 | Method Not Allowed | Invalid input | None |
Code samples
# You can also use wget
curl -X PUT https://petstore.swagger.io/v2/pet \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {access-token}'
PUT https://petstore.swagger.io/v2/pet HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
var headers = {
'Content-Type':'application/json',
'Authorization':'Bearer {access-token}'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/pet',
method: 'put',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const inputBody = '{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}';
const headers = {
'Content-Type':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('https://petstore.swagger.io/v2/pet',
{
method: 'PUT',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.put 'https://petstore.swagger.io/v2/pet',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {access-token}'
}
r = requests.put('https://petstore.swagger.io/v2/pet', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/pet");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("PUT");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("PUT", "https://petstore.swagger.io/v2/pet", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}PUT /pet
Update an existing pet
Body parameter
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}<?xml version="1.0" encoding="UTF-8" ?>
<Pet>
<id>0</id>
<category>
<id>0</id>
<name>string</name>
</category>
<name>doggie</name>
<photoUrls>string</photoUrls>
<tags>
<id>0</id>
<name>string</name>
</tags>
<status>available</status>
</Pet>| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | Pet | true | Pet object that needs to be added to the store |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 400 | Bad Request | Invalid ID supplied | None |
| 404 | Not Found | Pet not found | None |
| 405 | Method Not Allowed | Validation exception | None |
Code samples
# You can also use wget
curl -X GET https://petstore.swagger.io/v2/pet/findByStatus?status=available \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access-token}'
GET https://petstore.swagger.io/v2/pet/findByStatus?status=available HTTP/1.1
Host: petstore.swagger.io
Accept: application/json
var headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/pet/findByStatus',
method: 'get',
data: '?status=available',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('https://petstore.swagger.io/v2/pet/findByStatus?status=available',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.get 'https://petstore.swagger.io/v2/pet/findByStatus',
params: {
'status' => 'array[string]'
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {access-token}'
}
r = requests.get('https://petstore.swagger.io/v2/pet/findByStatus', params={
'status': [
"available"
]
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/pet/findByStatus?status=available");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://petstore.swagger.io/v2/pet/findByStatus", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}GET /pet/findByStatus
Finds Pets by status
Multiple status values can be provided with comma separated strings
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| status | query | array[string] | true | Status values that need to be considered for filter |
| Parameter | Value |
|---|---|
| status | available |
| status | pending |
| status | sold |
Example responses
200 Response
[
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
]<?xml version="1.0" encoding="UTF-8" ?>
<id>0</id>
<category>
<id>0</id>
<name>string</name>
</category>
<name>doggie</name>
<photoUrls>string</photoUrls>
<tags>
<id>0</id>
<name>string</name>
</tags>
<status>available</status>| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | successful operation | Inline |
| 400 | Bad Request | Invalid status value | None |
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| anonymous | [Pet] | false | none | none |
| » id | integer(int64) | false | none | none |
| » category | Category | false | none | none |
| »» id | integer(int64) | false | none | none |
| »» name | string | false | none | none |
| » name | string | true | none | none |
| » photoUrls | [string] | true | none | none |
| » tags | [Tag] | false | none | none |
| »» id | integer(int64) | false | none | none |
| »» name | string | false | none | none |
| » status | string | false | none | pet status in the store |
| Property | Value |
|---|---|
| status | available |
| status | pending |
| status | sold |
Code samples
# You can also use wget
curl -X GET https://petstore.swagger.io/v2/pet/findByTags?tags=string \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access-token}'
GET https://petstore.swagger.io/v2/pet/findByTags?tags=string HTTP/1.1
Host: petstore.swagger.io
Accept: application/json
var headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/pet/findByTags',
method: 'get',
data: '?tags=string',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const headers = {
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('https://petstore.swagger.io/v2/pet/findByTags?tags=string',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.get 'https://petstore.swagger.io/v2/pet/findByTags',
params: {
'tags' => 'array[string]'
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {access-token}'
}
r = requests.get('https://petstore.swagger.io/v2/pet/findByTags', params={
'tags': [
"string"
]
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/pet/findByTags?tags=string");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://petstore.swagger.io/v2/pet/findByTags", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}GET /pet/findByTags
Finds Pets by tags
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| tags | query | array[string] | true | Tags to filter by |
Example responses
200 Response
[
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
]<?xml version="1.0" encoding="UTF-8" ?>
<id>0</id>
<category>
<id>0</id>
<name>string</name>
</category>
<name>doggie</name>
<photoUrls>string</photoUrls>
<tags>
<id>0</id>
<name>string</name>
</tags>
<status>available</status>| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | successful operation | Inline |
| 400 | Bad Request | Invalid tag value | None |
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| anonymous | [Pet] | false | none | none |
| » id | integer(int64) | false | none | none |
| » category | Category | false | none | none |
| »» id | integer(int64) | false | none | none |
| »» name | string | false | none | none |
| » name | string | true | none | none |
| » photoUrls | [string] | true | none | none |
| » tags | [Tag] | false | none | none |
| »» id | integer(int64) | false | none | none |
| »» name | string | false | none | none |
| » status | string | false | none | pet status in the store |
| Property | Value |
|---|---|
| status | available |
| status | pending |
| status | sold |
Access to Petstore orders
Code samples
# You can also use wget
curl -X GET https://petstore.swagger.io/v2/store/inventory \
-H 'Accept: application/json' \
-H 'api_key: API_KEY'
GET https://petstore.swagger.io/v2/store/inventory HTTP/1.1
Host: petstore.swagger.io
Accept: application/json
var headers = {
'Accept':'application/json',
'api_key':'API_KEY'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/store/inventory',
method: 'get',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const headers = {
'Accept':'application/json',
'api_key':'API_KEY'
};
fetch('https://petstore.swagger.io/v2/store/inventory',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Accept' => 'application/json',
'api_key' => 'API_KEY'
}
result = RestClient.get 'https://petstore.swagger.io/v2/store/inventory',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Accept': 'application/json',
'api_key': 'API_KEY'
}
r = requests.get('https://petstore.swagger.io/v2/store/inventory', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/store/inventory");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
"api_key": []string{"API_KEY"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://petstore.swagger.io/v2/store/inventory", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}GET /store/inventory
Returns pet inventories by status
Returns a map of status codes to quantities
Example responses
200 Response
{
"property1": 0,
"property2": 0
}| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | successful operation | Inline |
Status Code 200
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| » additionalProperties | integer(int32) | false | none | none |
Code samples
# You can also use wget
curl -X GET https://petstore.swagger.io/v2/store/order/{orderId} \
-H 'Accept: application/json'
GET https://petstore.swagger.io/v2/store/order/{orderId} HTTP/1.1
Host: petstore.swagger.io
Accept: application/json
var headers = {
'Accept':'application/json'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/store/order/{orderId}',
method: 'get',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const headers = {
'Accept':'application/json'
};
fetch('https://petstore.swagger.io/v2/store/order/{orderId}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Accept' => 'application/json'
}
result = RestClient.get 'https://petstore.swagger.io/v2/store/order/{orderId}',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://petstore.swagger.io/v2/store/order/{orderId}', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/store/order/{orderId}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://petstore.swagger.io/v2/store/order/{orderId}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}GET /store/order/{orderId}
Find purchase order by ID
For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| orderId | path | integer(int64) | true | ID of pet that needs to be fetched |
Example responses
200 Response
{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2019-11-25T16:09:47Z",
"status": "placed",
"complete": true
}<?xml version="1.0" encoding="UTF-8" ?>
<Order>
<id>0</id>
<petId>0</petId>
<quantity>0</quantity>
<shipDate>2019-11-25T16:09:47Z</shipDate>
<status>placed</status>
<complete>true</complete>
</Order>| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | successful operation | Order |
| 400 | Bad Request | Invalid ID supplied | None |
| 404 | Not Found | Order not found | None |
Code samples
# You can also use wget
curl -X DELETE https://petstore.swagger.io/v2/store/order/{orderId}
DELETE https://petstore.swagger.io/v2/store/order/{orderId} HTTP/1.1
Host: petstore.swagger.io
$.ajax({
url: 'https://petstore.swagger.io/v2/store/order/{orderId}',
method: 'delete',
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
fetch('https://petstore.swagger.io/v2/store/order/{orderId}',
{
method: 'DELETE'
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
result = RestClient.delete 'https://petstore.swagger.io/v2/store/order/{orderId}',
params: {
}
p JSON.parse(result)import requests
r = requests.delete('https://petstore.swagger.io/v2/store/order/{orderId}', params={
)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/store/order/{orderId}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("DELETE");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("DELETE", "https://petstore.swagger.io/v2/store/order/{orderId}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}DELETE /store/order/{orderId}
Delete purchase order by ID
For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| orderId | path | integer(int64) | true | ID of the order that needs to be deleted |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 400 | Bad Request | Invalid ID supplied | None |
| 404 | Not Found | Order not found | None |
Code samples
# You can also use wget
curl -X POST https://petstore.swagger.io/v2/store/order \
-H 'Content-Type: application/json' \
-H 'Accept: application/json'
POST https://petstore.swagger.io/v2/store/order HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
Accept: application/json
var headers = {
'Content-Type':'application/json',
'Accept':'application/json'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/store/order',
method: 'post',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const inputBody = '{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2019-11-25T16:09:47Z",
"status": "placed",
"complete": true
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/json'
};
fetch('https://petstore.swagger.io/v2/store/order',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
result = RestClient.post 'https://petstore.swagger.io/v2/store/order',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
r = requests.post('https://petstore.swagger.io/v2/store/order', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/store/order");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
"Accept": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "https://petstore.swagger.io/v2/store/order", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}POST /store/order
Place an order for a pet
Body parameter
{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2019-11-25T16:09:47Z",
"status": "placed",
"complete": true
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | Order | true | order placed for purchasing the pet |
Example responses
200 Response
{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2019-11-25T16:09:47Z",
"status": "placed",
"complete": true
}<?xml version="1.0" encoding="UTF-8" ?>
<Order>
<id>0</id>
<petId>0</petId>
<quantity>0</quantity>
<shipDate>2019-11-25T16:09:47Z</shipDate>
<status>placed</status>
<complete>true</complete>
</Order>| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | successful operation | Order |
| 400 | Bad Request | Invalid Order | None |
Operations about user
Code samples
# You can also use wget
curl -X POST https://petstore.swagger.io/v2/user \
-H 'Content-Type: application/json'
POST https://petstore.swagger.io/v2/user HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
var headers = {
'Content-Type':'application/json'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/user',
method: 'post',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const inputBody = '{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}';
const headers = {
'Content-Type':'application/json'
};
fetch('https://petstore.swagger.io/v2/user',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json'
}
result = RestClient.post 'https://petstore.swagger.io/v2/user',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Content-Type': 'application/json'
}
r = requests.post('https://petstore.swagger.io/v2/user', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/user");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "https://petstore.swagger.io/v2/user", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}POST /user
Create user
This can only be done by the logged in user.
Body parameter
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | User | true | Created user object |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| default | Default | successful operation | None |
Code samples
# You can also use wget
curl -X POST https://petstore.swagger.io/v2/user/createWithArray \
-H 'Content-Type: application/json'
POST https://petstore.swagger.io/v2/user/createWithArray HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
var headers = {
'Content-Type':'application/json'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/user/createWithArray',
method: 'post',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const inputBody = '[
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}
]';
const headers = {
'Content-Type':'application/json'
};
fetch('https://petstore.swagger.io/v2/user/createWithArray',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json'
}
result = RestClient.post 'https://petstore.swagger.io/v2/user/createWithArray',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Content-Type': 'application/json'
}
r = requests.post('https://petstore.swagger.io/v2/user/createWithArray', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/user/createWithArray");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "https://petstore.swagger.io/v2/user/createWithArray", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}POST /user/createWithArray
Creates list of users with given input array
Body parameter
[
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}
]| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | UserArray | true | List of user object |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| default | Default | successful operation | None |
Code samples
# You can also use wget
curl -X POST https://petstore.swagger.io/v2/user/createWithList \
-H 'Content-Type: application/json'
POST https://petstore.swagger.io/v2/user/createWithList HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
var headers = {
'Content-Type':'application/json'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/user/createWithList',
method: 'post',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const inputBody = '[
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}
]';
const headers = {
'Content-Type':'application/json'
};
fetch('https://petstore.swagger.io/v2/user/createWithList',
{
method: 'POST',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json'
}
result = RestClient.post 'https://petstore.swagger.io/v2/user/createWithList',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Content-Type': 'application/json'
}
r = requests.post('https://petstore.swagger.io/v2/user/createWithList', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/user/createWithList");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "https://petstore.swagger.io/v2/user/createWithList", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}POST /user/createWithList
Creates list of users with given input array
Body parameter
[
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}
]| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | UserArray | true | List of user object |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| default | Default | successful operation | None |
Code samples
# You can also use wget
curl -X GET https://petstore.swagger.io/v2/user/{username} \
-H 'Accept: application/json'
GET https://petstore.swagger.io/v2/user/{username} HTTP/1.1
Host: petstore.swagger.io
Accept: application/json
var headers = {
'Accept':'application/json'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/user/{username}',
method: 'get',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const headers = {
'Accept':'application/json'
};
fetch('https://petstore.swagger.io/v2/user/{username}',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Accept' => 'application/json'
}
result = RestClient.get 'https://petstore.swagger.io/v2/user/{username}',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://petstore.swagger.io/v2/user/{username}', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/user/{username}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://petstore.swagger.io/v2/user/{username}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}GET /user/{username}
Get user by user name
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| username | path | string | true | The name that needs to be fetched. Use user1 for testing. |
Example responses
200 Response
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}<?xml version="1.0" encoding="UTF-8" ?>
<User>
<id>0</id>
<username>string</username>
<firstName>string</firstName>
<lastName>string</lastName>
<email>string</email>
<password>string</password>
<phone>string</phone>
<userStatus>0</userStatus>
</User>| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | successful operation | User |
| 400 | Bad Request | Invalid username supplied | None |
| 404 | Not Found | User not found | None |
Code samples
# You can also use wget
curl -X PUT https://petstore.swagger.io/v2/user/{username} \
-H 'Content-Type: application/json'
PUT https://petstore.swagger.io/v2/user/{username} HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
var headers = {
'Content-Type':'application/json'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/user/{username}',
method: 'put',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const inputBody = '{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}';
const headers = {
'Content-Type':'application/json'
};
fetch('https://petstore.swagger.io/v2/user/{username}',
{
method: 'PUT',
body: inputBody,
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Content-Type' => 'application/json'
}
result = RestClient.put 'https://petstore.swagger.io/v2/user/{username}',
params: {
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Content-Type': 'application/json'
}
r = requests.put('https://petstore.swagger.io/v2/user/{username}', params={
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/user/{username}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("PUT");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Content-Type": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("PUT", "https://petstore.swagger.io/v2/user/{username}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}PUT /user/{username}
Updated user
This can only be done by the logged in user.
Body parameter
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}| Name | In | Type | Required | Description |
|---|---|---|---|---|
| username | path | string | true | name that need to be updated |
| body | body | User | true | Updated user object |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 400 | Bad Request | Invalid user supplied | None |
| 404 | Not Found | User not found | None |
Code samples
# You can also use wget
curl -X DELETE https://petstore.swagger.io/v2/user/{username}
DELETE https://petstore.swagger.io/v2/user/{username} HTTP/1.1
Host: petstore.swagger.io
$.ajax({
url: 'https://petstore.swagger.io/v2/user/{username}',
method: 'delete',
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
fetch('https://petstore.swagger.io/v2/user/{username}',
{
method: 'DELETE'
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
result = RestClient.delete 'https://petstore.swagger.io/v2/user/{username}',
params: {
}
p JSON.parse(result)import requests
r = requests.delete('https://petstore.swagger.io/v2/user/{username}', params={
)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/user/{username}");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("DELETE");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("DELETE", "https://petstore.swagger.io/v2/user/{username}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}DELETE /user/{username}
Delete user
This can only be done by the logged in user.
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| username | path | string | true | The name that needs to be deleted |
| Status | Meaning | Description | Schema |
|---|---|---|---|
| 400 | Bad Request | Invalid username supplied | None |
| 404 | Not Found | User not found | None |
Code samples
# You can also use wget
curl -X GET https://petstore.swagger.io/v2/user/login?username=string&password=string \
-H 'Accept: application/json'
GET https://petstore.swagger.io/v2/user/login?username=string&password=string HTTP/1.1
Host: petstore.swagger.io
Accept: application/json
var headers = {
'Accept':'application/json'
};
$.ajax({
url: 'https://petstore.swagger.io/v2/user/login',
method: 'get',
data: '?username=string&password=string',
headers: headers,
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
const headers = {
'Accept':'application/json'
};
fetch('https://petstore.swagger.io/v2/user/login?username=string&password=string',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Accept' => 'application/json'
}
result = RestClient.get 'https://petstore.swagger.io/v2/user/login',
params: {
'username' => 'string',
'password' => 'string'
}, headers: headers
p JSON.parse(result)import requests
headers = {
'Accept': 'application/json'
}
r = requests.get('https://petstore.swagger.io/v2/user/login', params={
'username': 'string', 'password': 'string'
}, headers = headers)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/user/login?username=string&password=string");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
headers := map[string][]string{
"Accept": []string{"application/json"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://petstore.swagger.io/v2/user/login", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}GET /user/login
Logs user into the system
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| username | query | string | true | The user name for login |
| password | query | string | true | The password for login in clear text |
Example responses
200 Response
"string"| Status | Meaning | Description | Schema |
|---|---|---|---|
| 200 | OK | successful operation | string |
| 400 | Bad Request | Invalid username/password supplied | None |
| Status | Header | Type | Format | Description |
|---|---|---|---|---|
| 200 | X-Expires-After | string | date-time | date in UTC when token expires |
| 200 | X-Rate-Limit | integer | int32 | calls per hour allowed by the user |
Code samples
# You can also use wget
curl -X GET https://petstore.swagger.io/v2/user/logout
GET https://petstore.swagger.io/v2/user/logout HTTP/1.1
Host: petstore.swagger.io
$.ajax({
url: 'https://petstore.swagger.io/v2/user/logout',
method: 'get',
success: function(data) {
console.log(JSON.stringify(data));
}
})const fetch = require('node-fetch');
fetch('https://petstore.swagger.io/v2/user/logout',
{
method: 'GET'
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
result = RestClient.get 'https://petstore.swagger.io/v2/user/logout',
params: {
}
p JSON.parse(result)import requests
r = requests.get('https://petstore.swagger.io/v2/user/logout', params={
)
print r.json()URL obj = new URL("https://petstore.swagger.io/v2/user/logout");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());package main
import (
"bytes"
"net/http"
)
func main() {
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "https://petstore.swagger.io/v2/user/logout", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}GET /user/logout
Logs out current logged in user session
| Status | Meaning | Description | Schema |
|---|---|---|---|
| default | Default | successful operation | None |
{
"id": 0,
"name": "string"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| id | integer(int64) | false | none | none |
| name | string | false | none | none |
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| id | integer(int64) | false | none | none |
| category | Category | false | none | none |
| name | string | true | none | none |
| photoUrls | [string] | true | none | none |
| tags | [Tag] | false | none | none |
| status | string | false | none | pet status in the store |
| Property | Value |
|---|---|
| status | available |
| status | pending |
| status | sold |
{
"id": 0,
"name": "string"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| id | integer(int64) | false | none | none |
| name | string | false | none | none |
{
"code": 0,
"type": "string",
"message": "string"
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| code | integer(int32) | false | none | none |
| type | string | false | none | none |
| message | string | false | none | none |
{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2019-11-25T16:09:47Z",
"status": "placed",
"complete": true
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| id | integer(int64) | false | none | none |
| petId | integer(int64) | false | none | none |
| quantity | integer(int32) | false | none | none |
| shipDate | string(date-time) | false | none | none |
| status | string | false | none | Order Status |
| complete | boolean | false | none | none |
| Property | Value |
|---|---|
| status | placed |
| status | approved |
| status | delivered |
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}
| Name | Type | Required | Restrictions | Description |
|---|---|---|---|---|
| id | integer(int64) | false | none | none |
| username | string | false | none | none |
| firstName | string | false | none | none |
| lastName | string | false | none | none |
| string | false | none | none | |
| password | string | false | none | none |
| phone | string | false | none | none |
| userStatus | integer(int32) | false | none | User Status |