Skip to content
This repository was archived by the owner on Mar 2, 2022. It is now read-only.

API Structure

Gregory Kelly edited this page Dec 9, 2021 · 2 revisions

The backend is accessible through a REST API, with responses provided in JSON format

General

/status (GET)

/status (GET)

Get the list of supported schools

Parameters

None

Response

API Response Data

{
	"status": string		- "Alive" on success
}

User Endpoints

/users/{user} (GET)

/users/{user} (GET)

Get a user by id

Parameters

Name Location Description
id path User's id

Response

On failure, returns error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success
	"user": {					- Payload, undefined on failure
		"id": string,				- Registered user's ID
		"name": string,				- Registered user's name
		"school": string			- Registered user's school's ID
	}
}

/users/{user}/courses (GET)

/users/{user}/courses (GET)

Get courses owned by a user

Parameters

Name Location Description
id path User's id

Response

On failure, returns error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success
	"courses": [				- Payload, undefined on failure 
		{
			"id": string,			- ID of the course
			"name": string,			- Name of the course
			"code": string,			- Course code of the course
			"year": int,			- Academic year of the course
			"term": string,			- Term of the course
			"prof": string,			- Professor teaching the course
			"owner": string,		- ID of the user who maintains the course
			"school": string,		- ID of the course's school 
			"modified": long int	- Unix timestamp the course or it's children were last modified
		}
	]
}

Authentication

/users/register (POST)

/users/register (POST)

Register a new user

Parameters

Name Location Description
name post User's name
email post User's email
password post User's password
school post ID of user's chosen school

Response

On failure, returns error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success
	"user": {					- Payload, undefined on failure
		"id": string,				- Registered user's ID
		"name": string,				- Registered user's name
		"email": string,			- Registered user's email
		"school": string			- Registered user's school's ID,
		"token": string				- Authentication token for the user's session 
	}
}

/users/login (POST)

/users/login (POST)

Log in to a user account

Parameters

Name Location Description
email post Email being used to log in
password post Password being used to log in

Response

On success, returns information about logged in user. On failure, returns error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success 
	"user": {				 	- Payload, undefined on failure
		"id": string,				- Registered user's ID
		"name": string,				- Registered user's name
		"email": string,			- Registered user's email
		"school": string			- Registered user's school's ID 
		"token": string				- Authentication token for the user's session 
  }
}

Course Subscriptions

/users/subscriptions/get (GET)

/users/subscriptions/get (GET)

Get courses subscribed to by a user, can be filtered by date modified

Parameters

Name Location Description
since query Timestamp to ignore courses modified before
token cookie Session token to get and authenticate user

Response

List of courses subscribed to by the user

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success 
	"courses": [				- Payload, undefined on failure 
		{
			"id": string,			- ID of the course
			"name": string,			- Name of the course
			"code": string,			- Course code of the course
			"year": int,			- Academic year of the course
			"term": string,			- Term of the course
			"prof": string,			- Professor teaching the course
			"owner": string,		- ID of the user who maintains the course
			"school": string,		- ID of the course's school 
			"modified": long int	- Unix timestamp the course or it's children were last modified
		}
	]
}

/users/subscriptions/add (POST)

/users/subscriptions/add (POST)

Subscribe to a new course

Parameters

Name Location Description
course post ID of the course to subscribe to
token cookie Session token to get and authenticate user

Response

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success 
	"subscription": {			- Payload, undefined on failure 
		"user": string,				- ID of the user subscribing
		"course": string			- ID of the course subscribed to
	}
}

/users/subscriptions/{course}/remove (POST)

/users/subscriptions/{course}/remove (POST)

Unsubscribe from a course

Parameters

Name Location Description
course path ID of the course to unsubscribe from
token cookie Session token to get and authenticate user

Response

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string				- Error message on failure, '' on success
}

To-Dos

/users/todos/get (GET)

/users/todos/get (GET)

Get To-Dos for a user

Parameters

Name Location Description
token cookie Session token to authenticate user

Response

List of To-Dos for the user

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success  
	"todos": [					- Payload, undefined on failure
		{
			"id": string,			- ID of the todo
			"user": string,			- ID of the todo's user
			"name": string,			- Name of the todo
			"completed": boolean,	- Todo completion flag
		}
	]
}

/users/todos/add (POST)

/users/todos/add (POST)

Create a To-Do for a user

Parameters

Name Location Description
name post Name of To-Do
token cookie Session token to get and authenticate user

Response

On success, created To-Do. On failure error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success  
	"todo": {				 	- Payload, undefined on failure
		"id": string,				- ID of the created todo
		"user": string,				- ID of the todo's user
		"name": string,				- Name of the created todo
		"completed": boolean		- Todo completion flag
	}
}

/users/todos/{todo}/modify (POST)

/users/todos/{todo}/modify (POST)

Modify a To-Do for a user

Parameters

Name Location Description
todo path ID of target To-Do
name post Name of To-Do
completed post Completion state of To-Do
token cookie Session token to get and authenticate user

Response

On success, updated To-Do. On failure error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success  
	"todo": {				 	- Payload, undefined on failure
		"id": string,				- ID of the todo
		"user": string,				- ID of the todo's user
		"name": string,				- Updated name of the created todo
		"completed": boolean		- Updated todo completion flag
	}
}

/users/todos/{todo}/remove (POST)

/users/todos/{todo}/remove (POST)

Delete a To-Do for a user

Parameters

Name Location Description
todo path ID of the To-Do to delete
token cookie Session token to get and authenticate user

Response

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string				- Error message on failure, '' on success   
}

Reminders

/users/reminders/get (GET)

/users/reminders/get (GET)

Get reminders for a user

Parameters

Name Location Description
token cookie Session token to get and authenticate user

Response

List of reminders for the user

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
	"reminders": [				- Payload, undefined on failure
		{
			"id": string,			- ID of the reminder
			"user": string,			- ID of the reminder's user
			"event": string			- ID of the event the reminder is for
		}
	]
}

/users/reminders/add (POST)

/users/reminders/add (POST)

Create a reminder for a user

Parameters

Name Location Description
event post Event reminder is for
token cookie Session token to get and authenticate user

Response

On success, created reminder.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
	"reminder": {				- Payload, undefined on failure
		"id": string,			- ID of the created reminder
		"user": string,			- ID of the reminder's user
		"event": string			- ID of the event the reminder is for
	}
}

/users/reminders/{reminder}/remove (POST)

/users/reminders/{reminder}/remove (POST)

Delete a reminder for a user

Parameters

Name Location Description
id post ID of the reminder to delete
token cookie Session token to get and authenticate user

Response

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string				- Error message on failure, '' on success   
}

School Endpoints

/schools/get (GET)

/schools/get (GET)

Get the list of supported schools

Parameters

None

Response

List of schools in database

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
	"schools": [				- Payload, undefined on failure
		{
			"id": string,			- ID of school
			"name": string,			- Name of school
		}
	]
}

/schools/{school}/courses/get (GET)

/schools/{school}/courses/get (GET)

Get courses for a specific school, can also filter by year and term.

Parameters

Name Location Description
school path ID of school to get courses for
year query Year of returned courses
term query Term of returned courses

Response

List with all courses for specified school

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
	"courses": [				- Payload, undefined on failure
		{
			"id": string,			- ID of the course
			"name": string,			- Name of the course
			"code": string,			- Course code of the course
			"year": int,			- Academic year of the course
			"term": string,			- Term of the course
			"prof": string,			- Professor teaching the course
			"owner": string,		- ID of the user who maintains the course
			"school": string,		- ID of the course's school 
			"modified": long int	- Unix timestamp the course or it's children were last modified 
		}
	]
}

Course Endpoints

/courses/add (POST)

/courses/add (POST)

Create a new course

Parameters

Name Location Description
name post Name of course
code post Course code
year post Course's academic year
term post Course term, one of 'Wint', 'Spri', 'Summ', 'Fall'
prof post Course professor
owner post ID of user creating course
school post ID of course's school
token cookie Session token to authenticate user

Response

On success, returns information about created course. On failure, returns error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
	"course": {					- Payload, undefined on failure
		"id": string,				- ID of the created course
		"name": string,				- Name of the course
		"code": string,				- Course code of the course
		"year": int,				- Academic year of the course
		"term": string,				- Term of the course
		"prof": string,				- Professor teaching the course
		"owner": string,			- ID of the user who maintains the course
		"school": string,			- ID of the course's school 
		"modified": long int		- Unix timestamp the course or it's children were last modified   
	}
}

/courses/{course}/modify (POST)

/courses/{course}/modify (POST)

Modify an existing course

Parameters

Name Location Description
course path ID of target course
name post Name of course
code post Course code
year post Course's academic year
term post Course term, one of 'Wint', 'Spri', 'Summ', 'Fall'
prof post Course professor
school post ID of course's school
token cookie Session token to authenticate user

Response

On success, returns updated course. On failure, returns error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
	"course": {					- Payload, undefined on failure
		"id": string,				- ID of the course
		"name": string,				- Updated name of the course
		"code": string,				- Updated course code
		"year": int,				- Updated academic year of the course
		"term": string,				- Updated term of the course
		"prof": string,				- Updated professor teaching the course
 		"owner": string,			- ID of the user who maintains the course
 		"school": string,			- Updated ID of the course's school 
		"modified": long int		- Unix timestamp the course or it's children were last modified   
	}
}

/courses/{course}/remove (POST)

/courses/{course}/remove (POST)

Delete a existing course

Parameters

Name Location Description
course path ID of target course
token cookie Session token to authenticate user

Response

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
}

Course Events

/courses/{course}/events/get (GET)

/courses/{course}/events/get (GET)

Get events corresponding to a course

Parameters

Name Location Description
course path ID of target course

Response

List of events corresponding to the course

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
	"events": [					- Payload, undefined on failure
		{
			"id": string,			- ID of the event
			"course": string,		- ID of the event's course
			"name": string,			- Name of the event
			"type": string,			- Type of event
			"weight": int,			- Grade weight of event
			"datetime": long int,	- Unix timestamp of event start
			"endDate": long int,	- Unix timestamp of event ending
			"weekly": boolean		- Flag to indicate if the event occurs each week
		}
	]
}

/courses/{course}/events/add (POST)

/courses/{course}/events/add (POST)

Create an event for a course

Parameters

Name Location Description
course path ID of target course
name post Name of the event
type post Type of event, one of "LECTURE", "TUTORIAL", "LAB", "TEST", "QUIZ", or "ASSIGNMENT"

weight

post

Grade weight in course

datetime post

Date/time of event, as unix timestamp

endDate post

Date/time of event end, as unix timestamp or omitted for instantaneous events

weekly post

True/False indicating if event should be repeated weekly

token cookie Session token to authenticate user

Response

On success, returns created event. On failure, returns error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
	"event": {					- Payload, undefined on failure
		"id": string,				- ID of the created event
		"course": string,			- ID of the event's course
		"name": string,				- Name of the event
		"type": string,				- Type of event
		"weight": int,				- Grade weight of event
		"datetime": long int,		- Unix timestamp of event start
		"endDate": long int,		- Unix timestamp of event ending
		"weekly": boolean			- Flag to indicate if the event occurs each week
	}
}

/courses/{course}/events/{event}/modify (POST)

/courses/{course}/events/{event}/modify (POST)

Modify an event for a course

Parameters

Name Location Description
course path ID of target course
event path ID of target event
name post Name of the event
type post Type of event, one of "LECTURE", "TUTORIAL", "LAB", "TEST", "QUIZ", or "ASSIGNMENT"

weight

post

Grade weight in course

datetime post

Date/time of event, as unix timestamp

endDate post

Date/time of event end, as unix timestamp or omitted for instantaneous events

weekly post

True/False indicating if event should be repeated weekly

token cookie Session token to authenticate user

Response

On success, returns modified event. On failure, returns error message.

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string,			- Error message on failure, '' on success   
	"event": {					- Payload, undefined on failure
		"id": string,				- ID of the event
		"course": string,			- ID of the event's course
		"name": string,				- Updated name of the event
		"type": string,				- Updated type of event
		"weight": int,				- Updated grade weight of event
		"datetime": long int,		- Updated unix timestamp of event start
		"endDate": long int,		- Updated unix timestamp of event ending
		"weekly": boolean			- Updated flag to indicate if the event occurs each week
	}
}

/courses/{course}/events/{event}/remove (POST)

/courses/{course}/events/{event}/remove (POST)

Delete and event from a course

Parameters

Name Location Description
course path ID of target course
event path ID of event to delete 
token cookie Session token to authenticate user

Response

API Response Data

{
	"success": bool,			- True on success, otherwise false
	"error": string 			- Error message on failure, '' on success   
}

Clone this wiki locally