API Documentation - acmucsd-projects/green-team-backend GitHub Wiki

API Documentation

Trees

GET /trees/

Gets all BitByteTrees sorted in ascending alphabetical order and all BitByteNodes belonging to each of those trees

Request: No params

Response Body:

{
    "trees": BitByteTree[],
    "error": nullable
}

GET /trees/:id

Gets a specific BitByteTree and all its BitByteNodes by the BitByteTree's id

Request:

  • id: id of BitByteTree

Response Body:

{
    "tree": BitByteTree,
    "error": nullable
}

POST /trees/points

Increments a specific BitByteTree's points field by the number of points provided. Response does not return BitByteNodes of tree.

Request:

{
	"id": Integer,
	"points": Integer
}

Response Body:

{
    "tree": BitByteTreeSimple,
    "error": nullable
}

POST /trees/picture

Updates a BitByteTree's profile picture given a file in the request body.

Request:

  • multipart/form-data request body
  • "image": File
  • "id": Integer

Response Body:

{
    "tree": BitByteTreeSimple,
    "error": nullable
}

PUT /tree/:id

Updates a BitByteTree's fields given the desired fields in the request body. All fields in request are optional.

Request:

{
	"name": String,
	"points": Integer,
	"year": Integer,
	"description": String
}

Response:

{
	"tree": BitByteTreeSimple
}

Nodes

GET /nodes/

Gets all BitByteNodes in no particular order

Request: None

Response:

{
	"nodes": BitByteNode[],
	"error": nullable
}

GET /nodes/:id

Gets a BitByteNode by its id

Request:

  • id - id of BitByteNode

Response:

{
	"node": BitByteNode,
	"error": nullable
}

GET /nodes/:id/children

Gets all children of a particular BitByteNode, including itself.

Request:

  • id - id of root BitByteNode

Response:

{
	"nodes": BitByteNode[],
	"error": nullable
}

POST /nodes/

Creates a BitByteNode, as well as a BitByteTree if the BitByteNode's tree_name does not currently exist as a BitByteTree.

Request:

{
	"name": String,
	"username": String,
	"major": String,
	"college": String,
	"class_year": Integer,
	"tree_name": String,
	"quarter_joined": String,
	"linkedin": String,
	"facebook": String,
	"instagram": String,
	"profile_url": String,
	"opt_in": Boolean
}

Response:

{
	"node": BitByteNode,
	"error": nullable
}