The test server ip-address:port is https://dashboard-test.diaper-project.com:5000

The production server ip-address:port is https://dashboard-prod.diaper-project.com:5000

The production server AWS Chalice:port is https://4wuiajclt6.execute-api.us-east-1.amazonaws.com/api/ (No Longer in Use)


URL/api/login/
DescriptionLogin a user, and set cookie for authentication
MethodPOST
Url Param
Request Body Data
  1. HTML Form Submission with fields:
    1. email (string)
    2. password (string)
    3. remember_me (optional boolean)
  2. Alternatively, you can manually add following fields in request body as a json format:
    1. email (string)
    2. password (string)
    3. remember_me (optional boolean)
    4. formdata (empty string)
Response
  • {message: "Logged in."} - 200
  • {message: "Bad request format"} - 400
  • {message: "invalid credential(s) provided, please check your credential(s) and try again"} - 400/401
Cookie
  • session: a cookie for trace login status
  • remember_token: a cookie for remember_me feature (only when logged in with remember_me set to true)
URL/api/users/<email>/request-password-reset/
DescriptionRequest an email with a link and access token to reset password
MethodPOST
Url Paramemail
Request Body Data


Response
  • {message: "Password reset email has been sent."} - 200
  • {message: "There was a problem sending the password reset email. Please try again later"} - 500
Cookie


URL/api/users/<email>/resetpassword/
DescriptionRequest an email with a link and access token to reset password
MethodPOST
Url Paramemail
Request Body Data

A json format data
{
  "password":  "<string-password>"
}

Response
  • {message: "Successfully updated password."} - 200
  • {message: "Unauthorized: you do not have access to reset this user's password"} - 401
Cookie


URL/api/registration/
DescriptionRegister a new user.
MethodPOST
Url Param
Request Body Data
  1. HTML Form Submission with fields:
    1. email (string)
    2. password (string)
    3. confirm_password (string)
    4. user_type (string)
  2. Alternatively, you can manually add following fields in request body as a json format:
    1. email (string)
    2. password (string)
    3. confirm_password (string)
    4. user_type (string)
    5. formdata (!EMPTY! string)
Response
  • {message: "Registered, please login."} - 200
  • {message: "Data input is not valid, please try again"} - 400
Cookie


URL/api/logout/
DescriptionLogout a user, set cookie/disable the token saved in cookie
MethodPOST
Url Param
Request Body Data


Response
  • {message: "logged out"} - 200
Cookie
  • session: will be removed
  • remember_token: will be removed
URL/api/samples/
DescriptionAdd sample data to mongoDB
MethodPOST
Url Param
Request Body Data

A json format data
{
"sample": {
"description": "test",
"image_url": "url",
"uploader": "uploader",
"sample_id": "0000",
"sample_type": "BS",
"infant_id": "00"
}
}

Response
  • {message: "Sample data recorded!"} - 200
  • {message: "Bad reques"} - 400
  • {message: "invalid credential(s) provided, please check your credential(s) and try again"} - 400/401
URL/api/mobile-samples/
DescriptionGet user's sample data from mobile database
MethodGET
Url Param


Response
  • {message: "Internal Error, please try again"} - 500
URL/api/mobile-samples/image/<barcode_id>
DescriptionGet sample image to mongoDB
MethodGET
Url Param barcode_id
Request Body Data
Response
    • {message: "Bad barcode id"} -400
    • {message: "Bad Request"} - 400
    • {message: "No image data found for barcode {barcode_id}"} - 404
    • {message: "No sample found for barcode {barcode_id}"} - 404
    • image - 200
URL/api/samples/image/<barcode_id>
DescriptionAdd sample image to mongoDB
MethodPOST
Url Param barcode_id
Request Body Data

files: {

image: image

}

Response
    • {message: "Bad barcode id"} -400
    • {message: "Bad Request"} - 400
    • {message: "No sample found for barcode {barcode_id}"} - 404
    • {message: "No image uploaded, bad request"} - 400
    • {message: "image saved"} - 200
URL/api/samples/surey/<barcode_id>
DescriptionGet sample image to mongoDB
MethodGET
Url Param barcode_id
Request Body Data

{

data: survey

}

Response
  • {message: "Bad barcode id"} -400
  • {message: "Bad Request"} - 400
  • {message: "No sample found for barcode {barcode_id}"} - 404
  • {message: "No survey found in request body"} - 400
  • {message: "survey saved"} - 200
URL/api/samples/surey/<barcode_id>
DescriptionAdd sample image to mongoDB
MethodPOST
Url Param barcode_id
Request Body Data
Response
  • {message: "Bad barcode id"} -400
  • {message: "Bad Request"} - 400
  • {message: "No sample found for barcode {barcode_id}"} - 404
  • {message: "No survey found for barcode {barcode_id}"} - 404
  • survey_data - 200



URL/api/infant/
DescriptionAdd infant to db
MethodPOST
Url Param
Request Body Data HTML Form Submission with fields:
  1. description (string)
  2. infant_id (string)
  3. name (string)
Response
  • {message: "Infant created"} -200
    {message: "Internal Error, please try again"} - 500
    {message: "Data input is not valid, please try again"} - 400

URL/api/infant/<id>
DescriptionGet infant by id
MethodGET
Url Param infant_id
Request Body Data
Response
  • {message: "Infant does not exist"} -404
  • {
    'infant_id': infant.infant_id,
    'name': infant.name,
    'create_time': infant.create_time,
    'description': infant.description
    }, 200

URL/api/getSurvey/<surveyId>
Description

Get Survey CSV data by surveyId

surveyId= SV_8ILsEKzfiTLFmAK retrieves "Infant Nutrition After Birth Survey.csv"

surveyId=SV_2hHGHXngHMfsIyF retrieves "Infant Nutrition Onboarding.csv"

MethodGET
Url ParamsurveyId
Request Body Data
Response
  • {statusCode: 200, data: {"csv data..."}} , 200
URL/api/sendOnboardingSurvey
Description

Post to this endpoint with <email> and (optional) <name> to send onboarding email to email, will send a notification email to researchers at the same time.

MethodPOST
Url Param
Request Body Data

form-data

  1. email (string)
  2. name (string)
Response
  • {message: {"Email sent"}} , 200
URL /api/upload/
Description

GET: Fetching all uploaded species reads

PUT: Upload a species read

HeaderAPI_KEY
MethodPUT | GET
Url Param

--

Request Body Data

GET

---

PUT

{       

        "email":"XXXXX",

        "barcode_id":"XXXXX",
        "sample_id":"XXXX",
        "sample_species_read": {
                "Actinotignum_timeonense": "XX",
                "Aeriscardovia_aeriphila": "X",

                ...
                }
}

 

"Response

PUT

  • { message: “file uploaded” } - 200: Success


GET

{
        "read_list": [
                {
                        "_id": "XXXX",
                        "date_time": "XXXXXXX",
                        "email": "diapertestemail@gmail.com",
                        "sample_id": "XXX",
                        "sample_species_read": {
                                "Actinotignum_timeonense": "XX",
                                "Aeriscardovia_aeriphila": "XX",

                                ...
                         }
                },

                ...
         ],
         "nums": XX
}

 

200: Success

URL /api/stool-color/
Description

GET: Fetching all barcodes with their associated color

MethodGET
Request Body Data


Response
{
  "colors": [
    {
      "barcode_id": "XXXXX", 
      "color": "XXXXX"
    }, 
    {
      "barcode_id": "XXX", 
      "color": "XXX"
    },
...
]
}, 200
URL /api/stool-barcodes/
Description

GET: Fetch all valid barcodes in MongoDB

MethodGET
Request Body Data


Response
{
  "barcode_id": [
    "XXX1", 
    "XXX2", 
    "XXX3", 
...
]
}, 200
URL /api/stool-picture/<barcode_id>
Description

GET: Fetch an image for the given barcode_id

Valid barcode_ids can be fetched using /api/stool-barcodes/

MethodGET
Url Param

barcode_id

Response
if <barcode_id> is valid:
image of its output color as .png image , Status 200
if <barcode_id> is not valid:
   { "message": "barcode: barcode_id not found" }, Status 404
  • No labels