Swagger Petstore v1.0.0
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
Authentication
-
oAuth2 authentication.
- Flow: implicit
- Authorization URL = http://petstore.swagger.io/oauth/dialog
Scope | Scope Description |
---|---|
write:pets | modify pets in your account |
read:pets | read your pets |
- API Key (api_key)
- Parameter Name: api_key, in: header.
pet
Everything about your Pets
addPet
Code samples
# You can also use wget
curl -X POST http://petstore.swagger.io/v2/pet \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {access-token}'
POST http://petstore.swagger.io/v2/pet HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
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('http://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 'http://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('http://petstore.swagger.io/v2/pet', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer {access-token}',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','http://petstore.swagger.io/v2/pet', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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>
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | Pet | true | Pet object that needs to be added to the store |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
405 | Method Not Allowed | Invalid input | None |
updatePet
Code samples
# You can also use wget
curl -X PUT http://petstore.swagger.io/v2/pet \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {access-token}'
PUT http://petstore.swagger.io/v2/pet HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
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('http://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 'http://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('http://petstore.swagger.io/v2/pet', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
'Authorization' => 'Bearer {access-token}',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('PUT','http://petstore.swagger.io/v2/pet', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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>
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | Pet | true | Pet object that needs to be added to the store |
Responses
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 |
findPetsByStatus
Code samples
# You can also use wget
curl -X GET http://petstore.swagger.io/v2/pet/findByStatus?status=available \
-H 'Accept: application/xml' \
-H 'Authorization: Bearer {access-token}'
GET http://petstore.swagger.io/v2/pet/findByStatus?status=available HTTP/1.1
Host: petstore.swagger.io
Accept: application/xml
const headers = {
'Accept':'application/xml',
'Authorization':'Bearer {access-token}'
};
fetch('http://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/xml',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.get 'http://petstore.swagger.io/v2/pet/findByStatus',
params: {
'status' => 'array[string]'
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Accept': 'application/xml',
'Authorization': 'Bearer {access-token}'
}
r = requests.get('http://petstore.swagger.io/v2/pet/findByStatus', params={
'status': [
"available"
]
}, headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/xml',
'Authorization' => 'Bearer {access-token}',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('GET','http://petstore.swagger.io/v2/pet/findByStatus', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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/xml"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "http://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
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
status | query | array[string] | true | Status values that need to be considered for filter |
Enumerated Values
Parameter | Value |
---|---|
status | available |
status | pending |
status | sold |
Example responses
200 Response
<?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>
[
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | Inline |
400 | Bad Request | Invalid status value | None |
Response Schema
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 |
Enumerated Values
Property | Value |
---|---|
status | available |
status | pending |
status | sold |
findPetsByTags
Code samples
# You can also use wget
curl -X GET http://petstore.swagger.io/v2/pet/findByTags?tags=string \
-H 'Accept: application/xml' \
-H 'Authorization: Bearer {access-token}'
GET http://petstore.swagger.io/v2/pet/findByTags?tags=string HTTP/1.1
Host: petstore.swagger.io
Accept: application/xml
const headers = {
'Accept':'application/xml',
'Authorization':'Bearer {access-token}'
};
fetch('http://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/xml',
'Authorization' => 'Bearer {access-token}'
}
result = RestClient.get 'http://petstore.swagger.io/v2/pet/findByTags',
params: {
'tags' => 'array[string]'
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Accept': 'application/xml',
'Authorization': 'Bearer {access-token}'
}
r = requests.get('http://petstore.swagger.io/v2/pet/findByTags', params={
'tags': [
"string"
]
}, headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/xml',
'Authorization' => 'Bearer {access-token}',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('GET','http://petstore.swagger.io/v2/pet/findByTags', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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/xml"},
"Authorization": []string{"Bearer {access-token}"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "http://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
Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
tags | query | array[string] | true | Tags to filter by |
Example responses
200 Response
<?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>
[
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
]
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | Inline |
400 | Bad Request | Invalid tag value | None |
Response Schema
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 |
Enumerated Values
Property | Value |
---|---|
status | available |
status | pending |
status | sold |
getPetById
Code samples
# You can also use wget
curl -X GET http://petstore.swagger.io/v2/pet/{petId} \
-H 'Accept: application/xml' \
-H 'api_key: API_KEY'
GET http://petstore.swagger.io/v2/pet/{petId} HTTP/1.1
Host: petstore.swagger.io
Accept: application/xml
const headers = {
'Accept':'application/xml',
'api_key':'API_KEY'
};
fetch('http://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/xml',
'api_key' => 'API_KEY'
}
result = RestClient.get 'http://petstore.swagger.io/v2/pet/{petId}',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Accept': 'application/xml',
'api_key': 'API_KEY'
}
r = requests.get('http://petstore.swagger.io/v2/pet/{petId}', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/xml',
'api_key' => 'API_KEY',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('GET','http://petstore.swagger.io/v2/pet/{petId}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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/xml"},
"api_key": []string{"API_KEY"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "http://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
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
petId | path | integer(int64) | true | ID of pet to return |
Example responses
200 Response
<?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>
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | Pet |
400 | Bad Request | Invalid ID supplied | None |
404 | Not Found | Pet not found | None |
updatePetWithForm
Code samples
# You can also use wget
curl -X POST http://petstore.swagger.io/v2/pet/{petId} \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Authorization: Bearer {access-token}'
POST http://petstore.swagger.io/v2/pet/{petId} HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/x-www-form-urlencoded
const inputBody = '{
"name": "string",
"status": "string"
}';
const headers = {
'Content-Type':'application/x-www-form-urlencoded',
'Authorization':'Bearer {access-token}'
};
fetch('http://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 'http://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('http://petstore.swagger.io/v2/pet/{petId}', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/x-www-form-urlencoded',
'Authorization' => 'Bearer {access-token}',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','http://petstore.swagger.io/v2/pet/{petId}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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
Parameters
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 |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
405 | Method Not Allowed | Invalid input | None |
deletePet
Code samples
# You can also use wget
curl -X DELETE http://petstore.swagger.io/v2/pet/{petId} \
-H 'api_key: string' \
-H 'Authorization: Bearer {access-token}'
DELETE http://petstore.swagger.io/v2/pet/{petId} HTTP/1.1
Host: petstore.swagger.io
api_key: string
const headers = {
'api_key':'string',
'Authorization':'Bearer {access-token}'
};
fetch('http://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 'http://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('http://petstore.swagger.io/v2/pet/{petId}', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'api_key' => 'string',
'Authorization' => 'Bearer {access-token}',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('DELETE','http://petstore.swagger.io/v2/pet/{petId}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://petstore.swagger.io/v2/pet/{petId}", data)
req.Header = headers
client := &http.Client{}
resp, err := client.Do(req)
// ...
}
DELETE /pet/{petId}
Deletes a pet
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
api_key | header | string | false | none |
petId | path | integer(int64) | true | Pet id to delete |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
400 | Bad Request | Invalid ID supplied | None |
404 | Not Found | Pet not found | None |
uploadFile
Code samples
# You can also use wget
curl -X POST http://petstore.swagger.io/v2/pet/{petId}/uploadImage \
-H 'Content-Type: multipart/form-data' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {access-token}'
POST http://petstore.swagger.io/v2/pet/{petId}/uploadImage HTTP/1.1
Host: petstore.swagger.io
Content-Type: multipart/form-data
Accept: application/json
const inputBody = '{
"additionalMetadata": "string",
"file": "string"
}';
const headers = {
'Content-Type':'multipart/form-data',
'Accept':'application/json',
'Authorization':'Bearer {access-token}'
};
fetch('http://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 'http://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('http://petstore.swagger.io/v2/pet/{petId}/uploadImage', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'multipart/form-data',
'Accept' => 'application/json',
'Authorization' => 'Bearer {access-token}',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','http://petstore.swagger.io/v2/pet/{petId}/uploadImage', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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
Parameters
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"
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | ApiResponse |
store
Access to Petstore orders
getInventory
Code samples
# You can also use wget
curl -X GET http://petstore.swagger.io/v2/store/inventory \
-H 'Accept: application/json' \
-H 'api_key: API_KEY'
GET http://petstore.swagger.io/v2/store/inventory HTTP/1.1
Host: petstore.swagger.io
Accept: application/json
const headers = {
'Accept':'application/json',
'api_key':'API_KEY'
};
fetch('http://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 'http://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('http://petstore.swagger.io/v2/store/inventory', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/json',
'api_key' => 'API_KEY',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('GET','http://petstore.swagger.io/v2/store/inventory', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | Inline |
Response Schema
Status Code 200
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
ยป additionalProperties | integer(int32) | false | none | none |
placeOrder
Code samples
# You can also use wget
curl -X POST http://petstore.swagger.io/v2/store/order \
-H 'Content-Type: application/json' \
-H 'Accept: application/xml'
POST http://petstore.swagger.io/v2/store/order HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
Accept: application/xml
const inputBody = '{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2020-03-30T14:38:05Z",
"status": "placed",
"complete": false
}';
const headers = {
'Content-Type':'application/json',
'Accept':'application/xml'
};
fetch('http://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/xml'
}
result = RestClient.post 'http://petstore.swagger.io/v2/store/order',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json',
'Accept': 'application/xml'
}
r = requests.post('http://petstore.swagger.io/v2/store/order', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
'Accept' => 'application/xml',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','http://petstore.swagger.io/v2/store/order', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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/xml"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("POST", "http://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": "2020-03-30T14:38:05Z",
"status": "placed",
"complete": false
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | Order | true | order placed for purchasing the pet |
Example responses
200 Response
<?xml version="1.0" encoding="UTF-8" ?>
<Order>
<id>0</id>
<petId>0</petId>
<quantity>0</quantity>
<shipDate>2020-03-30T14:38:05Z</shipDate>
<status>placed</status>
<complete>false</complete>
</Order>
{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2020-03-30T14:38:05Z",
"status": "placed",
"complete": false
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | Order |
400 | Bad Request | Invalid Order | None |
getOrderById
Code samples
# You can also use wget
curl -X GET http://petstore.swagger.io/v2/store/order/{orderId} \
-H 'Accept: application/xml'
GET http://petstore.swagger.io/v2/store/order/{orderId} HTTP/1.1
Host: petstore.swagger.io
Accept: application/xml
const headers = {
'Accept':'application/xml'
};
fetch('http://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/xml'
}
result = RestClient.get 'http://petstore.swagger.io/v2/store/order/{orderId}',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Accept': 'application/xml'
}
r = requests.get('http://petstore.swagger.io/v2/store/order/{orderId}', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/xml',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('GET','http://petstore.swagger.io/v2/store/order/{orderId}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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/xml"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "http://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
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
orderId | path | integer(int64) | true | ID of pet that needs to be fetched |
Example responses
200 Response
<?xml version="1.0" encoding="UTF-8" ?>
<Order>
<id>0</id>
<petId>0</petId>
<quantity>0</quantity>
<shipDate>2020-03-30T14:38:05Z</shipDate>
<status>placed</status>
<complete>false</complete>
</Order>
{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2020-03-30T14:38:05Z",
"status": "placed",
"complete": false
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | Order |
400 | Bad Request | Invalid ID supplied | None |
404 | Not Found | Order not found | None |
deleteOrder
Code samples
# You can also use wget
curl -X DELETE http://petstore.swagger.io/v2/store/order/{orderId}
DELETE http://petstore.swagger.io/v2/store/order/{orderId} HTTP/1.1
Host: petstore.swagger.io
fetch('http://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 'http://petstore.swagger.io/v2/store/order/{orderId}',
params: {
}
p JSON.parse(result)
import requests
r = requests.delete('http://petstore.swagger.io/v2/store/order/{orderId}')
print(r.json())
<?php
require 'vendor/autoload.php';
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('DELETE','http://petstore.swagger.io/v2/store/order/{orderId}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
orderId | path | integer(int64) | true | ID of the order that needs to be deleted |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
400 | Bad Request | Invalid ID supplied | None |
404 | Not Found | Order not found | None |
user
Operations about user
createUser
Code samples
# You can also use wget
curl -X POST http://petstore.swagger.io/v2/user \
-H 'Content-Type: application/json'
POST http://petstore.swagger.io/v2/user HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
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('http://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 'http://petstore.swagger.io/v2/user',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json'
}
r = requests.post('http://petstore.swagger.io/v2/user', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','http://petstore.swagger.io/v2/user', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | User | true | Created user object |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
default | Default | successful operation | None |
createUsersWithArrayInput
Code samples
# You can also use wget
curl -X POST http://petstore.swagger.io/v2/user/createWithArray \
-H 'Content-Type: application/json'
POST http://petstore.swagger.io/v2/user/createWithArray HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
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('http://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 'http://petstore.swagger.io/v2/user/createWithArray',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json'
}
r = requests.post('http://petstore.swagger.io/v2/user/createWithArray', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','http://petstore.swagger.io/v2/user/createWithArray', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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
}
]
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | User | true | List of user object |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
default | Default | successful operation | None |
createUsersWithListInput
Code samples
# You can also use wget
curl -X POST http://petstore.swagger.io/v2/user/createWithList \
-H 'Content-Type: application/json'
POST http://petstore.swagger.io/v2/user/createWithList HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
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('http://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 'http://petstore.swagger.io/v2/user/createWithList',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json'
}
r = requests.post('http://petstore.swagger.io/v2/user/createWithList', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('POST','http://petstore.swagger.io/v2/user/createWithList', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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
}
]
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
body | body | User | true | List of user object |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
default | Default | successful operation | None |
loginUser
Code samples
# You can also use wget
curl -X GET http://petstore.swagger.io/v2/user/login?username=string&password=pa%24%24word \
-H 'Accept: application/xml'
GET http://petstore.swagger.io/v2/user/login?username=string&password=pa%24%24word HTTP/1.1
Host: petstore.swagger.io
Accept: application/xml
const headers = {
'Accept':'application/xml'
};
fetch('http://petstore.swagger.io/v2/user/login?username=string&password=pa%24%24word',
{
method: 'GET',
headers: headers
})
.then(function(res) {
return res.json();
}).then(function(body) {
console.log(body);
});
require 'rest-client'
require 'json'
headers = {
'Accept' => 'application/xml'
}
result = RestClient.get 'http://petstore.swagger.io/v2/user/login',
params: {
'username' => 'string',
'password' => 'string(password)'
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Accept': 'application/xml'
}
r = requests.get('http://petstore.swagger.io/v2/user/login', params={
'username': 'string', 'password': 'pa$$word'
}, headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/xml',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('GET','http://petstore.swagger.io/v2/user/login', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://petstore.swagger.io/v2/user/login?username=string&password=pa%24%24word");
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/xml"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "http://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
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
username | query | string | true | The user name for login |
password | query | string(password) | true | The password for login in clear text |
Example responses
200 Response
"string"
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | string |
400 | Bad Request | Invalid username/password supplied | None |
Response Headers
Status | Header | Type | Format | Description |
---|---|---|---|---|
200 | X-Rate-Limit | integer | int32 | calls per hour allowed by the user |
200 | X-Expires-After | string | date-time | date in UTC when token expires |
logoutUser
Code samples
# You can also use wget
curl -X GET http://petstore.swagger.io/v2/user/logout
GET http://petstore.swagger.io/v2/user/logout HTTP/1.1
Host: petstore.swagger.io
fetch('http://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 'http://petstore.swagger.io/v2/user/logout',
params: {
}
p JSON.parse(result)
import requests
r = requests.get('http://petstore.swagger.io/v2/user/logout')
print(r.json())
<?php
require 'vendor/autoload.php';
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('GET','http://petstore.swagger.io/v2/user/logout', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
default | Default | successful operation | None |
getUserByName
Code samples
# You can also use wget
curl -X GET http://petstore.swagger.io/v2/user/{username} \
-H 'Accept: application/xml'
GET http://petstore.swagger.io/v2/user/{username} HTTP/1.1
Host: petstore.swagger.io
Accept: application/xml
const headers = {
'Accept':'application/xml'
};
fetch('http://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/xml'
}
result = RestClient.get 'http://petstore.swagger.io/v2/user/{username}',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Accept': 'application/xml'
}
r = requests.get('http://petstore.swagger.io/v2/user/{username}', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Accept' => 'application/xml',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('GET','http://petstore.swagger.io/v2/user/{username}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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/xml"},
}
data := bytes.NewBuffer([]byte{jsonReq})
req, err := http.NewRequest("GET", "http://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
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
username | path | string | true | The name that needs to be fetched. Use user1 for testing. |
Example responses
200 Response
<?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>
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
200 | OK | successful operation | User |
400 | Bad Request | Invalid username supplied | None |
404 | Not Found | User not found | None |
updateUser
Code samples
# You can also use wget
curl -X PUT http://petstore.swagger.io/v2/user/{username} \
-H 'Content-Type: application/json'
PUT http://petstore.swagger.io/v2/user/{username} HTTP/1.1
Host: petstore.swagger.io
Content-Type: application/json
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('http://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 'http://petstore.swagger.io/v2/user/{username}',
params: {
}, headers: headers
p JSON.parse(result)
import requests
headers = {
'Content-Type': 'application/json'
}
r = requests.put('http://petstore.swagger.io/v2/user/{username}', headers = headers)
print(r.json())
<?php
require 'vendor/autoload.php';
$headers = array(
'Content-Type' => 'application/json',
);
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('PUT','http://petstore.swagger.io/v2/user/{username}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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
}
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
username | path | string | true | name that need to be updated |
body | body | User | true | Updated user object |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
400 | Bad Request | Invalid user supplied | None |
404 | Not Found | User not found | None |
deleteUser
Code samples
# You can also use wget
curl -X DELETE http://petstore.swagger.io/v2/user/{username}
DELETE http://petstore.swagger.io/v2/user/{username} HTTP/1.1
Host: petstore.swagger.io
fetch('http://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 'http://petstore.swagger.io/v2/user/{username}',
params: {
}
p JSON.parse(result)
import requests
r = requests.delete('http://petstore.swagger.io/v2/user/{username}')
print(r.json())
<?php
require 'vendor/autoload.php';
$client = new \GuzzleHttp\Client();
// Define array of request body.
$request_body = array();
try {
$response = $client->request('DELETE','http://petstore.swagger.io/v2/user/{username}', array(
'headers' => $headers,
'json' => $request_body,
)
);
print_r($response->getBody()->getContents());
}
catch (\GuzzleHttp\Exception\BadResponseException $e) {
// handle exception or api errors.
print_r($e->getMessage());
}
// ...
URL obj = new URL("http://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", "http://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.
Parameters
Name | In | Type | Required | Description |
---|---|---|---|---|
username | path | string | true | The name that needs to be deleted |
Responses
Status | Meaning | Description | Schema |
---|---|---|---|
400 | Bad Request | Invalid username supplied | None |
404 | Not Found | User not found | None |
Schemas
Order
{
"id": 0,
"petId": 0,
"quantity": 0,
"shipDate": "2020-03-30T14:38:05Z",
"status": "placed",
"complete": false
}
Properties
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 |
Enumerated Values
Property | Value |
---|---|
status | placed |
status | approved |
status | delivered |
Category
{
"id": 0,
"name": "string"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | integer(int64) | false | none | none |
name | string | false | none | none |
User
{
"id": 0,
"username": "string",
"firstName": "string",
"lastName": "string",
"email": "string",
"password": "string",
"phone": "string",
"userStatus": 0
}
Properties
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 |
Tag
{
"id": 0,
"name": "string"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
id | integer(int64) | false | none | none |
name | string | false | none | none |
Pet
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
Properties
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 |
Enumerated Values
Property | Value |
---|---|
status | available |
status | pending |
status | sold |
ApiResponse
{
"code": 0,
"type": "string",
"message": "string"
}
Properties
Name | Type | Required | Restrictions | Description |
---|---|---|---|---|
code | integer(int32) | false | none | none |
type | string | false | none | none |
message | string | false | none | none |