Skip to content

API Documentation

Zachary Duvall edited this page Jan 25, 2021 · 16 revisions

The GoodTrees API is organized around REST. Our API has predictable resource oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes and verbs.

API routes are not user-facing and should only be used by developers.

ForestConnection

Endpoints for the ForestConnection resource:

Create ForestConnection

Mark tree as "climbed" or "want to climb", creates a ForestConnection between logged in user (userId) and tree they chose (treeId).

Parameter Type Description Notes
userId int id of user creating ForestConnection required, FK points to User.id
treeId int id of tree in new ForestConnection required, FK points to Tree.id
climbStatus boolean true - climbed, false - want to climb required

Returns

Returns the created ForestConnection object if successful, and returns an error otherwise.

Update ForestConnection

Update a ForestConnection to toggle status of "climbed" or "want to climb" (use "where" to indicate userId and treeId)

Parameter Type Description Notes
userId int id of user creating ForestConnection required, FK points to User.id
treeId int id of tree in new ForestConnection required, FK points to Tree.id
climbStatus boolean true - climbed, false - want to climb required

Returns

Returns the updated ForestConnection object if successful, and returns an error otherwise.

Delete ForestConnection

Delete a forest connection to remove that tree from users forest (use "where" to indicate userId and treeId)

Clone this wiki locally