RESTful API Idea - Digital Pet

November 11, 2019Understanding Networks


For this assignment, my partner Andrew and I wanted to create a digital and physical virtual pet experience, similar to a Tamagotchi.

The REST application offers a representation of a digital pet that needs, food, love, and to be cleaned, that can be interacted with via a web interface. The physical computing aspect of this project is an internet-of-thing "pet" that in some way indicates the "happiness" of the pet, affected by its care.

Screen Shot 2019-11-11 at 11.23.17 PM

Details on the REST application

The REST application will store attributes about the pet's care. These attributes can be interacted with over a client-side web interface.

Attributes of the pet:

Hunger satisfaction level

  • How satisfied is the pet’s hunger?
  • This level decrements over time.
  • This level starts at 0 and maxes out at 10.

Love satisfaction level

  • How much love does the pet have?
  • This level decrements over time.
  • This level starts at 0 and maxes out at 10.

Cleanliness level

  • How clean is the pet?
  • This level decrements over time.
  • This level starts at 0 and maxes out at 10.

The attributes tick and decrement at a predetermined time interval, eg every hour.

A physical avatar communicating the state of the simulation

In addition to the application simulating the pet, the system will include a physical “pet” that can represent the state of the pet’s overall happiness. We define “overall happiness” to be the sum of the hunger, love, and cleanliness levels, out of the total number of 30 points. For example if we have hunger = 4/10, love = 2/10, cleanliness = 9/10, overall happiness will be 15/30.

The way the physical pet can represent this overall happiness level is up to the builders interpretation. For example, it can be as simple as turning an LED within the pet “on” if the happiness is over a certain threshold, and “off” if it is below that threshold.

The pet will be making continuous GET requests, at an interval up to the builder’s discretion to the level of the pet’s overall happiness.

We also leave open the general physical form of the “pet” to the interpretation of the builders.

A web client to provide users with an easy way to trigger API calls

(Andrew and I are still a bit confused on the conventions behind RESTFUL API calls and will need to clarify our approach here)

The web client will first allow users to see the pet's attributes.


-> return data about the hunger, love, cleanliness, and happiness

The web client will allow users to take care of the pet, by pressing buttons that say "Feed", "Pet", and "Clean". Each of these three buttons will trigger API calls to the REST application and increase the value of fed-ness, loved-ness, and cleanliness, respectively.

Feed the Pet

HTTP PUT /pet/bowl -> {foods:1}

We feed the pet by a unit of 1, which should increase the fed level by 1.

Pet the Pet

HTTP PUT /pet/love/ -> {pat:1}

We pat the pet once, which should increase the love level by 1.

Clean the Poop

PUT /pet/cleanliness -> {isCleaned: true}

Sending the server "isCleaned: true" will clean the pet and return it to a full cleanliness level.

Again, hopefully in class we will clarify if this is the correct approach.