GET https://mobile-test.diaper.cf:5001/api/samples/
GET https://mobile-prod.diaper.cf:5001/api/samples/
Retrieves a page of samples for a user. Samples include the survey data, sample image, user email and etc.
Authorization : Bearer ACCESS_TOKEN
Content-Type : multipart/form-data
API-KEY
| Param | Type | Range | Default | ||
|---|---|---|---|---|---|
| 1 | limit | integer | 1000 | 25 | The maximum number of items to return per page. |
| 2 | offset | integer | Depends on dataset | 0 | The offset of the item at which to begin the response. |
To fetch the first page of entries in a collection the API needs to be called either without the offset parameter, or with the offset set to 0. The limit field is optional.
curl -X GET "https://mobile-test.diaper.cf/api/samples?offset=0&limit=25" \ -H "authorization: Bearer ACCESS_TOKEN" |
By default, GET operations, which return a list of requested items, return only the first 25 items. To get a different set of items, you can use the offset and limit parameters in the query string of the GET request. |
To fetch the next page of entries the API needs to be called with an offset parameter that equals the sum of the previous offset value and limit returned in the previous result, previous_offset + previous_limit.
curl -X GET "https://mobile-test.diaper.cf/api/samples?offset=25&limit=25" \ -H "authorization: Bearer ACCESS_TOKEN" |
Note that the offset should be increased by the previous limit and not by the size of the entries in the response array, as this may be less than the limit. Generally we advise using the value of the limit in the response object to increase the offset value. |
The final page of items has been requested when the next offset value exceeds the total_count value in the response object. At this point there are no more items to fetch.
Tips:
…/samples?limit=1 to get just metadata, with one sample data. Then send subsequent requests with increasing offsets and a fixed limit until you get all the data..../samples?limit=0 to get all sample data. Setting limit = 0 is equivalent to setting no limit. Be careful to use it because it may ends up with requesting timeout.When paginating collections, the API returns an object that contains the set of results as an array, as well as some information about the current page of results.
| Field | Type | |
|---|---|---|
| sampleList | Array | The page of items for this page. This will be an empty array if there are no results. |
| offset | Integer | The offset used for this page of results |
| limit | Integer | The limit used for this page of results. This will be the same as the limit query parameter unless it exceeded the maximum value allowed for this API endpoint. |
| next_page | string | The link for the next page of the query assuming current value of limit and offset. The final page will have "" on next_page and at this point there are no more items to fetch. |
| prev_page | string | The link for the previous page of the query |
| count | Integer | The total number of items in the collection |
| total | Integer | The total count of items available in the entire dataset. The total number of items in the sampleList count may be less than total_count |
| page_num | Integer | Current page number |
| pages | Integer | Total number of pages in the dataset |
| Status code | Type | |
|---|---|---|
| 200 | multipart/form-data | Returns a collection of samples and pagination information |
| 403 | multipart/form-data | Returned when the access token provided in the |
| 404 | multipart/form-data | Returned if the samples is not found, or the user does not have access to the samples. |
| default | An unexpected client error |
// curl -L -X GET 'https://mobile-test.diaper.cf:5001/api/samples?offset=0&limit=2' -H 'API-KEY: [SECRET KEY]' -H 'Authorization: Bearer [ACCESS TOKEN]'
{
"pagination": {
"count": 2,
"limit": 2,
"next_url": "/api/samples?limit=2&offset=2",
"offset": 0,
"page_num": 1,
"pages": 11,
"prev_url": "",
"total": 22
},
"sampleList": [
{
"dateTime": 1638746006,
"email": "diapertestemail@gmail.com",
"id": "6921899930718",
"image_url": "/api/sample/6921899930718/image",
"milk_id": "N/A",
"readableSurveyData": {
"Any feeding changes": "No",
"What was the color of the stool?": "Red Orange"
},
"surveyData": {
"questionDietChange": [
{
"responseId": "responsesDietChange_no",
"responseText": "No"
}
],
"questionStoolColor": [
{
"responseId": "responseStoolColor_RedOrange",
"responseText": "Red Orange"
}
]
}
},
{
"dateTime": 1638743884,
"email": "diapertestemail@gmail.com",
"id": "0815766023787",
"image_url": "/api/sample/0815766023787/image",
"milk_id": "0815766023787",
"readableSurveyData": {
"Any GI distress?": "Yes",
"Any feeding changes": "Yes",
"Any of the following health concerns?": "None",
"Any use of diaper creams or baby powder?": "None",
"Are you currently pumping milk mostly for a freezer stash or use in the next week? (Exclude any pumping done for this study)": "Yes - Immediate use",
"Did Baby receive any antibiotics this week?": "No",
"Did Mom receive any antibiotics this week?": "No",
"Did you feed your baby any breast milk you had stored in the refrigerator or freezer?": "No",
"Did you give baby any supplements?": "Probiotics w/ Bifidobacterium",
"How did you feed your baby breast milk?": "Partially at the breast and partially using a bottle",
"How many poopy diapers do you estimate since your last entry?": "5",
"On a scale of 1 (low) - 10 (high) - how concerned are you about the contents of your baby's diaper?": "7",
"What did you feed your baby today?": "Breast milk",
"What distress types?": "Diarrhea",
"What was the color of the stool?": "Red Orange",
"What was the consistency of the stool?": "Mucous, stringy, more fluid than soft",
"What were the diet changes?": "Stopped breastfeeding"
},
"surveyData": {
"questionBabyAntibiotics": [
{
"responseId": "responsesAntibiotics_Babyno",
"responseText": "No"
}
],
"questionDiaperCreamBabyPowderUse": [
{
"responseId": "responsesDiaperCreamBabyPowderUse_none",
"responseText": "None"
}
],
"questionDiaperFreeform": [
{
"responseId": "responsesDiaperFreeform_7",
"responseText": "7"
}
],
"questionDiet": [
{
"responseId": "responsesDiet_BreastMilk",
"responseText": "Breast milk"
}
],
"questionDietChange": [
{
"responseId": "responsesDietChange_yes",
"responseText": "Yes"
}
],
"questionDietChangeFollowup": [
{
"responseId": "responsesDietChangeFollowup_StoppedBreastfeeding",
"responseText": "Stopped breastfeeding"
}
],
"questionFerige": [
{
"responseId": "2",
"responseText": "No"
}
],
"questionGIDistress": [
{
"responseId": "responsesGIDistress_yes",
"responseText": "Yes"
}
],
"questionGIDistressFollowup": [
{
"responseId": "responsesGIDistressFollowup_diarrhea",
"responseText": "Diarrhea"
}
],
"questionGiveBabyAnySupplements": [
{
"responseId": "responsessupplements_Probioticsw/Bifidobacterium",
"responseText": "Probiotics w/ Bifidobacterium"
}
],
"questionHowFeedBreastMilk": [
{
"responseId": "responsesFormulaUsage_Mix",
"responseText": "Partially at the breast and partially using a bottle"
}
],
"questionMomAntibiotics": [
{
"responseId": "responsesAntibiotics_Momno",
"responseText": "No"
}
],
"questionPoopyDiaper": [
{
"responseId": "questionPoopyDiaper_5",
"responseText": "5"
}
],
"questionPumping": [
{
"responseId": "2",
"responseText": "Yes - Immediate use"
}
],
"questionSickDays": [
{
"responseId": "1",
"responseText": "None"
}
],
"questionStoolColor": [
{
"responseId": "responseStoolColor_RedOrange",
"responseText": "Red Orange"
}
],
"questionStoolConsistency": [
{
"responseId": "responsesstoolConsistency_Mucous",
"responseText": "Mucous, stringy, more fluid than soft"
}
]
}
}
]
} |
Besides the actual results, response also contains several metadata for pagination such as next_page(the link for the next page of results), prev_page(the link for the previous page of results),total_count(indicates the number of entries in the dataset) and total pages.
In the above example, it will show the next page of results with /api/samples?limit=2&offset=2. Note that there is no previous link in the response meaning there is no results before this page. This is same for next_page when we are reaching out the final page of data. At this point there are no more items to fetch.