Swagger Petstore v2 (OpenAPI 2)

Pets

listPets

List all pets


/pets

Usage and SDK Samples

curl -X GET "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 SwaggerPetstoreV2OpenApi2 = require('swagger_petstore_v2__open_api_2');

var api = new SwaggerPetstoreV2OpenApi2.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\Api\PetsApi();
$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 - An paged array of pets

Name Type Format Description
x-next String A link to the next page of responses

Status: default - unexpected error