API document for Nutivity App
POST /auth/login
Content-type: application/json
Parameter | Type | Description |
---|---|---|
username |
email |
Required |
password |
string |
Required |
Response:
{
"user": {
"user_id": 13,
"email": "lisaSmai@metropolia.fi",
"name": "Lisa Smai",
"user_filename": "",
"role": 2
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoxMywiZW1haWwiOiJsaXNhU21haUBtZXRyb3BvbGlhLmZpIiwibmFtZSI6Ikxpc2EgU21haSIsInVzZXJfZmlsZW5hbWUiOiIiLCJyb2xlIjoyLCJpYXQiOjE2Mzk1ODAxNTZ9.0fHjziSRq5MaUSPu_wxpet9EWQEJBUncjYnWnzLRHmk"
POST /auth/register
Content-type: multipart/form-data
Parameter | Type | Description |
---|---|---|
name |
string |
Required, min length 3 |
email |
email |
Required, email |
password |
string |
Required, min length 8 characters, at least one capital letter |
filename |
file |
Optional |
Response:
{
"message": "Successfully registered!",
"emailValid": true
}
GET /activity
Authorization: Bearer token
Guest mode does not require authorization
Response:
[
{
"owner": "Jessica Medrod",
"owner_id": 8,
"activity": "Hiking",
"id": 14,
"location": "Espoo",
"description": "Hiking in Nuuksio",
"filename": "f7ab22def71d542757f65fcb8ea3258a",
"VST": "2021-12-08T09:18:03.000Z",
"VET": "2022-11-30T15:00:00.000Z",
"participantNum": 2
},
]
POST /activity
Authorization: Bearer token
Content-type: multipart/form-data
Parameter | Type | Description |
---|---|---|
name |
string |
Required, min length 3 |
location |
string |
Required, YYYY-MM-DD |
description |
string |
Required |
VET |
datetime |
Required |
filename |
file |
Required, jpg, png, gif |
Response:
message "activity added with id: 97"
GET /activity/:activityId
Authorization: Bearer token
Parameter | Type | Description |
---|---|---|
activityId |
int |
Required. Id of activity to fetch |
Response:
{
"owner": "Khava Gali",
"owner_id": 7,
"activity": "Fishing",
"id": 15,
"location": "Espoo",
"description": "Fishing in Nuuksio",
"filename": "34a10943cfd1e406ef28d2d9150769ab",
"VST": "2021-12-01T09:57:44.000Z",
"VET": "2022-01-01T10:00:00.000Z",
"participantNum": 4
}
DELETE /activity/:activityId
Authorization: Bearer token
Parameter | Type | Description |
---|---|---|
activityId |
int |
Required. Id of activity to delete |
Response:
{
"message": "Activity deleted"
}
POST /activity/participation/:activityId
Authorization: Bearer token
Parameter | Type | Description |
---|---|---|
activityId |
int |
Required. Id of activity |
userId |
int |
Required. Id of the logged in user from the session storage |
Response:
{
"message": "add participation data { userId: '6' }"
}
DELETE /activity/participation/:activityId
Authorization: Bearer token
Parameter | Type | Description |
---|---|---|
activityId |
int |
Required. Id of activity |
userId |
int |
Required. Id of the logged in user from the session storage |
Response:
{
"message": "Participation deleted"
}
GET /activity/comment/:activityId
Authorization: Bearer token
Parameter | Type | Description |
---|---|---|
activityId |
int |
Required. Id of activity to fetch |
Response:
{
"user": "The mighty admin",
"user_id": 1,
"activity": "Hiking",
"comment": "Yay play",
"time": "2021-12-14T19:02:59.000Z"
}
GET /activity/comment/:activityId
Authorization: Bearer token
Content-type: application/json
Parameter | Type | Description |
---|---|---|
activityId |
int |
Required. Id of activity to fetch |
comment |
string |
Required. Content of the comment |
Response:
{"message": "new comment id: 122"}
GET /user
Authorization: Bearer token
[
{
"user_id": 1,
"email": "dieu-test@metropolia.fi",
"name": "The mighty admin",
"user_filename": "1639584006904.png",
"role": 0
},
{
"user_id": 4,
"email": "xiaoming@metropolia.fi",
"name": "Alex",
"user_filename": "1639564826179.png",
"role": 0
}
]
GET /user/:id
Authorization: Bearer token
Parameter | Type | Description |
---|---|---|
id |
int |
Required. Id of the user to fetch |
Response:
{
"user_id": 1,
"email": "dieu-test@metropolia.fi",
"name": "The mighty admin",
"user_filename": "1639584006904.png",
"role": 0,
"ownActivity": [
{
"activity_id": 17,
"name": "Swimming",
"location": "Helsinki",
"description": "Swimming in this weekend",
"filename": "a00f631933d073d58219cd0959e89296",
"owner": 1,
"VST": "2021-12-03T11:13:08.000Z",
"VET": "2022-01-29T10:00:00.000Z",
"owner_name": "The mighty admin",
"num_participant": 2
},
{
"activity_id": 87,
"name": "Skateboarding",
"location": "Helsinki",
"description": "Skateboarding in Helsinki",
"filename": "1639560269822.jpg",
"owner": 1,
"VST": "2021-12-15T09:24:29.000Z",
"VET": "2022-01-16T10:00:00.000Z",
"owner_name": "The mighty admin",
"num_participant": null
}
],
"participateActivity": [
{
"participant": 1,
"activity": 14,
"activity_id": 14,
"name": "Hiking",
"location": "Espoo",
"description": "Hiking in Nuuksio",
"filename": "f7ab22def71d542757f65fcb8ea3258a",
"owner": 8,
"VST": "2021-12-08T09:18:03.000Z",
"VET": "2022-11-30T15:00:00.000Z",
"owner_name": "Jessica Medrod",
"num_participant": 2
},
{
"participant": 1,
"activity": 15,
"activity_id": 15,
"name": "Fishing",
"location": "Espoo",
"description": "Fishing in Nuuksio",
"filename": "34a10943cfd1e406ef28d2d9150769ab",
"owner": 7,
"VST": "2021-12-01T09:57:44.000Z",
"VET": "2022-01-01T10:00:00.000Z",
"owner_name": "Khava Gali",
"num_participant": 4
}
]
}
PUT /user/:id
Authorization: Bearer token
Content-type: multipart/form-data
Parameter | Type | Description |
---|---|---|
id |
int |
Required, user_id of the user, admin only |
name |
string |
Optional, min length 3 |
email |
email |
Optional, email |
filename |
file |
Optional |
Response:
- If email input is not existing in database:
{
"message": "Successfully updated profile!", "emailValid": true
}
- If email input is existing in database:
{
"message": "Email address is taken!",
"emailValid": true
}
PUT /user/:id/passwordChange
Authorization: Bearer token
Content-type: application/json
Parameter | Type | Description |
---|---|---|
currentPassword |
string |
Required, min length 8 characters, at least one capital letter |
newPassword |
string |
Required, min length 8 characters, at least one capital letter |
checkPassword |
string |
Required, min length 8 characters, at least one capital letter |
id |
int |
Required, user_id of the user |
Response:
- If current password correct:
{
"message": "Update password succeeded"
}
- If current password incorrect:
{
"message": "Update password failed, old password incorrect"
}
PUT /user/:id
Authorization: Bearer token
Parameter | Type | Description |
---|---|---|
id |
int |
Required, user_id of the user, admin only |
Response:
- If demoting user:
{
"message": "User demotion succeeded"
}
- If promoting user:
{
"message": "User promotion succeeded"
}
DELETE /user/:id
Authorization: Bearer token
Parameter | Type | Description |
---|---|---|
id |
int |
Required, user_id of the user, admin only |
Response:
{
"message": "Account has been deleted."
}
GET /user/token
Authorization: Bearer token
Response:
{
"user_id":1,
"email":"dieu-test@metropolia.fi",
"name":"The mighty admin",
"user_filename":"1639568891350.png",
"role":0
}
GET /activity/last24hours/list
Authorization: Bearer token
Guest mode does not require authorization
Response:
[
{
"owner": "The mighty admin",
"owner_id": 1,
"activity": "Skateboarding",
"id": 87,
"location": "Helsinki",
"description": "Skateboarding in Helsinki",
"filename": "1639560269822.jpg",
"VST": "2021-12-15T09:24:29.000Z",
"VET": "2022-01-16T10:00:00.000Z",
"participantNum": 0
},
{
"owner": "The mighty admin",
"owner_id": 1,
"activity": "Movie night",
"id": 96,
"location": "Lapland",
"description": "Have fun with friends",
"filename": "1639585203987.jpg",
"VST": "2021-12-15T16:20:04.000Z",
"VET": "2022-01-01T21:00:00.000Z",
"participantNum": 0
}
]
GET /activity/searchDate/:searchDate
Authorization: Bearer token
Guest mode does not require authorization
Parameter | Type | Description |
---|---|---|
searchDate |
datetime |
Required, search date |
Response: For example searchDate = '2022-01-01'
[
{
"owner": "Khava Gali",
"activity": "Fishing",
"id": 15,
"location": "Espoo",
"description": "Fishing in Nuuksio",
"filename": "34a10943cfd1e406ef28d2d9150769ab",
"VST": "2021-12-01T09:57:44.000Z",
"VET": "2022-01-01T10:00:00.000Z",
"participantNum": 4
},
{
"owner": "The mighty admin",
"activity": "Movie night",
"id": 96,
"location": "Lapland",
"description": "Have fun with friends",
"filename": "1639585203987.jpg",
"VST": "2021-12-15T16:20:04.000Z",
"VET": "2022-01-01T21:00:00.000Z",
"participantNum": 0
}
]
GET /activity/searchDate/:searchLocation
Authorization: Bearer token
Guest mode does not require authorization
Parameter | Type | Description |
---|---|---|
searchLocation |
string |
Required, search location |
Response: For example location = 'espoo'
[[
{
"owner": "Jessica Medrod",
"activity": "Hiking",
"id": 14,
"location": "Espoo",
"description": "Hiking in Nuuksio",
"filename": "f7ab22def71d542757f65fcb8ea3258a",
"VST": "2021-12-08T09:18:03.000Z",
"VET": "2022-11-30T15:00:00.000Z",
"participantNum": 2
},
{
"owner": "Khava Gali",
"activity": "Fishing",
"id": 15,
"location": "Espoo",
"description": "Fishing in Nuuksio",
"filename": "34a10943cfd1e406ef28d2d9150769ab",
"VST": "2021-12-01T09:57:44.000Z",
"VET": "2022-01-01T10:00:00.000Z",
"participantNum": 4
}
]
GET /activity/searchDate/:searchType
Authorization: Bearer token
Guest mode does not require authorization
Parameter | Type | Description |
---|---|---|
searchType |
string |
Required, search string |
Response: For example location = 'badminton'
[
{
"owner": "Jasmin P.",
"activity": "Badminton",
"id": 82,
"location": "Turku",
"description": "Looking for a badminton buddy.",
"filename": "1639407176755.jpg",
"VST": "2021-12-13T14:52:56.000Z",
"VET": "2021-12-30T07:00:00.000Z",
"participantNum": 1
}
]
GET /activity/participants/:activityId
Authorization: Bearer token
Parameter | Type | Description |
---|---|---|
searchDate |
datetime |
Required, search date |
Response:
[
{
"name": "The mighty admin",
"activity": 14
},
{
"name": "alifah",
"activity": 14
}
]