Other Methods

The Remaining Methods


Though we've only looked in depth at a handful of the methods, the remaining methods generally function in a very similar manner, accepting the same sorts of arguments and returning the same sorts of data. The only new category of information to go over is that of shelters.

Before we get there though,let's take a look at what we have left:

In the sections below I will briefly cover these methods, how they relate to the previously explained methods and how they differ some.

pet.getRandom


As mentioned earlier, this method can be used to pull a random pet that matches some provided parameters.

Parameters

Name Type Required? Description
key string required your developer key
token string optional session token
animal string optional type of animal (barnyard, bird, cat, dog, horse, pig, reptile, smallfurry)
breed string optional breed of animal (use breeds.list for a list of valid breeds)
size string optional size of animal (S=small, M=medium, L=large, XL=extra-large)
sex character optional M=male, F=female
location string optional the ZIP/postal code or city and state the animal should be located (NOTE: the closest possible animal will be selected)
shelterid string optional ID of the shelter that posted the pet
output string optional (default=id) How much of the pet record to return: id, basic, full
format string optional (default=xml) Response format: xml, json
(Above table taken from official API docs and placed here for ease of reference.)
Look Familiar?

As you may have noticed many of these parameters are the same as those from the pet.find method.

The only real changes are the lack of count, offset and age. It's worth nothing that the first two are unnecessary since we are only pulling a single random pet. As far as why we cannot add age in here goes, I have no idea.

It does have an additional parameter though. That would be shelterid. Here was can provide the id of a shelter (which we can get from shelter.find) to get a random pet only from that single shelter.

shelter.getPets


This method will return a list of all pets that are currently at specified the shelter.

Parameters

ARGUMENTS
Name Type Required? Description
key string required your developer key
token string optional session token
id string required shelter ID (e.g. NJ94)
status character optional (default=A, public may only list adoptable pets) A=adoptable, H=hold, P=pending, X=adopted/removed
offset integer optional offset into the result set (default is 0)
count integer optional how many records to return for this particular API call (default is 25)
output string optional (default=basic) How much of the pet record to return: id, basic (no description), full
format string optional (default=xml) Response format: xml, json
(Above table taken from official API docs and placed here for ease of reference.)
See anything new?

The only new parameter is status which allows us to indicate the type of pet we want to receive back (adoptable, adopted, etc). However, free API keys are only able to see the adoptable pets, so feel free to ignore this parameter.

Aside from that, this method has very few parameters to worry about, and none that are new.

shelter.listByBreed


This method returns all shelters that have animals of a specific breed available. For example, it could grab all shelters that have Appaloosa horses available.

Parameters

Name Type Required? Description
key string required your developer key
token string optional session token
animal string required type of animal (barnyard, bird, cat, dog, horse, pig, reptile, smallfurry)
breed string required greed of animal(use breed.list for a list of valid breeds)
offset integer optional offset into the result set (default is 0)
count integer optional how many records to return for this particular API call (default is 25)
format string optional (default=xml) Response format: xml, json
(Above table taken from official API docs and placed here for ease of reference.)

Pretty Basic

For this last method, there are actually no new parameters to see.

Like the other methods returning multiple records, it also uses count and offset to navigate and grab specific ranges of results.

How could this method be used?

Since the method does not allow you to specify the location of the shelter, it seems more of a tool ot just find shelters offering a breed of animal for other purposes besides adopting. After all, what use is getting shelters from Alaska if you live in Florida? Nevertheless you could trim the results by having a function only grab those in your state. You could then call shelter.getPets to obtain all pets from those shelters, and then you could loop through the results to grab only the pets of your desired breed.

Example


Below is an example of using the method to get a big list and then paring it down to just those from a single state: California.

Be sure to insert your own key before running.