Docs
Backend
API

API

⚠️

API endpoints are simulated on localhost:5000

Endpoints

  1. Login
  1. Get projects
  1. Get project
  1. Get owned projects
  1. Get saved projects
  1. Get active projects
  1. Get completed projects
  1. Start project
  1. Update project
  1. Delete Project
  1. Get own profile
  1. Update profile
  1. Get project works
  1. Complete work
  1. Update work
  1. Topup
  1. Pay
  1. Withdraw

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/users

Body:

KeyValueDescription
emailtest1@gmail.com
passwordtest123
firstNameTester
lastNameOne

More example Requests/Responses:

I. Example Request: Register

Body:

KeyValueDescription
emailtest1@gmail.com
passwordtest123
firstNameTester
lastNameOne

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/login

Body:

KeyValueDescription
emailtest1@gmail.com
passwordtest123

More example Requests/Responses:

I. Example Request: Login

Body:

KeyValueDescription
emailtest1@gmail.com
passwordtest123

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/projects

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
}

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/projects

More 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/:pid

URL variables:

KeyValueDescription
pid640896a723b2bd761d307e0b

More example Requests/Responses:

I. Example Request: Get project

Query:

KeyValueDescription
pid640896a723b2bd761d307e0b

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/own

More 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/saved

More 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/active

More 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/completed

More 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/start

Body:

KeyValueDescription
pid640896a723b2bd761d307e0b

More example Requests/Responses:

I. Example Request: Start project

Body:

KeyValueDescription
pid640896a723b2bd761d307e0b

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/:pid

URL variables:

KeyValueDescription
pid640896a723b2bd761d307e0b

Body:

{
    "maxParticipants": 5,
    "status": 2
}

More example Requests/Responses:

I. Example Request: Update project

Query:

KeyValueDescription
pid640896a723b2bd761d307e0b

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/:pid

URL variables:

KeyValueDescription
pid640896a723b2bd761d307e0b

More example Requests/Responses:

I. Example Request: Delete Project

Query:

KeyValueDescription
pid640896a723b2bd761d307e0b

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/:uid

URL variables:

KeyValueDescription
uid64088e3da13ed24c5b9cefce

More example Requests/Responses:

I. Example Request: Get profile

Query:

KeyValueDescription
uid64088e3da13ed24c5b9cefce

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/project

Body:

KeyValueDescription
projectID640896a723b2bd761d307e0b

More example Requests/Responses:

I. Example Request: New join request

Body:

KeyValueDescription
projectID640896a723b2bd761d307e0b

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/works

More 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/:pid

URL variables:

KeyValueDescription
pid640896a723b2bd761d307e0b

More example Requests/Responses:

I. Example Request: Get project works

Query:

KeyValueDescription
pid640896a723b2bd761d307e0b

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/:wid

URL variables:

KeyValueDescription
wid640897ec23b2bd761d307e3e

Body:

KeyValueDescription
resultwww.resulturl.com (opens in a new tab)

More example Requests/Responses:

I. Example Request: Complete work

Query:

KeyValueDescription
wid640897ec23b2bd761d307e3e

Body:

KeyValueDescription
resultwww.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/:wid

URL variables:

KeyValueDescription
wid640897ec23b2bd761d307e3e

Body:

{
    "status": 3
}

More example Requests/Responses:

I. Example Request: Update work

Query:

KeyValueDescription
wid640897ec23b2bd761d307e3e

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/wallet

More 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/topup

Body:

{
    "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/:uid

URL variables:

KeyValueDescription
uid63fbec1fe9fd6ffde190056c

Body:

{
    "amount": 5
}

More example Requests/Responses:

I. Example Request: Pay

Query:

KeyValueDescription
uid63fbec1fe9fd6ffde190056c

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/withdraw

Body:

{
    "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/sensors

More 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

Back to top