Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

User Authentication APIs

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

--

Response

{version: "xxx"} - 200

Cookie

--

 

 

URL/api/auth
DescriptionUser login
MethodPOST
Url Param--
Request Body Data 
Response

 

Cookie

 


Sample APIs

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
  • {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

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.
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

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.

MethodPOSTUrl Param Request Body Data

{ email: xxx, password: xxx}

Response{ message: "User successfully authenticated.",
  authToken: xxx,
  email: xxx,
  firstName: xxx,
  lastName: xxx }
201: Created
{ message: ”Failed Login”}  

  • {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/samples/
    DescriptionAdd sample data to mongoDBFetching multiple Samples at the same time or Inserting a Sample.     [Poop Sample Response]
    HeaderAPI_KEY, Authorization
    MethodPUT | GETMethodPOST
    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

    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" } - 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.

    URL/api/sample/<sample_id>
    DescriptionFetching the image of a Specific Sample Response
    HeaderAPI_KEY, Authorization
    MethodGET
    Url Param

    sample_id=[string]

    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

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

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

    { 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>
    DescriptionFetching a Specific Sample Response
    HeaderAPI_KEY, Authorization
    MethodGET
    Url Param

    sample_id=[string]

    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

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

    { 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>
    DescriptionFetching the image of a Specific Sample Response
    HeaderAPI_KEY, Authorization
    MethodGET
    Url Param

    sample_id=[string]

    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

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

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