API Reference

You can use our API to access pet API endpoints, which can get information on various cats, kittens, and breeds in our database.

Authentication

Pet uses API keys to allow access to the API. You can register a new Pet API key at our developer portal.

Pet expects for the API key to be included in all API requests to the server in a header that looks like the following:

Authorization: meowmeowmeow

Use this code:

require = 'pet'

api = pet :: APIClient.authorize!('meowmeowmeow')

import pet

api = pet.authorize('meowmeowmeow')

# With shell, you can just pass the correct header with each request

curl "api_endpoint_here"

-H "Authorization: meowmeowmeow"

const pet = require('pet');

let api = pet.authorize('meowmeowmeow');

Make sure to replace meowmeowmeow with your API key.

Pets

The following sections cover the endpoints for pets.

Get All Pets

This endpoint retrieves all pets.

HTTP Request

GET http://example.com/api/pets

Query Parameters

Parameter Default Description
include_cats false If set to true, the result will also include cats.
available true If set to false, the result will include pets that have already been adopted.

Use this code:

require 'pet'

api = pet::APIClient.authorize!('meowmeowmeow')

api.pet.get

import pet

api = pet.authorize('meowmeowmeow')

api.kittens.get()

curl "http://example.com/api/pets"

-H "Authorization: meowmeowmeow"

const pet = require('pet');

let api = pet.authorize('meowmeowmeow');

let kittens = api.pets.get();

The preceding command returns JSON structured like this:

[ { "id": 1, "name": "Fluffums", "breed": "calico", "fluffiness": 6, "cuteness": 7 },

{ "id": 2, "name": "Max", "breed": "unknown", "fluffiness": 5, "cuteness": 10 } ]

Get a Specific Pet

This endpoint retrieves a specific pet.

HTTP Request

GET http://example.com/pets/<ID>

URL Parameters

Parameter Description
ID The ID of the pet to retrieve

Use this code:

require 'pet'

api = pet::APIClient.authorize!('meowmeowmeow')

api.pets.get(2)

import pet

api = pet.authorize('meowmeowmeow')

api.pets.get(2)

curl "http://example.com/api/pets/2"

-H "Authorization: meowmeowmeow"

const pet = require('pet');

let api = pet.authorize('meowmeowmeow');

let max = api.pets.get(2);

The preceding command returns JSON structured like this:

{ "id": 2, "name": "Max", "breed": "unknown", "fluffiness": 5, "cuteness": 10 }

Delete a Specific Pet

This endpoint deletes a specific pet.

HTTP Request

DELETE http://example.com/pets/<ID>

URL Parameters

Parameter Description
ID The ID of the pet to delete

Use this code:

require 'pet'

api = pet::APIClient.authorize!('meowmeowmeow')

api.kittens.delete(2)

import pet

api = pet.authorize('meowmeowmeow')

api.kittens.delete(2)

curl "http://example.com/api/pets/2"

-X DELETE

-H "Authorization: meowmeowmeow"

const pet = require('pet');

let api = pet.authorize('meowmeowmeow');

let max = api.pets.delete(2);

The preceding command returns JSON structured like this:

{ "id": 2, "deleted" : ":(" }

Errors

The pet API uses the following error codes:

Error Code Meaning
400 Bad Request -- Please try again.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- The pet requested is hidden for administrators only.
404 Not Found -- The specified pet could not be found.
405 Method Not Allowed -- You tried to access a pet with an invalid method.
406 Not Acceptable -- You requested a format that isn't json.
410 Gone -- The pet requested has been removed from our servers.
418 I'm a teapot.
429 Too Many Requests -- You're requesting too many pets! Slow down!
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.