Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

URL for

...

prod server: https://

...

mobile.diaper-project.

...

URL for prod server: https://on-prod.diaper.cf:5001

com

Notes:

The API key is just the API key.

Image Added

If the Header needs Authentification, please use the "user log in" API first, the response body will have "authToken," as shown in the below image. Copy it in to the header, and add "Bearer" in front of it.

Image Added

Image Added

Server Info APIs

URL/api/monitoring
DescriptionMonitoring related info
MethodGET
Url Param--
Request Body Data

--

Response

{

api_env: "dev",

connected_db: "dev",

pipeline: "mobile"

}

200

          
Cookie

--

URL/api/version
DescriptionShow API Version
MethodGET
Url Param--
Request Body Data

--

Response

{version: "xxx"} - 200

Cookie

--

...

User Creation APIs

User Creation APIs

 

URL/api/users
DescriptionCreate a new user
MethodPUT
Content-typeapplication/json
Url Param---
Request Body Data
{
email: xxx,
firstName: xxx,
lastName: xxx,
surveyData: xxx
}
Response
Response BodyCode

{

message: "Password set email has been sent."

}

200

{

message: "Malformatted JSON"

}

400

{

message: "There was a problem sending the password set email. Please try again later."

}

500

{

message: "User already exists!"

}

500
Cookie---

 

...

User Authentication APIs

URL/api/
version
auth
Description
Show API Version
User login
Method
GET
POST
Url Param
Content-
-Request Body Data

--

Response

{version: "xxx"} - 200

Cookie

--

 

 

typeapplication/json
URL/api/authDescriptionUser loginMethodPOST
Url Param--
Request Body Data
{
email: xxx,
password: xxx,
firstName: xxx,
lastName: xxx
}
Response
Response BodyCode

{

loginResponseType: “loginResponseTypeSuccess”,

message: "User successfully authenticated.",

accessToken: xxx,

email: xxx,

firstName: xxx,

lastName: xxx

}

201

{

loginResponseType: "loginResponseTypeInvalidPassword",

message: "Failed login",

displayMessage: "Incorrect email or password."

}

401

{

message: "There was a problem sending the password set email. Please try again later"

}

500

{

loginResponseType: "loginResponseTypePasswordNotSet",

message: "User password has not been set.",

displayMessage: "Please check your email for a link to set your account password."

}

 


Cookie

---

 

 

URL/api/users/<email>/resetpassword
DescriptionReset password with given new password
MethodPOST
Url Paramemail: email for the user to reset password
Request Body Data
{
password: xxx
}

Note: password field takes the new password to be reset, not the old password.
Response
Response BodyCode

{

message: "Successfully updated password"

}

200

{

message: "Invalid email address provided"

}

400

{

message: "Unauthorized: you do not have access to reset this user's password"

}

401
Cookie---

...

 

...

URL/api/users/<email>/requestpasswordreset
DescriptionSend password reset email
MethodPOST
Url Paramemail: email for the user to reset password
Request Body Data---
Response
Response BodyCode

{

message: "Password reset email has been sent."

}

200

{

message: "Invalid email address provided"

}

400

{

message: "There was a problem sending the password reset email. Please try again later"

}

500
Cookie---

 

URL/api/logout
DescriptionLog out user by deleting the user's access token
MethodDELETE
Url Param---
Request Body Data---
Response
Response BodyCode

{

message: "Successfully logged out"

}

200
Cookie---

...

Sample APIs

PUT

  • { message: “Sample data recorded!” } - 200: Success
  • { message: "Bad request: no image or sample data" } - 400
  • { message: "Bad request: no sample data"} - 401
  • { message: "Bad request: no barcode ID"} - 402
  • { message: "Bad request: no survey data"} - 403
    GET
    { sampleList: [ { id: xxx, dateTime: xxx, hasPict: xxx, hasSurvey: xxx, hasContainer: xxx },
                              { id: xxx, dateTime: xxx, hasPict: xxx, hasSurvey: xxx, hasContainer: xxx },
                              {}…..{} ] }
    200: Success
    Note[Limit]: Up to 15 samples can be retrieved at max.
    URL /api/samples/
    Description

    GET: Fetching all samples created from a user

    PUT: Inserting a new sample

    Fetching multiple Samples at the same time or Inserting a Sample.    

    [Poop Sample Response]

    HeaderAPI_KEY, Authorization
    Content-typemultipart/form-data
    MethodPUT | GET
    Url Param

    --

    Request Body Data

    PUT
    { sampleData: xxx, image: xxx}

    Note: SampleData should send as form-data text, and the image should be form-data file.

    Response

     

     

     

    ...

    URL/api/samples/
    DescriptionFetching multiple Samples at the same time or Inserting a Sample.     [Poop Sample Response]
    HeaderAPI_KEY, Authorization
    MethodPUT | GET
    Url Param

    --

    Request Body Data

    GET

    ---

    PUT
    {

    sampleData: {

    sampleBarcodeID: xxx,

    milkBarcodeID:xxx,

    surveyData: {...} 

    },

    image: xxx

    PUT
    { sampleData: xxx, image: xxx}

    Note: SampleData should send as form-data text, and the image should be form-data file.

    Response

    PUT

    • { message: “Sample data recorded!” } - 200: Success
    • { message: "Bad request: no image or sample data" } - 400
    • { message: "Bad request: no sample data"} - 401
    • { message: "Bad request: no barcode ID"} - 402
    • { message: "Bad request: no survey data"} - 403


    GET
    { sampleList:
    [

    {

    id:

    xxx, dateTime: xxx, hasPict: xxx, hasSurvey: xxx, hasContainer: xxx },
                              { id: xxx, dateTime: xxx, hasPict: xxx, hasSurvey: xxx, hasContainer: xxx },
                              {}…..{} ] }
    200: Success
    Note[Limit]: Up to 15 samples can be retrieved at max.

     

     

    ...

    --

    ...

    PUT
    { sampleData: xxx, image: xxx}

    Note: SampleData should send as form-data text, and the image should be form-data file.

    ...

    PUT

    • { message: “Sample data recorded!” } - 200: Success
    • { message: "Bad request: no image or sample data" } - 404
    • { message: "Bad request: no sample data"} - 404
    • { message: "Bad request: no barcode ID"} - 404
    • { message: "Bad request: no survey data"} - 404

    GET
    { sampleList: [ { id: xxx, dateTime: xxx, hasPict: xxx, hasSurvey: xxx, hasContainer: xxx },
                              { id: xxx, dateTime: xxx, hasPict: xxx, hasSurvey: xxx, hasContainer: xxx },
                              {}…..{} ] }
    200: Success
    Note[Limit]: Up to 15 samples can be retrieved at max.

    barcode id,

    milk_id: milk id,

    dateTime: timestamp,

    surveyData: {},

    readableSurveyData: {}, 

    image_url: url of sample image,

    email: xxx@gmail.com

    },

    {

    ...

    },]

    }
    200: Success


    URL/api/sample/<sample_id>(deprecated)
    DescriptionFetching the image of a Specific Sample Response
    URL /api/sample/<barcode_id>
    DescriptionFetching a specific sample with barcode id
    HeaderAPI_KEY, Authorization
    MethodGET
    Url Param

    sample_id=[string]<barcode_id> : ID for the sample to update (string) 

    Request Body DataPUT
    { sampleData: xxx, image: xxx}

    Note: SampleData should send as form-data text, and the image should be form-data file.

    Response

    { sample: { id: xxx, dateTime: xxx, hasPict: xxx, hasSurvey: xxx, hasContainer: xxx } }
    200: Success

    { message: ”This user does not have access to this sample data” ”sample id is invalid” }
    403400: UnauthorizedInvalid


    { message: ”No such sample exists” }
    404: Resource Not Found
    { message: ”This user does not have access to this sample data” }
    403: Unauthorized

    { message: ”No such sample exists” }
    404: Resource Not Found

    ...

     

    URL/api/sample/
    <barcode_id>
    <barcode_id>/image
    DescriptionFetching
    a Specific Sample Response
    the image of a specific sample 
    HeaderAPI_KEY, Authorization
    MethodGET
    Url Param
    barcode_id=[string]

    <barcode_id> : ID for the sample to update (string) 

    Request Body Data

    --

    Response
    { sample: { id: xxx, dateTime: xxx, hasPict: xxx, hasSurvey: xxx, hasContainer: xxx } }

    image/png

    200:

    Success

    Succeed


    { message: ”This user does not have access to this sample data” }
    403: Unauthorized

    { message: ”No such sample exists” }
    404: Resource Not Found

     

    URL /api/sample/count_this_week
    DescriptionReturn the total number the user uploaded this week
    HeaderAPI_KEY, Authorization
    MethodGET
    Url Param
    Request Body Data

    --

    Response

    { "sampleCount": int } - 200

    ...

    URL/api/sample/<barcode_id>/
    image
    updatesurvey 
    Description
    Fetching the image of a Specific Sample Response
    Update survey for the given sample id
    Content-Typemultipart/form-data
    HeaderAPI_KEY, Authorization
    Method
    GET
    PUT
    Url Param
    barcode_id=[string]

    <barcode_id> : ID for the sample to update (string)

    Request Body Data
    --

    surveyData: list of new survey data

    Response

    {message:

    ”This user does not have access to this sample data” }
    403: Unauthorized

    "Bad request: no survey data to update"} - 404

    {message:

    ”No such sample exists” }
    404: Resource Not Found

     

    "sample id is invalid"} - 400

    {message: "successfully updated survey data"} - 200

    ...

    URL /api/sample/count_this_weektotal
    DescriptionReturn the total number of samples the user uploaded this week
    HeaderAPI_KEY, Authorization
    MethodGET
    Url Param --
    Request Body Data

    --

    Response

    { "sampleCount": int } - 200

     

    ...

    Survey APIs

    URL /api/sendAfterBirthSurvey
    Descriptionsend the infant after birth qualtrics survey to the email specified
    HeaderAPI_KEY, Authorization
    MethodPOST
    Url Param --
    Request Body Data


    Image Added


    Response

    {message: "Email is sent"} - 200

    {message: "There was a problem sending the email. Please try again later"} - 500

    ...

    URL /api/samplesurvey/count_totalquestions
    DescriptionReturn the total number the user uploadedReturns the sample survey when 'main_survey' is passed in as survey_name
    HeaderAPI_KEY, Authorization
    MethodGET
    Url Param survey_name
    Request Body Data

    --

    Response
    unmigrated-wiki-markup
    Request Body Data

    --

    Response

    { "sampleCount": int } - 200

    ...

    {questionsList: [{
            "questionId": "questionDiet",
            "questionText": "Whatwasyourbaby'sdiettoday?",
            "questionType": "questionTypeSingleSelect",
            "responses": [
                {
                    "responseId": "responsesDiet_exclusiveBreastFeeding",
                    "responseText": "ExclusiveBreastFeeding"
                },
    ...
    ...
    ...
    ]}



    URL /api/survey
    DescriptionPlace a survey into the database in order to be retrieved by the application in the future
    HeaderAPI_KEY, Authorization
    MethodPUT
    Url Paramsurvey_name
    Request Body Data

    Survey to placed in the database

    Response
    {
    "message": "Incorrect API key provided."
    }
    {
    "message": "Survey stored!"
    }, 200
    If survey name not passed in,
    {
    "message"="Please pass in survey name to create a survey"
    }, 400
    Sample

    Image Added