API
API endpoints are simulated on localhost:5000
Endpoints
Auth
User authentication
1. Register
Register a new account, returns a JWT token
EndFragment
Endpoint:
Method: POST
Type: URLENCODED
URL: http://localhost:5000/api/v1/usersBody:
| Key | Value | Description |
|---|---|---|
| test1@gmail.com | ||
| password | test123 | |
| firstName | Tester | |
| lastName | One |
More example Requests/Responses:
I. Example Request: Register
Body:
| Key | Value | Description |
|---|---|---|
| test1@gmail.com | ||
| password | test123 | |
| firstName | Tester | |
| lastName | One |
I. Example Response: Register
{
"_id": "64088e3da13ed24c5b9cefce",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MDg4ZTNkYTEzZWQyNGM1YjljZWZjZSIsImlhdCI6MTY3ODI4MjMwMSwiZXhwIjoxNjgwODc0MzAxfQ.F-XWdEFC5eUP5TmEpJCULDQzLn1e35MBop6wlzlFHIw",
"email": "test1@gmail.com",
"verified": false,
"profile": {
"UID": "64088e3da13ed24c5b9cefce",
"firstName": "Tester",
"lastName": "One",
"dob": null,
"country": null,
"sensors": [],
"rating": 0,
"projectsCompleted": 0
},
"wallet": {
"UID": "64088e3da13ed24c5b9cefce",
"balance": 0,
"_id": "64088e3da13ed24c5b9cefd2",
"__v": 0
}
}Status Code: 201
2. Login
Login to an existing account, returns a JWT token
Endpoint:
Method: POST
Type: URLENCODED
URL: http://localhost:5000/api/v1/users/loginBody:
| Key | Value | Description |
|---|---|---|
| test1@gmail.com | ||
| password | test123 |
More example Requests/Responses:
I. Example Request: Login
Body:
| Key | Value | Description |
|---|---|---|
| test1@gmail.com | ||
| password | test123 |
I. Example Response: Login
{
"_id": "64088e3da13ed24c5b9cefce",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY0MDg4ZTNkYTEzZWQyNGM1YjljZWZjZSIsImlhdCI6MTY3ODI4MjUyNywiZXhwIjoxNjgwODc0NTI3fQ.xxch0RMyaHlg48IvIYIh1-ctwfjLDjLOmgyGzmf5Qc8",
"email": "test1@gmail.com",
"verified": false,
"profile": {
"UID": "64088e3da13ed24c5b9cefce",
"firstName": "Tester",
"lastName": "One",
"dob": null,
"country": null,
"sensors": [],
"rating": 0,
"projectsCompleted": 0
},
"wallet": {
"_id": "64088e3da13ed24c5b9cefd2",
"UID": "64088e3da13ed24c5b9cefce",
"balance": 0,
"__v": 0
}
}Status Code: 201
Project
1. Create project
Creating a new project on the platform
Endpoint:
Method: POST
Type: RAW
URL: http://localhost:5000/api/v1/projectsBody:
{
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000+00:00",
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 20,
"serviceCost": 20,
"rewards": 5,
"privateProject": false
}More example Requests/Responses:
I. Example Request: Create project
Body:
{
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000+00:00",
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 20,
"serviceCost": 20,
"rewards": 5,
"privateProject": false
}I. Example Response: Create project
{
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000Z",
"status": 0,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 20,
"participants": 0,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"_id": "640896a723b2bd761d307e0b",
"__v": 0
}Status Code: 200
2. Get projects
Get all active and public projects
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/projectsMore example Requests/Responses:
I. Example Request: Get projects
Body: None
I. Example Response: Get projects
[
{
"_id": "640896a723b2bd761d307e0b",
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"end": "2023-04-08T14:00:00.000Z",
"status": 1,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 5,
"participants": 0,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"__v": 0
}
]Status Code: 200
3. Get project
Get details for a specific project
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/projects/:pidURL variables:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
More example Requests/Responses:
I. Example Request: Get project
Query:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
Body: None
I. Example Response: Get project
{
"_id": "640896a723b2bd761d307e0b",
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000Z",
"status": 0,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 5,
"participants": 0,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"__v": 0
}Status Code: 200
4. Get owned projects
Get a list of all owned projects
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/projects/ownMore example Requests/Responses:
I. Example Request: Get owned projects
Body: None
I. Example Response: Get owned projects
[
{
"_id": "640896a723b2bd761d307e0b",
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000Z",
"status": 0,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 20,
"participants": 0,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"__v": 0
}
]Status Code: 200
5. Get saved projects
Get a list of all saved projects (pending payment)
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/projects/savedMore example Requests/Responses:
I. Example Request: Get saved projects
Body: None
I. Example Response: Get saved projects
[
{
"_id": "640896a723b2bd761d307e0b",
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000Z",
"status": 0,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 20,
"participants": 0,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"__v": 0
}
]Status Code: 200
6. Get active projects
Get a list of all active projects
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/projects/activeMore example Requests/Responses:
I. Example Request: Get active projects
Body: None
I. Example Response: Get active projects
[
{
"_id": "640896a723b2bd761d307e0b",
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000Z",
"status": 1,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 5,
"participants": 0,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"__v": 0
}
]Status Code: 200
7. Get completed projects
Get a list of all completed projects
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/projects/completedMore example Requests/Responses:
I. Example Request: Get completed projects
Body: None
I. Example Response: Get completed projects
[
{
"_id": "640896a723b2bd761d307e0b",
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000Z",
"status": 2,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 5,
"participants": 1,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"__v": 0
}
]Status Code: 200
8. Start project
Start a saved project to trigger payments and set project to active
Endpoint:
Method: POST
Type: URLENCODED
URL: http://localhost:5000/api/v1/projects/startBody:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
More example Requests/Responses:
I. Example Request: Start project
Body:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
I. Example Response: Start project
{
"_id": "640896a723b2bd761d307e0b",
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000Z",
"status": 1,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 5,
"participants": 0,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"__v": 0
}Status Code: 200
9. Update project
Update project information
Endpoint:
Method: PUT
Type: RAW
URL: http://localhost:5000/api/v1/projects/:pidURL variables:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
Body:
{
"maxParticipants": 5,
"status": 2
}More example Requests/Responses:
I. Example Request: Update project
Query:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
Body:
{
"maxParticipants": 5
}I. Example Response: Update project
{
"_id": "640896a723b2bd761d307e0b",
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000Z",
"status": 0,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 5,
"participants": 0,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"__v": 0
}Status Code: 200
10. Delete Project
Delete a project
Endpoint:
Method: DELETE
Type:
URL: http://localhost:5000/api/v1/projects/:pidURL variables:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
More example Requests/Responses:
I. Example Request: Delete Project
Query:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
Body: None
I. Example Response: Delete Project
{
"id": "640896a723b2bd761d307e0b"
}Status Code: 200
Profile
1. Get profile
Get public information for a specific user
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/profiles/:uidURL variables:
| Key | Value | Description |
|---|---|---|
| uid | 64088e3da13ed24c5b9cefce |
More example Requests/Responses:
I. Example Request: Get profile
Query:
| Key | Value | Description |
|---|---|---|
| uid | 64088e3da13ed24c5b9cefce |
Body: None
I. Example Response: Get profile
{
"UID": "64088e3da13ed24c5b9cefce",
"country": null,
"sensors": []
}Status Code: 200
2. Get own profile
Get own profile information
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/profiles/More example Requests/Responses:
I. Example Request: Get own profile
Body: None
I. Example Response: Get own profile
{
"_id": "64088e3da13ed24c5b9cefd0",
"UID": "64088e3da13ed24c5b9cefce",
"firstName": "Tester",
"lastName": "One",
"dob": null,
"country": null,
"sensors": [],
"rating": 0,
"projectsCompleted": 0,
"__v": 0
}Status Code: 200
3. Update profile
Update own profile information
Endpoint:
Method: POST
Type: RAW
URL: http://localhost:5000/api/v1/profiles/Body:
{
"sensors": [
0,
1,
2,
3
]
}More example Requests/Responses:
I. Example Request: Update profile
Body:
{
"sensors": [
0,
1,
2,
3
]
}I. Example Response: Update profile
{
"_id": "64088e3da13ed24c5b9cefd0",
"UID": "64088e3da13ed24c5b9cefce",
"firstName": "Tester",
"lastName": "One",
"dob": null,
"country": null,
"sensors": [
0,
1,
2,
3
],
"rating": 0,
"hiddenRating": 0,
"projectsCompleted": 0,
"__v": 0
}Status Code: 200
Request
Action requests
1. New join request
Trigger join action for a user joining a project
Endpoint:
Method: POST
Type: URLENCODED
URL: http://localhost:5000/api/v1/requests/projectBody:
| Key | Value | Description |
|---|---|---|
| projectID | 640896a723b2bd761d307e0b |
More example Requests/Responses:
I. Example Request: New join request
Body:
| Key | Value | Description |
|---|---|---|
| projectID | 640896a723b2bd761d307e0b |
I. Example Response: New join request
{
"UID": "64088e3da13ed24c5b9cefce",
"projectID": "640896a723b2bd761d307e0b",
"status": 1,
"rated": false,
"_id": "640897ec23b2bd761d307e3e",
"__v": 0
}Status Code: 200
Work
Work for accepted projects
1. Get works
Get a list of all works the current user has accepted
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/worksMore example Requests/Responses:
I. Example Request: Get works
Body: None
I. Example Response: Get works
[
{
"_id": "640897ec23b2bd761d307e3e",
"UID": "64088e3da13ed24c5b9cefce",
"projectID": {
"_id": "640896a723b2bd761d307e0b",
"ownerUID": "63fbec1fe9fd6ffde190056c",
"title": "Unisense",
"description": "An insight into uni travels",
"details": "The project aims to understand the commute from uni students reaching their first class from their house",
"instructions": "Begin data collection when leaving your house and stop when you reach your first class",
"end": "2023-04-08T14:00:00.000Z",
"status": 1,
"private": false,
"sensors": [
0,
1,
2,
3
],
"lowFrequency": [
0,
1
],
"medFrequency": [
2
],
"highFrequency": [
3
],
"maxParticipants": 5,
"participants": 1,
"serviceCost": 800,
"rewards": 5,
"partialRewards": false,
"__v": 0
},
"status": 1,
"rated": false,
"__v": 0
}
]Status Code: 200
2. Get project works
Get a list of all works for a project
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/works/project/:pidURL variables:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
More example Requests/Responses:
I. Example Request: Get project works
Query:
| Key | Value | Description |
|---|---|---|
| pid | 640896a723b2bd761d307e0b |
Body: None
I. Example Response: Get project works
[
{
"_id": "640897ec23b2bd761d307e3e",
"UID": "64088e3da13ed24c5b9cefce",
"projectID": "640896a723b2bd761d307e0b",
"status": 1,
"rated": false,
"__v": 0
}
]Status Code: 200
3. Complete work
Complete a work and submit collected sensor data
Endpoint:
Method: POST
Type: URLENCODED
URL: http://localhost:5000/api/v1/works/complete/:widURL variables:
| Key | Value | Description |
|---|---|---|
| wid | 640897ec23b2bd761d307e3e |
Body:
| Key | Value | Description |
|---|---|---|
| result | www.resulturl.com (opens in a new tab) |
More example Requests/Responses:
I. Example Request: Complete work
Query:
| Key | Value | Description |
|---|---|---|
| wid | 640897ec23b2bd761d307e3e |
Body:
| Key | Value | Description |
|---|---|---|
| result | www.resulturl.com (opens in a new tab) |
I. Example Response: Complete work
{
"_id": "640897ec23b2bd761d307e3e",
"UID": "64088e3da13ed24c5b9cefce",
"projectID": "640896a723b2bd761d307e0b",
"status": 2,
"rated": false,
"__v": 0
}Status Code: 200
4. Update work
Update work information
Endpoint:
Method: POST
Type: RAW
URL: http://localhost:5000/api/v1/works/:widURL variables:
| Key | Value | Description |
|---|---|---|
| wid | 640897ec23b2bd761d307e3e |
Body:
{
"status": 3
}More example Requests/Responses:
I. Example Request: Update work
Query:
| Key | Value | Description |
|---|---|---|
| wid | 640897ec23b2bd761d307e3e |
Body:
{
"status": 3
}I. Example Response: Update work
{
"_id": "640897ec23b2bd761d307e3e",
"UID": "64088e3da13ed24c5b9cefce",
"projectID": "640896a723b2bd761d307e0b",
"status": 3,
"rated": false,
"__v": 0
}Status Code: 200
Wallet
1. Get wallet
Get the wallet for the currently logged in user
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/walletMore example Requests/Responses:
I. Example Request: Get wallet
Body: None
I. Example Response: Get wallet
{
"_id": "64088e3da13ed24c5b9cefd2",
"UID": "64088e3da13ed24c5b9cefce",
"balance": 10000,
"__v": 0
}Status Code: 200
2. Topup
Deposit credits to the wallet
Endpoint:
Method: POST
Type: RAW
URL: http://localhost:5000/api/v1/wallet/topupBody:
{
"amount": 10000
}More example Requests/Responses:
I. Example Request: Topup
Body:
{
"amount": 10000
}I. Example Response: Topup
{
"_id": "64088e3da13ed24c5b9cefd2",
"UID": "64088e3da13ed24c5b9cefce",
"balance": 10000,
"__v": 0
}Status Code: 200
3. Pay
Transfer credits from the currently logged in user to another user
Endpoint:
Method: POST
Type: RAW
URL: http://localhost:5000/api/v1/wallet/pay/:uidURL variables:
| Key | Value | Description |
|---|---|---|
| uid | 63fbec1fe9fd6ffde190056c |
Body:
{
"amount": 5
}More example Requests/Responses:
I. Example Request: Pay
Query:
| Key | Value | Description |
|---|---|---|
| uid | 63fbec1fe9fd6ffde190056c |
Body:
{
"amount": 5
}I. Example Response: Pay
{
"_id": "64088e3da13ed24c5b9cefd2",
"UID": "64088e3da13ed24c5b9cefce",
"balance": 7045,
"__v": 0
}Status Code: 200
4. Withdraw
Withdraw credits from the currently logged in user
Endpoint:
Method: POST
Type: RAW
URL: http://localhost:5000/api/v1/wallet/withdrawBody:
{
"amount": 200
}More example Requests/Responses:
I. Example Request: Withdraw
Body:
{
"amount": 200
}I. Example Response: Withdraw
{
"_id": "64088e3da13ed24c5b9cefd2",
"UID": "64088e3da13ed24c5b9cefce",
"balance": 7050,
"__v": 0
}Status Code: 200
Sensors
1. Sensors
Get all supported platform sensors
Endpoint:
Method: GET
Type:
URL: http://localhost:5000/api/v1/sensorsMore example Requests/Responses:
I. Example Request: Sensors
Body: None
I. Example Response: Sensors
[
{
"_id": "64089235461bbd8cf0acbe0f",
"value": 0,
"label": "Gyroscope"
},
{
"_id": "64089292461bbd8cf0acbe10",
"value": 1,
"label": "Accelerometer"
},
{
"_id": "640892a1461bbd8cf0acbe11",
"value": 2,
"label": "Barometer"
},
{
"_id": "640892aa461bbd8cf0acbe12",
"value": 3,
"label": "Magnetometer"
}
]Status Code: 200
API Documentation generated with docgen (opens in a new tab) with Postman (opens in a new tab) collection