Skip to main content

API

Backend REST API

POST /users/create

Description:
Create a new user and store it in the database.

Valid Request Body:

{
"email": String,
"password": String
}

Successful call:

{
"status": 201,
"body": "A new user has been successfully created."
}

Failed call:

{
"status": 409,
"body": "Email already in use."
}
{
"status": 400,
"message": "Missing data in request body."
}

PUT /users/update/{id}

Description:
Update a user's data in the database.

Path Variable:

  • {id}: String

Valid Request Body:

{
"email": String,
"password": String
}

or

{
"email": String
}

or

{
"password": String
}

Successful call:

{
"status": 200,
"body": "User with ID: {id} has been updated."
}

Failed call:

{
"status": 409,
"body": "No fields updated. Email already in use."
}
{
"status": 409,
"body": "User with ID: {id} does not exist."
}

DELETE /users/delete/{id}

Description:
Delete an existing user from the database.

Path Variable:

  • {id}: String

Valid Request Body:
No request body required.

Successful call:

{
"status": 200,
"body": "User with ID: {id} has been deleted."
}

Failed call:

{
"status": 409,
"body": "User with ID: {id} does not exist."
}

GET /users/login

Description:
Verify user login information.

Valid Request Body:

{
"email": String,
"password": String
}

Successful call:

id: Integer

Failed call:

{
"status": 409,
"body": "User with ID: {id} does not exist."
}
{
"status": 409,
"body": "Incorrect password."
}

GET /users/get/{id}

Description:
Get user email from an ID.

Valid Request Body:
No request body required.

Successful call:

email: String

Failed call:

{
"status": 409,
"body": "User with ID: {id} does not exist."
}

Raspberri Pi API

POST /createNode/{location}

Description:
Create node at specific location.

Parameters:

  • {location}: String

Successful call:

{
"success": "200: updated properly",
"LocationID": Integer
}

Failed call:

{
"error": "401: invalid location"
}
{
"error": "404: connection broken"
}

PUT /update/{locationID, number of spots}

Description:
Rasberry pi sends information about the number of spots at a specific location.

Parameters:

  • {locationID}: int
  • {number of spots}: int

Successful call:

{
"success": "200: updated properly"
}

Failed call:

{
"error": "401: invalid location"
}
{
"error": "402: invalid invalid number of spots"
}
{
"error": "404: connection broken"
}

DELETE /location/{locationID}

Description:
Delete node with locationID.

Parameters:

  • {locationID}: int

Successful call:

{
"success", "200: deleted sucessfully"
}

Failed call:

{
"error": "401: invalid location"
}
{
"error": "404: connection broken"
}