Swagger Petstore v3 (OpenAPI 3)

Pets

createPets

Create a pet


/pets

Usage and SDK Samples

curl -X POST\
-H "Accept: application/json"\
"http://petstore.swagger.io/v1/pets"
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.PetsApi;

import java.io.File;
import java.util.*;

public class PetsApiExample {

    public static void main(String[] args) {
        
        PetsApi apiInstance = new PetsApi();
        try {
            apiInstance.createPets();
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#createPets");
            e.printStackTrace();
        }
    }
}
import io.swagger.client.api.PetsApi;

public class PetsApiExample {

    public static void main(String[] args) {
        PetsApi apiInstance = new PetsApi();
        try {
            apiInstance.createPets();
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#createPets");
            e.printStackTrace();
        }
    }
}

PetsApi *apiInstance = [[PetsApi alloc] init];

// Create a pet
[apiInstance createPetsWithCompletionHandler: 
              ^(NSError* error) {
                            if (error) {
                                NSLog(@"Error: %@", error);
                            }
                        }];
var SwaggerPetstoreV3OpenApi3 = require('swagger_petstore_v3__open_api_3');

var api = new SwaggerPetstoreV3OpenApi3.PetsApi()
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully.');
  }
};
api.createPets(callback);
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;

namespace Example
{
    public class createPetsExample
    {
        public void main()
        {

            var apiInstance = new PetsApi();

            try
            {
                // Create a pet
                apiInstance.createPets();
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling PetsApi.createPets: " + e.Message );
            }
        }
    }
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new Swagger\Client\ApiPetsApi();

try {
    $api_instance->createPets();
} catch (Exception $e) {
    echo 'Exception when calling PetsApi->createPets: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::SwaggerClient::Configuration;
use WWW::SwaggerClient::PetsApi;

my $api_instance = WWW::SwaggerClient::PetsApi->new();

eval { 
    $api_instance->createPets();
};
if ($@) {
    warn "Exception when calling PetsApi->createPets: $@\n";
}
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = swagger_client.PetsApi()

try: 
    # Create a pet
    api_instance.create_pets()
except ApiException as e:
    print("Exception when calling PetsApi->createPets: %s\n" % e)

Parameters

Responses

Status: 201 - Null response

Status: default - unexpected error


listPets

List all pets


/pets

Usage and SDK Samples

curl -X GET\
-H "Accept: application/json"\
"http://petstore.swagger.io/v1/pets?limit="
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.PetsApi;

import java.io.File;
import java.util.*;

public class PetsApiExample {

    public static void main(String[] args) {
        
        PetsApi apiInstance = new PetsApi();
        Integer limit = 56; // Integer | How many items to return at one time (max 100)
        try {
            Pets result = apiInstance.listPets(limit);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#listPets");
            e.printStackTrace();
        }
    }
}
import io.swagger.client.api.PetsApi;

public class PetsApiExample {

    public static void main(String[] args) {
        PetsApi apiInstance = new PetsApi();
        Integer limit = 56; // Integer | How many items to return at one time (max 100)
        try {
            Pets result = apiInstance.listPets(limit);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#listPets");
            e.printStackTrace();
        }
    }
}
Integer *limit = 56; // How many items to return at one time (max 100) (optional)

PetsApi *apiInstance = [[PetsApi alloc] init];

// List all pets
[apiInstance listPetsWith:limit
              completionHandler: ^(Pets output, NSError* error) {
                            if (output) {
                                NSLog(@"%@", output);
                            }
                            if (error) {
                                NSLog(@"Error: %@", error);
                            }
                        }];
var SwaggerPetstoreV3OpenApi3 = require('swagger_petstore_v3__open_api_3');

var api = new SwaggerPetstoreV3OpenApi3.PetsApi()
var opts = { 
  'limit': 56 // {{Integer}} How many items to return at one time (max 100)
};
var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.listPets(opts, callback);
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;

namespace Example
{
    public class listPetsExample
    {
        public void main()
        {

            var apiInstance = new PetsApi();
            var limit = 56;  // Integer | How many items to return at one time (max 100) (optional) 

            try
            {
                // List all pets
                Pets result = apiInstance.listPets(limit);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling PetsApi.listPets: " + e.Message );
            }
        }
    }
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new Swagger\Client\ApiPetsApi();
$limit = 56; // Integer | How many items to return at one time (max 100)

try {
    $result = $api_instance->listPets($limit);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling PetsApi->listPets: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::SwaggerClient::Configuration;
use WWW::SwaggerClient::PetsApi;

my $api_instance = WWW::SwaggerClient::PetsApi->new();
my $limit = 56; # Integer | How many items to return at one time (max 100)

eval { 
    my $result = $api_instance->listPets(limit => $limit);
    print Dumper($result);
};
if ($@) {
    warn "Exception when calling PetsApi->listPets: $@\n";
}
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = swagger_client.PetsApi()
limit = 56 # Integer | How many items to return at one time (max 100) (optional)

try: 
    # List all pets
    api_response = api_instance.list_pets(limit=limit)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling PetsApi->listPets: %s\n" % e)

Parameters

Query parameters
Name Description
limit
Integer (int32)
How many items to return at one time (max 100)

Responses

Status: 200 - A paged array of pets

Name Type Format Description
x-next String

Status: default - unexpected error


showPetById

Info for a specific pet


/pets/{petId}

Usage and SDK Samples

curl -X GET\
-H "Accept: application/json"\
"http://petstore.swagger.io/v1/pets/{petId}"
import io.swagger.client.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
import io.swagger.client.api.PetsApi;

import java.io.File;
import java.util.*;

public class PetsApiExample {

    public static void main(String[] args) {
        
        PetsApi apiInstance = new PetsApi();
        String petId = petId_example; // String | The id of the pet to retrieve
        try {
            Pets result = apiInstance.showPetById(petId);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#showPetById");
            e.printStackTrace();
        }
    }
}
import io.swagger.client.api.PetsApi;

public class PetsApiExample {

    public static void main(String[] args) {
        PetsApi apiInstance = new PetsApi();
        String petId = petId_example; // String | The id of the pet to retrieve
        try {
            Pets result = apiInstance.showPetById(petId);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling PetsApi#showPetById");
            e.printStackTrace();
        }
    }
}
String *petId = petId_example; // The id of the pet to retrieve

PetsApi *apiInstance = [[PetsApi alloc] init];

// Info for a specific pet
[apiInstance showPetByIdWith:petId
              completionHandler: ^(Pets output, NSError* error) {
                            if (output) {
                                NSLog(@"%@", output);
                            }
                            if (error) {
                                NSLog(@"Error: %@", error);
                            }
                        }];
var SwaggerPetstoreV3OpenApi3 = require('swagger_petstore_v3__open_api_3');

var api = new SwaggerPetstoreV3OpenApi3.PetsApi()
var petId = petId_example; // {{String}} The id of the pet to retrieve

var callback = function(error, data, response) {
  if (error) {
    console.error(error);
  } else {
    console.log('API called successfully. Returned data: ' + data);
  }
};
api.showPetById(petId, callback);
using System;
using System.Diagnostics;
using IO.Swagger.Api;
using IO.Swagger.Client;
using IO.Swagger.Model;

namespace Example
{
    public class showPetByIdExample
    {
        public void main()
        {

            var apiInstance = new PetsApi();
            var petId = petId_example;  // String | The id of the pet to retrieve

            try
            {
                // Info for a specific pet
                Pets result = apiInstance.showPetById(petId);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling PetsApi.showPetById: " + e.Message );
            }
        }
    }
}
<?php
require_once(__DIR__ . '/vendor/autoload.php');

$api_instance = new Swagger\Client\ApiPetsApi();
$petId = petId_example; // String | The id of the pet to retrieve

try {
    $result = $api_instance->showPetById($petId);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling PetsApi->showPetById: ', $e->getMessage(), PHP_EOL;
}
?>
use Data::Dumper;
use WWW::SwaggerClient::Configuration;
use WWW::SwaggerClient::PetsApi;

my $api_instance = WWW::SwaggerClient::PetsApi->new();
my $petId = petId_example; # String | The id of the pet to retrieve

eval { 
    my $result = $api_instance->showPetById(petId => $petId);
    print Dumper($result);
};
if ($@) {
    warn "Exception when calling PetsApi->showPetById: $@\n";
}
from __future__ import print_statement
import time
import swagger_client
from swagger_client.rest import ApiException
from pprint import pprint

# create an instance of the API class
api_instance = swagger_client.PetsApi()
petId = petId_example # String | The id of the pet to retrieve

try: 
    # Info for a specific pet
    api_response = api_instance.show_pet_by_id(petId)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling PetsApi->showPetById: %s\n" % e)

Parameters

Path parameters
Name Description
petId*
String
The id of the pet to retrieve
Required

Responses

Status: 200 - Expected response to a valid request

Status: default - unexpected error