Introduction to PetfindeR

The following vignette introduces the PetfindeR package and its methods for interacting with the Petfinder API. The goal of the PetfindeR library is to enable other users to interact with the rich data available in the Petfinder database. More information on the Petfinder API itself can be found on the API documentation page.

Table of Contents

Obtaining an API and Secret Key

Before we can begin extracting data from the API, we first require an API and secret key to authenticate access. To receive an API and secret key, create a free account with Petfinder on their developer page and request an API key.

The API and secret key received from Petfinder are what we will use to authenticate our connection to the Petfinder API with PetfindeR. Note authenication has a timeout of 3600 seconds, or one hour, after which the authentication to the API will need to be made again. For more information on how the Petfinder API authenication works, visit the API documentation on the Petfinder developer page.

Storing your keys received from APIs and other sensitive information in a secure file or as an environment variable is considered best practice to avoid any potential malicious activity. Therefore, we save the API and secret keys we received from Petfinder as environment variables in a specific R file named .Renviron. If you do not have an .Renviron file on your system, here is handy and short guide for creating one and adding environment variables for both Linux and Windows. If on a Mac, you can add the .Renviron file in your home directory. After saving the variables and restarting R/RStudio, we can access the environment variables with the Sys.getenv() function.

key <- Sys.getenv('PETFINDER_KEY')
secret <- Sys.getenv('PETFINDER_SECRET_KEY')

Installation

If not already installed, PetfindeR can be installed through the usual means:

install.packages('PetfindeR')

The package can also be installed with devtools for those wanting the most recent development version.

install.packages('devtools') # if devtools is not already installed
devtools::install_github('aschleg/PetfindeR')

Once installed, we can load the library as usual:

library(PetfindeR)

Now that PetfindeR is loaded, we can authenticate our connection to the API and begin extracting data! The authentication to the Petfinder API occurs when the PetfindeR class is initialized, which requires the API and secret keys we received in the previous step as parameters.

pf = Petfinder(key = key, secret = secret)

The pf variable is the initialized Petfinder class with our given API and secret key. We can now use this instance to interact with and extract data from the Petfinder API.

Getting Animal Types

The animal_types method allows one to get information on all or specific animal types in the Petfinder database. Animal type data includes the type’s species, color, coat and gender. Leaving the types parameter of the method empty will return all available animal types.

animal_types = pf$animal_types()

We can get the names of all the animal types available in the Petfinder API by using the names() function

names(animal_types)
## [1] "Dog"                  "Cat"                  "Rabbit"              
## [4] "Small & Furry"        "Horse"                "Bird"                
## [7] "Scales, Fins & Other" "Barnyard"

Specific information for a given type can be accessed as usual:

print(animal_types$Cat$coats)
## [1] "Hairless" "Short"    "Medium"   "Long"
print(animal_types$Cat$colors)
##  [1] "Black"                        "Black & White / Tuxedo"      
##  [3] "Blue Cream"                   "Blue Point"                  
##  [5] "Brown / Chocolate"            "Buff & White"                
##  [7] "Buff / Tan / Fawn"            "Calico"                      
##  [9] "Chocolate Point"              "Cream / Ivory"               
## [11] "Cream Point"                  "Dilute Calico"               
## [13] "Dilute Tortoiseshell"         "Flame Point"                 
## [15] "Gray & White"                 "Gray / Blue / Silver"        
## [17] "Lilac Point"                  "Orange & White"              
## [19] "Orange / Red"                 "Seal Point"                  
## [21] "Smoke"                        "Tabby (Brown / Chocolate)"   
## [23] "Tabby (Buff / Tan / Fawn)"    "Tabby (Gray / Blue / Silver)"
## [25] "Tabby (Leopard / Spotted)"    "Tabby (Orange / Red)"        
## [27] "Tabby (Tiger Striped)"        "Torbie"                      
## [29] "Tortoiseshell"                "White"

The animal_types method also accepts a single or multiple animal types.

cats = pf$animal_types('cat')

We can access the type’s data as we did before:

print(cats$Cat$coats)
## [1] "Hairless" "Short"    "Medium"   "Long"
print(cats$Cat$colors)
##  [1] "Black"                        "Black & White / Tuxedo"      
##  [3] "Blue Cream"                   "Blue Point"                  
##  [5] "Brown / Chocolate"            "Buff & White"                
##  [7] "Buff / Tan / Fawn"            "Calico"                      
##  [9] "Chocolate Point"              "Cream / Ivory"               
## [11] "Cream Point"                  "Dilute Calico"               
## [13] "Dilute Tortoiseshell"         "Flame Point"                 
## [15] "Gray & White"                 "Gray / Blue / Silver"        
## [17] "Lilac Point"                  "Orange & White"              
## [19] "Orange / Red"                 "Seal Point"                  
## [21] "Smoke"                        "Tabby (Brown / Chocolate)"   
## [23] "Tabby (Buff / Tan / Fawn)"    "Tabby (Gray / Blue / Silver)"
## [25] "Tabby (Leopard / Spotted)"    "Tabby (Orange / Red)"        
## [27] "Tabby (Tiger Striped)"        "Torbie"                      
## [29] "Tortoiseshell"                "White"

Multiple specific animal types can also be passed.

cat_dog <- pf$animal_types(c('cat', 'dog'))
print(cat_dog$Dog$coats)
## [1] "Hairless" "Short"    "Medium"   "Long"     "Wire"     "Curly"
print(cat_dog$Cat$coats)
## [1] "Hairless" "Short"    "Medium"   "Long"

Finding Available Breeds of Animal Types

Listed breeds for each animal type can be extracted using the breeds() method.

all_breeds <- pf$breeds()

For brevity, let’s print the animal types and the first three breeds of each type.

for (breed in 1:length(all_breeds)) {
  print(names(all_breeds[breed]))
  print(all_breeds[breed][0:3])
}
## [1] "dog"
## $dog
##   [1] "Affenpinscher"                           
##   [2] "Afghan Hound"                            
##   [3] "Airedale Terrier"                        
##   [4] "Akbash"                                  
##   [5] "Akita"                                   
##   [6] "Alaskan Malamute"                        
##   [7] "American Bulldog"                        
##   [8] "American Eskimo Dog"                     
##   [9] "American Foxhound"                       
##  [10] "American Hairless Terrier"               
##  [11] "American Staffordshire Terrier"          
##  [12] "American Water Spaniel"                  
##  [13] "Anatolian Shepherd"                      
##  [14] "Appenzell Mountain Dog"                  
##  [15] "Australian Cattle Dog / Blue Heeler"     
##  [16] "Australian Kelpie"                       
##  [17] "Australian Shepherd"                     
##  [18] "Australian Terrier"                      
##  [19] "Basenji"                                 
##  [20] "Basset Hound"                            
##  [21] "Beagle"                                  
##  [22] "Bearded Collie"                          
##  [23] "Beauceron"                               
##  [24] "Bedlington Terrier"                      
##  [25] "Belgian Shepherd / Laekenois"            
##  [26] "Belgian Shepherd / Malinois"             
##  [27] "Belgian Shepherd / Sheepdog"             
##  [28] "Belgian Shepherd / Tervuren"             
##  [29] "Bernese Mountain Dog"                    
##  [30] "Bichon Frise"                            
##  [31] "Black and Tan Coonhound"                 
##  [32] "Black Labrador Retriever"                
##  [33] "Black Mouth Cur"                         
##  [34] "Black Russian Terrier"                   
##  [35] "Bloodhound"                              
##  [36] "Blue Lacy"                               
##  [37] "Bluetick Coonhound"                      
##  [38] "Boerboel"                                
##  [39] "Bolognese"                               
##  [40] "Border Collie"                           
##  [41] "Border Terrier"                          
##  [42] "Borzoi"                                  
##  [43] "Boston Terrier"                          
##  [44] "Bouvier des Flandres"                    
##  [45] "Boxer"                                   
##  [46] "Boykin Spaniel"                          
##  [47] "Briard"                                  
##  [48] "Brittany Spaniel"                        
##  [49] "Brussels Griffon"                        
##  [50] "Bull Terrier"                            
##  [51] "Bullmastiff"                             
##  [52] "Cairn Terrier"                           
##  [53] "Canaan Dog"                              
##  [54] "Cane Corso"                              
##  [55] "Cardigan Welsh Corgi"                    
##  [56] "Carolina Dog"                            
##  [57] "Catahoula Leopard Dog"                   
##  [58] "Cattle Dog"                              
##  [59] "Caucasian Sheepdog / Caucasian Ovtcharka"
##  [60] "Cavalier King Charles Spaniel"           
##  [61] "Chesapeake Bay Retriever"                
##  [62] "Chihuahua"                               
##  [63] "Chinese Crested Dog"                     
##  [64] "Chinese Foo Dog"                         
##  [65] "Chinook"                                 
##  [66] "Chocolate Labrador Retriever"            
##  [67] "Chow Chow"                               
##  [68] "Cirneco dell'Etna"                       
##  [69] "Clumber Spaniel"                         
##  [70] "Cockapoo"                                
##  [71] "Cocker Spaniel"                          
##  [72] "Collie"                                  
##  [73] "Coonhound"                               
##  [74] "Corgi"                                   
##  [75] "Coton de Tulear"                         
##  [76] "Curly-Coated Retriever"                  
##  [77] "Dachshund"                               
##  [78] "Dalmatian"                               
##  [79] "Dandie Dinmont Terrier"                  
##  [80] "Doberman Pinscher"                       
##  [81] "Dogo Argentino"                          
##  [82] "Dogue de Bordeaux"                       
##  [83] "Dutch Shepherd"                          
##  [84] "English Bulldog"                         
##  [85] "English Cocker Spaniel"                  
##  [86] "English Coonhound"                       
##  [87] "English Foxhound"                        
##  [88] "English Pointer"                         
##  [89] "English Setter"                          
##  [90] "English Shepherd"                        
##  [91] "English Springer Spaniel"                
##  [92] "English Toy Spaniel"                     
##  [93] "Entlebucher"                             
##  [94] "Eskimo Dog"                              
##  [95] "Feist"                                   
##  [96] "Field Spaniel"                           
##  [97] "Fila Brasileiro"                         
##  [98] "Finnish Lapphund"                        
##  [99] "Finnish Spitz"                           
## [100] "Flat-Coated Retriever"                   
## [101] "Fox Terrier"                             
## [102] "Foxhound"                                
## [103] "French Bulldog"                          
## [104] "Galgo Spanish Greyhound"                 
## [105] "German Pinscher"                         
## [106] "German Shepherd Dog"                     
## [107] "German Shorthaired Pointer"              
## [108] "German Spitz"                            
## [109] "German Wirehaired Pointer"               
## [110] "Giant Schnauzer"                         
## [111] "Glen of Imaal Terrier"                   
## [112] "Golden Retriever"                        
## [113] "Gordon Setter"                           
## [114] "Great Dane"                              
## [115] "Great Pyrenees"                          
## [116] "Greater Swiss Mountain Dog"              
## [117] "Greyhound"                               
## [118] "Hamiltonstovare"                         
## [119] "Harrier"                                 
## [120] "Havanese"                                
## [121] "Hound"                                   
## [122] "Hovawart"                                
## [123] "Husky"                                   
## [124] "Ibizan Hound"                            
## [125] "Icelandic Sheepdog"                      
## [126] "Illyrian Sheepdog"                       
## [127] "Irish Setter"                            
## [128] "Irish Terrier"                           
## [129] "Irish Water Spaniel"                     
## [130] "Irish Wolfhound"                         
## [131] "Italian Greyhound"                       
## [132] "Jack Russell Terrier"                    
## [133] "Japanese Chin"                           
## [134] "Jindo"                                   
## [135] "Kai Dog"                                 
## [136] "Karelian Bear Dog"                       
## [137] "Keeshond"                                
## [138] "Kerry Blue Terrier"                      
## [139] "Kishu"                                   
## [140] "Klee Kai"                                
## [141] "Komondor"                                
## [142] "Kuvasz"                                  
## [143] "Kyi Leo"                                 
## [144] "Labrador Retriever"                      
## [145] "Lakeland Terrier"                        
## [146] "Lancashire Heeler"                       
## [147] "Leonberger"                              
## [148] "Lhasa Apso"                              
## [149] "Lowchen"                                 
## [150] "Maltese"                                 
## [151] "Manchester Terrier"                      
## [152] "Maremma Sheepdog"                        
## [153] "Mastiff"                                 
## [154] "McNab"                                   
## [155] "Miniature Bull Terrier"                  
## [156] "Miniature Dachshund"                     
## [157] "Miniature Pinscher"                      
## [158] "Miniature Poodle"                        
## [159] "Miniature Schnauzer"                     
## [160] "Mixed Breed"                             
## [161] "Mountain Cur"                            
## [162] "Mountain Dog"                            
## [163] "Munsterlander"                           
## [164] "Neapolitan Mastiff"                      
## [165] "New Guinea Singing Dog"                  
## [166] "Newfoundland Dog"                        
## [167] "Norfolk Terrier"                         
## [168] "Norwegian Buhund"                        
## [169] "Norwegian Elkhound"                      
## [170] "Norwegian Lundehund"                     
## [171] "Norwich Terrier"                         
## [172] "Nova Scotia Duck Tolling Retriever"      
## [173] "Old English Sheepdog"                    
## [174] "Otterhound"                              
## [175] "Papillon"                                
## [176] "Parson Russell Terrier"                  
## [177] "Patterdale Terrier / Fell Terrier"       
## [178] "Pekingese"                               
## [179] "Pembroke Welsh Corgi"                    
## [180] "Peruvian Inca Orchid"                    
## [181] "Petit Basset Griffon Vendeen"            
## [182] "Pharaoh Hound"                           
## [183] "Pit Bull Terrier"                        
## [184] "Plott Hound"                             
## [185] "Pointer"                                 
## [186] "Polish Lowland Sheepdog"                 
## [187] "Pomeranian"                              
## [188] "Poodle"                                  
## [189] "Portuguese Podengo"                      
## [190] "Portuguese Water Dog"                    
## [191] "Presa Canario"                           
## [192] "Pug"                                     
## [193] "Puli"                                    
## [194] "Pumi"                                    
## [195] "Pyrenean Shepherd"                       
## [196] "Rat Terrier"                             
## [197] "Redbone Coonhound"                       
## [198] "Retriever"                               
## [199] "Rhodesian Ridgeback"                     
## [200] "Rottweiler"                              
## [201] "Rough Collie"                            
## [202] "Saint Bernard"                           
## [203] "Saluki"                                  
## [204] "Samoyed"                                 
## [205] "Sarplaninac"                             
## [206] "Schipperke"                              
## [207] "Schnauzer"                               
## [208] "Scottish Deerhound"                      
## [209] "Scottish Terrier"                        
## [210] "Sealyham Terrier"                        
## [211] "Setter"                                  
## [212] "Shar-Pei"                                
## [213] "Sheep Dog"                               
## [214] "Shepherd"                                
## [215] "Shetland Sheepdog / Sheltie"             
## [216] "Shiba Inu"                               
## [217] "Shih Tzu"                                
## [218] "Siberian Husky"                          
## [219] "Silky Terrier"                           
## [220] "Skye Terrier"                            
## [221] "Sloughi"                                 
## [222] "Smooth Collie"                           
## [223] "Smooth Fox Terrier"                      
## [224] "South Russian Ovtcharka"                 
## [225] "Spaniel"                                 
## [226] "Spanish Water Dog"                       
## [227] "Spinone Italiano"                        
## [228] "Spitz"                                   
## [229] "Staffordshire Bull Terrier"              
## [230] "Standard Poodle"                         
## [231] "Standard Schnauzer"                      
## [232] "Sussex Spaniel"                          
## [233] "Swedish Vallhund"                        
## [234] "Terrier"                                 
## [235] "Thai Ridgeback"                          
## [236] "Tibetan Mastiff"                         
## [237] "Tibetan Spaniel"                         
## [238] "Tibetan Terrier"                         
## [239] "Tosa Inu"                                
## [240] "Toy Fox Terrier"                         
## [241] "Toy Manchester Terrier"                  
## [242] "Treeing Walker Coonhound"                
## [243] "Vizsla"                                  
## [244] "Weimaraner"                              
## [245] "Welsh Springer Spaniel"                  
## [246] "Welsh Terrier"                           
## [247] "West Highland White Terrier / Westie"    
## [248] "Wheaten Terrier"                         
## [249] "Whippet"                                 
## [250] "White German Shepherd"                   
## [251] "Wire Fox Terrier"                        
## [252] "Wirehaired Dachshund"                    
## [253] "Wirehaired Pointing Griffon"             
## [254] "Wirehaired Terrier"                      
## [255] "Xoloitzcuintli / Mexican Hairless"       
## [256] "Yellow Labrador Retriever"               
## [257] "Yorkshire Terrier"                       
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL
## 
## [1] "cat"
## $cat
##  [1] "Abyssinian"                           
##  [2] "American Bobtail"                     
##  [3] "American Curl"                        
##  [4] "American Shorthair"                   
##  [5] "American Wirehair"                    
##  [6] "Applehead Siamese"                    
##  [7] "Balinese"                             
##  [8] "Bengal"                               
##  [9] "Birman"                               
## [10] "Bombay"                               
## [11] "British Shorthair"                    
## [12] "Burmese"                              
## [13] "Burmilla"                             
## [14] "Calico"                               
## [15] "Canadian Hairless"                    
## [16] "Chartreux"                            
## [17] "Chausie"                              
## [18] "Chinchilla"                           
## [19] "Cornish Rex"                          
## [20] "Cymric"                               
## [21] "Devon Rex"                            
## [22] "Dilute Calico"                        
## [23] "Dilute Tortoiseshell"                 
## [24] "Domestic Long Hair"                   
## [25] "Domestic Medium Hair"                 
## [26] "Domestic Short Hair"                  
## [27] "Egyptian Mau"                         
## [28] "Exotic Shorthair"                     
## [29] "Extra-Toes Cat / Hemingway Polydactyl"
## [30] "Havana"                               
## [31] "Himalayan"                            
## [32] "Japanese Bobtail"                     
## [33] "Javanese"                             
## [34] "Korat"                                
## [35] "LaPerm"                               
## [36] "Maine Coon"                           
## [37] "Manx"                                 
## [38] "Munchkin"                             
## [39] "Nebelung"                             
## [40] "Norwegian Forest Cat"                 
## [41] "Ocicat"                               
## [42] "Oriental Long Hair"                   
## [43] "Oriental Short Hair"                  
## [44] "Oriental Tabby"                       
## [45] "Persian"                              
## [46] "Pixiebob"                             
## [47] "Ragamuffin"                           
## [48] "Ragdoll"                              
## [49] "Russian Blue"                         
## [50] "Scottish Fold"                        
## [51] "Selkirk Rex"                          
## [52] "Siamese"                              
## [53] "Siberian"                             
## [54] "Silver"                               
## [55] "Singapura"                            
## [56] "Snowshoe"                             
## [57] "Somali"                               
## [58] "Sphynx / Hairless Cat"                
## [59] "Tabby"                                
## [60] "Tiger"                                
## [61] "Tonkinese"                            
## [62] "Torbie"                               
## [63] "Tortoiseshell"                        
## [64] "Turkish Angora"                       
## [65] "Turkish Van"                          
## [66] "Tuxedo"                               
## [67] "York Chocolate"                       
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL
## 
## [1] "rabbit"
## $rabbit
##  [1] "American"           "American Fuzzy Lop" "American Sable"    
##  [4] "Angora Rabbit"      "Belgian Hare"       "Beveren"           
##  [7] "Britannia Petite"   "Bunny Rabbit"       "Californian"       
## [10] "Champagne D'Argent" "Checkered Giant"    "Chinchilla"        
## [13] "Cinnamon"           "Creme D'Argent"     "Dutch"             
## [16] "Dwarf"              "Dwarf Eared"        "English Lop"       
## [19] "English Spot"       "Flemish Giant"      "Florida White"     
## [22] "French Lop"         "Harlequin"          "Havana"            
## [25] "Himalayan"          "Holland Lop"        "Hotot"             
## [28] "Jersey Wooly"       "Lilac"              "Lionhead"          
## [31] "Lop Eared"          "Mini Lop"           "Mini Rex"          
## [34] "Netherland Dwarf"   "New Zealand"        "Palomino"          
## [37] "Polish"             "Rex"                "Rhinelander"       
## [40] "Satin"              "Silver"             "Silver Fox"        
## [43] "Silver Marten"      "Tan"               
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL
## 
## [1] "small-furry"
## $`small-furry`
##  [1] "Abyssinian"       "Chinchilla"       "Degu"            
##  [4] "Dwarf Hamster"    "Ferret"           "Gerbil"          
##  [7] "Guinea Pig"       "Hamster"          "Hedgehog"        
## [10] "Mouse"            "Peruvian"         "Prairie Dog"     
## [13] "Rat"              "Rex"              "Short-Haired"    
## [16] "Silkie / Sheltie" "Skunk"            "Sugar Glider"    
## [19] "Teddy"           
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL
## 
## [1] "horse"
## $horse
##  [1] "Appaloosa"            "Arabian"              "Belgian"             
##  [4] "Clydesdale"           "Connemara"            "Curly Horse"         
##  [7] "Donkey"               "Draft"                "Friesian"            
## [10] "Gaited"               "Grade"                "Haflinger"           
## [13] "Icelandic Horse"      "Lipizzan"             "Miniature Horse"     
## [16] "Missouri Foxtrotter"  "Morgan"               "Mule"                
## [19] "Mustang"              "Paint / Pinto"        "Palomino"            
## [22] "Paso Fino"            "Percheron"            "Peruvian Paso"       
## [25] "Pony"                 "Pony of the Americas" "Quarterhorse"        
## [28] "Rocky Mountain Horse" "Saddlebred"           "Shetland Pony"       
## [31] "Standardbred"         "Tennessee Walker"     "Thoroughbred"        
## [34] "Warmblood"           
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL
## 
## [1] "bird"
## $bird
##  [1] "African Grey"          "Amazon"               
##  [3] "Brotogeris"            "Budgie / Budgerigar"  
##  [5] "Button-Quail"          "Caique"               
##  [7] "Canary"                "Chicken"              
##  [9] "Cockatiel"             "Cockatoo"             
## [11] "Conure"                "Dove"                 
## [13] "Duck"                  "Eclectus"             
## [15] "Emu"                   "Finch"                
## [17] "Goose"                 "Guinea Fowl"          
## [19] "Kakariki"              "Lory / Lorikeet"      
## [21] "Lovebird"              "Macaw"                
## [23] "Ostrich"               "Parakeet (Other)"     
## [25] "Parrot (Other)"        "Parrotlet"            
## [27] "Peacock / Peafowl"     "Pheasant"             
## [29] "Pigeon"                "Pionus"               
## [31] "Poicephalus / Senegal" "Quail"                
## [33] "Quaker Parakeet"       "Rhea"                 
## [35] "Ringneck / Psittacula" "Rosella"              
## [37] "Swan"                  "Toucan"               
## [39] "Turkey"               
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL
## 
## [1] "scales-fins-other"
## $`scales-fins-other`
##  [1] "Asian Box"              "Ball Python"           
##  [3] "Bearded Dragon"         "Boa"                   
##  [5] "Boa Constrictor"        "Box"                   
##  [7] "Bull"                   "Bullfrog"              
##  [9] "Burmese Python"         "Chameleon"             
## [11] "Corn / Rat"             "Eastern Box"           
## [13] "Fire Salamander"        "Fire-Bellied"          
## [15] "Fire-Bellied Newt"      "Florida Box"           
## [17] "Freshwater Fish"        "Frog"                  
## [19] "Garter / Ribbon"        "Gecko"                 
## [21] "Goldfish"               "Hermit Crab"           
## [23] "Horned Frog"            "Iguana"                
## [25] "King / Milk"            "Leopard"               
## [27] "Leopard Frog"           "Lizard"                
## [29] "Mississippi Map Turtle" "Monitor"               
## [31] "Mud"                    "Musk"                  
## [33] "Oregon Newt"            "Ornamental Box"        
## [35] "Other"                  "Paddle Tailed Newt"    
## [37] "Painted"                "Python"                
## [39] "Red Foot"               "Red-Eared Slider"      
## [41] "Russian"                "Saltwater Fish"        
## [43] "Scorpion"               "Snake"                 
## [45] "Snapping"               "Soft Shell"            
## [47] "Southern"               "Sulcata"               
## [49] "Tarantula"              "Three-Toed Box"        
## [51] "Tiger Salamander"       "Toad"                  
## [53] "Tortoise"               "Tree Frog"             
## [55] "Turtle"                 "Uromastyx"             
## [57] "Water Dragon"           "Yellow-Bellied Slider" 
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL
## 
## [1] "barnyard"
## $barnyard
##  [1] "Alpaca"                 "Alpine"                
##  [3] "Angora"                 "Angus"                 
##  [5] "Barbados"               "Boer"                  
##  [7] "Cow"                    "Duroc"                 
##  [9] "Goat"                   "Hampshire"             
## [11] "Holstein"               "Jersey"                
## [13] "LaMancha"               "Landrace"              
## [15] "Llama"                  "Merino"                
## [17] "Mouflon"                "Myotonic / Fainting"   
## [19] "Nigerian Dwarf"         "Nubian"                
## [21] "Oberhasli"              "Pig"                   
## [23] "Pot Bellied"            "Pygmy"                 
## [25] "Saanen"                 "Sheep"                 
## [27] "Shetland"               "Toggenburg"            
## [29] "Vietnamese Pot Bellied" "Yorkshire"             
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL

Similar to the animal_types() method, the breeds() mehtod can accept a single or multiple animal types.

cat_rabbit = pf$breeds(c('cat', 'rabbit'))

for (breed in 1:length(cat_rabbit)) {
  print(names(all_breeds[breed]))
  print(all_breeds[breed][0:3])
}
## [1] "dog"
## $dog
##   [1] "Affenpinscher"                           
##   [2] "Afghan Hound"                            
##   [3] "Airedale Terrier"                        
##   [4] "Akbash"                                  
##   [5] "Akita"                                   
##   [6] "Alaskan Malamute"                        
##   [7] "American Bulldog"                        
##   [8] "American Eskimo Dog"                     
##   [9] "American Foxhound"                       
##  [10] "American Hairless Terrier"               
##  [11] "American Staffordshire Terrier"          
##  [12] "American Water Spaniel"                  
##  [13] "Anatolian Shepherd"                      
##  [14] "Appenzell Mountain Dog"                  
##  [15] "Australian Cattle Dog / Blue Heeler"     
##  [16] "Australian Kelpie"                       
##  [17] "Australian Shepherd"                     
##  [18] "Australian Terrier"                      
##  [19] "Basenji"                                 
##  [20] "Basset Hound"                            
##  [21] "Beagle"                                  
##  [22] "Bearded Collie"                          
##  [23] "Beauceron"                               
##  [24] "Bedlington Terrier"                      
##  [25] "Belgian Shepherd / Laekenois"            
##  [26] "Belgian Shepherd / Malinois"             
##  [27] "Belgian Shepherd / Sheepdog"             
##  [28] "Belgian Shepherd / Tervuren"             
##  [29] "Bernese Mountain Dog"                    
##  [30] "Bichon Frise"                            
##  [31] "Black and Tan Coonhound"                 
##  [32] "Black Labrador Retriever"                
##  [33] "Black Mouth Cur"                         
##  [34] "Black Russian Terrier"                   
##  [35] "Bloodhound"                              
##  [36] "Blue Lacy"                               
##  [37] "Bluetick Coonhound"                      
##  [38] "Boerboel"                                
##  [39] "Bolognese"                               
##  [40] "Border Collie"                           
##  [41] "Border Terrier"                          
##  [42] "Borzoi"                                  
##  [43] "Boston Terrier"                          
##  [44] "Bouvier des Flandres"                    
##  [45] "Boxer"                                   
##  [46] "Boykin Spaniel"                          
##  [47] "Briard"                                  
##  [48] "Brittany Spaniel"                        
##  [49] "Brussels Griffon"                        
##  [50] "Bull Terrier"                            
##  [51] "Bullmastiff"                             
##  [52] "Cairn Terrier"                           
##  [53] "Canaan Dog"                              
##  [54] "Cane Corso"                              
##  [55] "Cardigan Welsh Corgi"                    
##  [56] "Carolina Dog"                            
##  [57] "Catahoula Leopard Dog"                   
##  [58] "Cattle Dog"                              
##  [59] "Caucasian Sheepdog / Caucasian Ovtcharka"
##  [60] "Cavalier King Charles Spaniel"           
##  [61] "Chesapeake Bay Retriever"                
##  [62] "Chihuahua"                               
##  [63] "Chinese Crested Dog"                     
##  [64] "Chinese Foo Dog"                         
##  [65] "Chinook"                                 
##  [66] "Chocolate Labrador Retriever"            
##  [67] "Chow Chow"                               
##  [68] "Cirneco dell'Etna"                       
##  [69] "Clumber Spaniel"                         
##  [70] "Cockapoo"                                
##  [71] "Cocker Spaniel"                          
##  [72] "Collie"                                  
##  [73] "Coonhound"                               
##  [74] "Corgi"                                   
##  [75] "Coton de Tulear"                         
##  [76] "Curly-Coated Retriever"                  
##  [77] "Dachshund"                               
##  [78] "Dalmatian"                               
##  [79] "Dandie Dinmont Terrier"                  
##  [80] "Doberman Pinscher"                       
##  [81] "Dogo Argentino"                          
##  [82] "Dogue de Bordeaux"                       
##  [83] "Dutch Shepherd"                          
##  [84] "English Bulldog"                         
##  [85] "English Cocker Spaniel"                  
##  [86] "English Coonhound"                       
##  [87] "English Foxhound"                        
##  [88] "English Pointer"                         
##  [89] "English Setter"                          
##  [90] "English Shepherd"                        
##  [91] "English Springer Spaniel"                
##  [92] "English Toy Spaniel"                     
##  [93] "Entlebucher"                             
##  [94] "Eskimo Dog"                              
##  [95] "Feist"                                   
##  [96] "Field Spaniel"                           
##  [97] "Fila Brasileiro"                         
##  [98] "Finnish Lapphund"                        
##  [99] "Finnish Spitz"                           
## [100] "Flat-Coated Retriever"                   
## [101] "Fox Terrier"                             
## [102] "Foxhound"                                
## [103] "French Bulldog"                          
## [104] "Galgo Spanish Greyhound"                 
## [105] "German Pinscher"                         
## [106] "German Shepherd Dog"                     
## [107] "German Shorthaired Pointer"              
## [108] "German Spitz"                            
## [109] "German Wirehaired Pointer"               
## [110] "Giant Schnauzer"                         
## [111] "Glen of Imaal Terrier"                   
## [112] "Golden Retriever"                        
## [113] "Gordon Setter"                           
## [114] "Great Dane"                              
## [115] "Great Pyrenees"                          
## [116] "Greater Swiss Mountain Dog"              
## [117] "Greyhound"                               
## [118] "Hamiltonstovare"                         
## [119] "Harrier"                                 
## [120] "Havanese"                                
## [121] "Hound"                                   
## [122] "Hovawart"                                
## [123] "Husky"                                   
## [124] "Ibizan Hound"                            
## [125] "Icelandic Sheepdog"                      
## [126] "Illyrian Sheepdog"                       
## [127] "Irish Setter"                            
## [128] "Irish Terrier"                           
## [129] "Irish Water Spaniel"                     
## [130] "Irish Wolfhound"                         
## [131] "Italian Greyhound"                       
## [132] "Jack Russell Terrier"                    
## [133] "Japanese Chin"                           
## [134] "Jindo"                                   
## [135] "Kai Dog"                                 
## [136] "Karelian Bear Dog"                       
## [137] "Keeshond"                                
## [138] "Kerry Blue Terrier"                      
## [139] "Kishu"                                   
## [140] "Klee Kai"                                
## [141] "Komondor"                                
## [142] "Kuvasz"                                  
## [143] "Kyi Leo"                                 
## [144] "Labrador Retriever"                      
## [145] "Lakeland Terrier"                        
## [146] "Lancashire Heeler"                       
## [147] "Leonberger"                              
## [148] "Lhasa Apso"                              
## [149] "Lowchen"                                 
## [150] "Maltese"                                 
## [151] "Manchester Terrier"                      
## [152] "Maremma Sheepdog"                        
## [153] "Mastiff"                                 
## [154] "McNab"                                   
## [155] "Miniature Bull Terrier"                  
## [156] "Miniature Dachshund"                     
## [157] "Miniature Pinscher"                      
## [158] "Miniature Poodle"                        
## [159] "Miniature Schnauzer"                     
## [160] "Mixed Breed"                             
## [161] "Mountain Cur"                            
## [162] "Mountain Dog"                            
## [163] "Munsterlander"                           
## [164] "Neapolitan Mastiff"                      
## [165] "New Guinea Singing Dog"                  
## [166] "Newfoundland Dog"                        
## [167] "Norfolk Terrier"                         
## [168] "Norwegian Buhund"                        
## [169] "Norwegian Elkhound"                      
## [170] "Norwegian Lundehund"                     
## [171] "Norwich Terrier"                         
## [172] "Nova Scotia Duck Tolling Retriever"      
## [173] "Old English Sheepdog"                    
## [174] "Otterhound"                              
## [175] "Papillon"                                
## [176] "Parson Russell Terrier"                  
## [177] "Patterdale Terrier / Fell Terrier"       
## [178] "Pekingese"                               
## [179] "Pembroke Welsh Corgi"                    
## [180] "Peruvian Inca Orchid"                    
## [181] "Petit Basset Griffon Vendeen"            
## [182] "Pharaoh Hound"                           
## [183] "Pit Bull Terrier"                        
## [184] "Plott Hound"                             
## [185] "Pointer"                                 
## [186] "Polish Lowland Sheepdog"                 
## [187] "Pomeranian"                              
## [188] "Poodle"                                  
## [189] "Portuguese Podengo"                      
## [190] "Portuguese Water Dog"                    
## [191] "Presa Canario"                           
## [192] "Pug"                                     
## [193] "Puli"                                    
## [194] "Pumi"                                    
## [195] "Pyrenean Shepherd"                       
## [196] "Rat Terrier"                             
## [197] "Redbone Coonhound"                       
## [198] "Retriever"                               
## [199] "Rhodesian Ridgeback"                     
## [200] "Rottweiler"                              
## [201] "Rough Collie"                            
## [202] "Saint Bernard"                           
## [203] "Saluki"                                  
## [204] "Samoyed"                                 
## [205] "Sarplaninac"                             
## [206] "Schipperke"                              
## [207] "Schnauzer"                               
## [208] "Scottish Deerhound"                      
## [209] "Scottish Terrier"                        
## [210] "Sealyham Terrier"                        
## [211] "Setter"                                  
## [212] "Shar-Pei"                                
## [213] "Sheep Dog"                               
## [214] "Shepherd"                                
## [215] "Shetland Sheepdog / Sheltie"             
## [216] "Shiba Inu"                               
## [217] "Shih Tzu"                                
## [218] "Siberian Husky"                          
## [219] "Silky Terrier"                           
## [220] "Skye Terrier"                            
## [221] "Sloughi"                                 
## [222] "Smooth Collie"                           
## [223] "Smooth Fox Terrier"                      
## [224] "South Russian Ovtcharka"                 
## [225] "Spaniel"                                 
## [226] "Spanish Water Dog"                       
## [227] "Spinone Italiano"                        
## [228] "Spitz"                                   
## [229] "Staffordshire Bull Terrier"              
## [230] "Standard Poodle"                         
## [231] "Standard Schnauzer"                      
## [232] "Sussex Spaniel"                          
## [233] "Swedish Vallhund"                        
## [234] "Terrier"                                 
## [235] "Thai Ridgeback"                          
## [236] "Tibetan Mastiff"                         
## [237] "Tibetan Spaniel"                         
## [238] "Tibetan Terrier"                         
## [239] "Tosa Inu"                                
## [240] "Toy Fox Terrier"                         
## [241] "Toy Manchester Terrier"                  
## [242] "Treeing Walker Coonhound"                
## [243] "Vizsla"                                  
## [244] "Weimaraner"                              
## [245] "Welsh Springer Spaniel"                  
## [246] "Welsh Terrier"                           
## [247] "West Highland White Terrier / Westie"    
## [248] "Wheaten Terrier"                         
## [249] "Whippet"                                 
## [250] "White German Shepherd"                   
## [251] "Wire Fox Terrier"                        
## [252] "Wirehaired Dachshund"                    
## [253] "Wirehaired Pointing Griffon"             
## [254] "Wirehaired Terrier"                      
## [255] "Xoloitzcuintli / Mexican Hairless"       
## [256] "Yellow Labrador Retriever"               
## [257] "Yorkshire Terrier"                       
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL
## 
## [1] "cat"
## $cat
##  [1] "Abyssinian"                           
##  [2] "American Bobtail"                     
##  [3] "American Curl"                        
##  [4] "American Shorthair"                   
##  [5] "American Wirehair"                    
##  [6] "Applehead Siamese"                    
##  [7] "Balinese"                             
##  [8] "Bengal"                               
##  [9] "Birman"                               
## [10] "Bombay"                               
## [11] "British Shorthair"                    
## [12] "Burmese"                              
## [13] "Burmilla"                             
## [14] "Calico"                               
## [15] "Canadian Hairless"                    
## [16] "Chartreux"                            
## [17] "Chausie"                              
## [18] "Chinchilla"                           
## [19] "Cornish Rex"                          
## [20] "Cymric"                               
## [21] "Devon Rex"                            
## [22] "Dilute Calico"                        
## [23] "Dilute Tortoiseshell"                 
## [24] "Domestic Long Hair"                   
## [25] "Domestic Medium Hair"                 
## [26] "Domestic Short Hair"                  
## [27] "Egyptian Mau"                         
## [28] "Exotic Shorthair"                     
## [29] "Extra-Toes Cat / Hemingway Polydactyl"
## [30] "Havana"                               
## [31] "Himalayan"                            
## [32] "Japanese Bobtail"                     
## [33] "Javanese"                             
## [34] "Korat"                                
## [35] "LaPerm"                               
## [36] "Maine Coon"                           
## [37] "Manx"                                 
## [38] "Munchkin"                             
## [39] "Nebelung"                             
## [40] "Norwegian Forest Cat"                 
## [41] "Ocicat"                               
## [42] "Oriental Long Hair"                   
## [43] "Oriental Short Hair"                  
## [44] "Oriental Tabby"                       
## [45] "Persian"                              
## [46] "Pixiebob"                             
## [47] "Ragamuffin"                           
## [48] "Ragdoll"                              
## [49] "Russian Blue"                         
## [50] "Scottish Fold"                        
## [51] "Selkirk Rex"                          
## [52] "Siamese"                              
## [53] "Siberian"                             
## [54] "Silver"                               
## [55] "Singapura"                            
## [56] "Snowshoe"                             
## [57] "Somali"                               
## [58] "Sphynx / Hairless Cat"                
## [59] "Tabby"                                
## [60] "Tiger"                                
## [61] "Tonkinese"                            
## [62] "Torbie"                               
## [63] "Tortoiseshell"                        
## [64] "Turkish Angora"                       
## [65] "Turkish Van"                          
## [66] "Tuxedo"                               
## [67] "York Chocolate"                       
## 
## $<NA>
## NULL
## 
## $<NA>
## NULL

Search for animals in the Petfinder database

The animals method can be used to perform a general search for animals based on specified criteria or returning data on specific animals based on their respective IDs. For example, let’s say we want to get 100 adoptable female cats within a 10 mile distance of Seattle, WA.

cats = pf$animals(animal_type = 'cat', gender = 'female', status = 'adoptable', location = 'Seattle, WA', distance = 10, results_per_page = 50, pages = 2)

Specific animal data can also be extracted by supplying the animal_id parameter in the animals() method. As the search by ID is a direct search, the general search queries such as gender, age, and the others are overridden. As an example, we can use some of the animal_ids returned from the animals() method. Although Petfinder animal_ids are integers, they can be supplied as strings.

cat_ids = pf$animals(animal_id = c(animal_id1, animal_id2))

Finding animal welfare organizations

The organizations() method is similar to the animals() method described above but is used to perform general or specific searches by ID on animal welfare organizations listed in the Petfinder database. Again, similar to the first example above, we can find animal welfare organizations in a 50 mile radius of Seattle, WA. To see all of the possible search parameters, please see the petpy documentation for the organizations() method.

wa_orgs = pf$organizations(location = 'Seattle, WA', distance = 50, sort = 'distance', pages = 4, results_per_page = 100)

We can also extract specific animal welfare organization data by supplying the organizations() method with Petfinder organization IDs. When performing a direct search for organizations, the general search parameters in the method are overridden and do not need to be supplied.

wa_some_orgs = pf$organizations(organization_id = wa_orgs$page1$id[0:3])

Conclusion

Hopefully this served as a useful introduction to the basic functionality of PetfindeR and some short examples to get started. The Petfinder database contains a wealth of adoptable animal information that is updated constantly so it is the goal of the PetfindeR wrapper library to make extracting and interacting with this data even easier whether you’re building a web app or want to scrape the database for data analysis.