By PetHub, 23 January, 2023

The /Perks endpoint focuses on the current list of lost pets posted on PetHub.com. Use this to create, read/pull, update and delete Lost Pet Posters.

Digging into /Perks

The /perks endpoint offers the following:

/perks Description
/  
/{perkid}
  • GET
  • PUT
  • DELETE
   
   

The Swagger 2.0 / OAS YAML rendering is below including the data structures necessary for POST or returned by GET.

Category
By PetHub, 23 January, 2023

The /LostPets endpoint focuses on the current list of lost pets posted on PetHub.com. Use this to create, read/pull, update and delete Lost Pet Posters.

Digging into /LostPets

The /lostpets endpoint offers the following:

/lostpets Description
/
  • POST - create a lost pet poster
  • GET - pull a list of lost pet posters and their {posterId}
    Examples:
    https://pethub.io/v1/lostpets?state=wa&city=seattle&species=dog
/{posterId}
  • GET - retrieve the details of a specific poster
  • PUT - update a lost pet poster's details
  • DELETE - remove a lost pet poster
/{posterId}/share
  • POST - specify which channels to share the poster
  • GET - retrieve a list of channels (Facebook, Twitter, etc.) in which the poster has been shared
/{posterId}/pdf GET - retrieve a link to a PDF version of the lost pet poster

The Swagger 2.0 / OAS YAML rendering is below including the data structures necessary for POST or returned by GET.

Category
By PetHub, 1 January, 2023

PetHub Open API v1.0 - the struggle is always putting out a good first version of.. well.. anything. It's no different for putting out a solid API and so we did a lot of reading, learned from other developers over the years about what worked and what didn't, and landed on a solid approach that will, of course, change for the better. Until then, we have our v1 and we look forward to -- with your help -- creating an even better v2. It only works if you provide us with your thoughtful, critical feedback.

Tags

By PetHub, 1 January, 2023

The /types endpoint focuses on the types of data that can be associated with a pet's profile on PetHub.com. Use this to retrieve the list of type names and unique IDs to associate with a pet's profile information.

This endpoint:

By PetHub, 1 January, 2023

The HTTP response status codes that PetHub API utilizes are currently:

  • 200 - OK
  • 201 - Created
  • 400 - Bad request
  • 404 - Not found
  • 500 - Internal server error

In addition to returning an HTTP response to a request to a PetHub.io API, we hope to actually provide some helpful information in the event of an error (but, if we miss that mark, please let us know so we can do our best to address it).

Request Errors

In addition to the HTTP response code above being returned, when an error occurs we will endeavor to have it include the following fields to help you (and possibly us) in diagnosing the problem:

  • response_code - HTTP status code (see above)
  • message - verbose, plain language description of the problem with hints of how to fix it
  • more_info - link to any supporting documentation
  • code - API error code defined in the PetHub API documentation to further identify the issue

For example, let's attempt to look-up the information for our beloved Grizzly (the original tester dog) where an access token is not included in the Header of the request:

curl GET https://pethub.io/v1/pets/321

Should have been:
curl -H "Authorization: Bearer abc123" GET https://pethub.io/v1/pets/321

The response would look something like the following:

HTTP Status Code: 401

{
    "response_code" : "401",
    "message" : "Header is missing or includes an invalid access token",
    "more_info" : "https://pethub.io/api/v1/auth,https://pethub.io/errors/202201100",
    "code" : "202201100"
}

 

By PetHub, 1 January, 2023

Helpful API provided by Petfinder (requires API key sign-up).

Swagger 2.0 File
Category
By PetHub, 1 January, 2023

The /pets endpoint focuses on the pet profile on PetHub.com. Use this to create a pet profile, retrieve a pet's information, and update its details as documented here.

The main parameter of this endpoint is the pet ID {pid} which is a UUID for a pet.

Digging into /Pets

The /pets endpoint offers the following:

/pets Description
/

POST - creates a new pet profile

/{pid}
  • GET - returns basic profile information such as name, photo, breed, species, age, description, and so on
  • PUT - updates a pet's basic profile information
  • DELETE - deletes a pet's basic profile and causes all associated data to be deleted as well (e.g. activities, allergies, documents, conditions, foods, medications, etc.)
/{pid}/activities
  • POST - add an activity for a pet
  • GET - return list of activities for a specific pet
  • DELETE - remove an activity for the pet
/{pid}/allergies
  • POST - add an allergy entry for a pet
  • GET - returns a list of allergies associated with a pet
  • PUT - updates a pet's existing allergy information
  • DELETE - deletes the pet's specified allergy entry
/{pid}/conditions
  • POST - add a condition entry for a pet
  • GET - returns a list of conditions for the specified pet
  • PUT - updates a pet's existing condition information
  • DELETE - deletes the pet's specified condition entry
/{pid}/documents
  • POST - add a file to a pet's profile
  • GET - list of documents associated with the pet
  • DELETE - remove a document from the website and pet's profile
/{pid}/foods
  • POST - add a food entry for a pet's diet
  • GET - retrieve a list of foods on a pet's diet
  • PUT - update a pet's food regimen
  • DELETE - remove the food entry from the pet's profile
/{pid}/medications
  • POST - Add a medication entry for a pet
  • GET - retrieve a list of medications and their details for a pet
  • PUT - update a medication entry for a pet
  • DELETE - remove a medication from the pet's profile
/{pid}/procedures
  • POST - add a medical procedure entry for a pet
  • GET - returns a list of medical procedures associated with this pet
  • PUT - update the medical procedure entry
  • DELETE - remove a procedure from the pet's profile
/{pid}/tags
  • POST - links a tag to the pet
  • GET - returns a list of IDs linked to the pet's profile
  • DELETE - unlink the tag from the pet's profile

The Swagger 2.0 / OAS YAML rendering is below including the data structures necessary for POST or returned by GET.

Swagger 2.0 File
By PetHub, 1 January, 2023

The /Persons endpoint focuses on the user account on PetHub.com.

Use this to create a user account, retrieve a user's information, update their details, and retrieve a list of content they own (including pet profiles, documents, safety contacts, and so on). Then, if it is necessary to dive deeper into detail, use the other APIs to access specific details about those Types of content.

Security: this information is only available if the user has provided both access to the requesting application and permissions to access the type of information being requested. If a user provides access to their account but has not given permission to view Documents or Insurance information, for example, an error 400 (Bad Request) will be returned.

Digging into /Persons

The /persons endpoint:

/persons Description
/
  • POST - Creates a new user account
  • GET - search for a person's basic account information using their email address or username.
    Examples:
    • https://pethub.io/v1/persons?email=john@example.com
    • https://pethub.io/v1/persons?username=johndoe
/{uuid}1
  • GET - returns basic account information such as email address, unique username, creation date, last login
  • PUT - updates an existing user's account
  • DELETE - Removes the user account and any content provided by the user (requires elevated permissions)
/{uuid}/authorized

GET - list of API key IDs user has approved for accessing their account and data (requires elevated permissions)

/{uuid}/perks
  • POST - add a perk to a user's list of perks
  • GET - list of perks claimed by the user (can filter by expiration and status)
    Example:
    https://pethub.io/v1/persons/3295c76acbf4caaed33c36b1b5fc2cb1/perks?status=active
    (returns only active perks and excludes those that have expired)
  • DELETE - remove a perk from a user's list of claimed perks
/{uuid}/pets

GET - the pets type causes the API to return a basic list of the user's pets perfect for using in a list that allows drilling deeper into an individual pet's information

Example:
https://pethub.io/v1/persons/3295c76acbf4caaed33c36b1b5fc2cb1/pets?species=dog
(returns list of user's pets that are dogs)

/{uuid}/policies
  • POST - add a policy to a user's profile
  • GET - list of all insurance policies added to the site by the user and to which pets the policy applies
  • DELETE - remove a policy from a user's account
/{uuid}/profile
  • GET - deeper information about the user's account information, including first name, last name, main telephone number(s), additional email addresses, and mailing address
  • PUT - updates a user's profile
/{uuid}/safetyCircle
  • POST - add a safety circle contact (including to which pet(s) is/are known by the person
  • GET - list of Safety Circle contacts the user has added to the website. Also includes a list of pets each of the contacts knows (optional query attribute pet_id may be used to filter by pet)
  • PUT - update a contact's information (including which pet(s) are known by the contact)
  • DELETE - remove an emergency contact from the user's list
/{uuid}/subscriptions
  • POST - add a new subscription to the user's account
  • GET - which subscriptions have been purchased by the user, to which pet they apply, when they were purchased, and when they expire
  • DELETE - terminate a user's subscription

1 {uuid} is the universally unique identifier returned when a GET request is made to the /persons endpoint by an authorized API integrator

The Swagger 2.0 / OAS YAML rendering is below including the data structures necessary for POST or returned by GET.

Swagger 2.0 File
By PetHub, 1 January, 2023

PetHub APIs support a number of endpoints that, with your feedback, we will continue to add to our library. The APIs below are what are currently in our catalog.

We've broken these up into 3 sections:

  • Sniffing Around - both the most commonly used API calls for starting an interaction with a user's account and also the calls you'll need when initially registering your application with PetHub and getting a user's permission to utilize their data
  • Digging Deeper - endpoints that help you dig deeper into a user's or pet's information
  • Webhooks - proactively pull information as well as register to have PetHub notify you when specific events have taken place (such as tags being scanned or lost pet alerts being sent, for example)

The fun stuff:

  • Sniffing Around:
    • Authorizations - before a 3rd party application may interact with a PetHub user's account and data, it may first receive authorization from the PetHub user
    • Persons - the end-user with the account on PetHub who has control of their own and their pet's content
    • Pets - the profiles of the animals managed by the PetHub platform
  • Digging Deeper:
    • Activities - walking, agility, eating, playing, training, sleeping, pooping, and more. This is how you list it and add to it for a particular pet
    • Foods - manufacturer, formula, type (wet? kibble? raw?), amount, timing, and special preparation instructions can be found or added to for a pet with this endpoint
    • LostPets - pull a list of lost pet posters for a user, specific pet, by geo location, and more. Or, add to our list of Lost Pet posters
    • Perks - view which discounts a PetHub subscriber has claimed or the entire list of Perks that could be claimed
    • Species - pull the list of species supported by the PetHub platform or look-up the species for a specific pet
    • Tags - ability to look-up tag information including a pet's profile information if publicly published by the pet owner
  • Webhooks:
    • Alerts - announcements about missing or found animals
    • Notifications - tag scanning events (webhook) for a particular pet or particular tag ID

Each of these can be accessed with permission from the user whose data is being requested. In addition, the user can see which applications have been given permission to use their data which can be revoked at any time. Lastly, the user can control which of these types of resources each application is allowed to access on a read / write / update / delete basis.

By PetHub, 1 January, 2023

In the case of our favorite original tester, Grizzly, requesting his information would take the following form:

curl -H "Authorization: Bearer abc123" GET https://pethub.io/v1/pets/223

The above authorized call to PetHub.io's "/v1/pets/{id}" endpoint with Grizzly's unique identifier (where "223" replaces the "{id}") would receive the following response:

{
    "pid": "223",
    "uid": "66",
    "name": "Grizzly",
    "species": {
      "tid": "3031"
    },
    "breed_primary": {
      "target_id": "2855"
    },
    "breed_mix": "Chihuahua",
    "gender": "Male",
    "picture": {
      "fid": "189",
      "uid": "66",
      "filename": "grizzly.jpg",
      "filemime": "image/jpeg",
      "filesize": "7735",
      "status": "1",
      "timestamp": "1414801248",
      "type": "image",
      "metadata": {
        "height": 280,
        "width": 186
      },
      "height": "280",
      "width": "186",
      "url": "https://images.pethub.com/dev/pub/grizzly.jpg?milgJeq.a.UHYX6vfvnF7f2alm0p1Y5H"
    },
    "birthday": "2013-11-16 00:00:00",
    "size": {
      "tid": "3236"
    },
    "weight_value": "4",
    "weight_unit": "lb",
    "coat": "Short Hair",
    "tail": {
      "tid": "3428"
    },
    "altered": {
      "value": "Yes"
    },
    "description": "Our precious fuzzi-wuzzums.",
    "microchip": ""
  }

The format of the data above is JSON which is the default format typically specified in the Header as part of the request. However, if necessary, the format can be explicitly requested by appending ".json" or ".xml" to the noun to receive JSON or XML formatted data, respectively. For example:

curl -H "Authorization: Bearer abc123" GET https://pethub.io/v1/pets.json/223