NOTE: Be aware, if you use this with the other IFTTT integration, you could get yourself into an infinite loop of funness.
QUOTA: There is a quota allowed per ID or Access Token. The current quota is 50 requests in a 5 minute time period. If you exceed that quota your account will be banned from the public API automatically. If you need additional quota, please reach out to us at support@babystats.org.
We have opened up a public API that can be used by your own home automation projects, or can be used by IFTTT web hooks. In order to use this API, click the button below to generate an "accessToken". This token needs to be supplied with every request or we will reject your request. Ensure you save this token for use later.
If you are not technical, don't worry below that will show you how to get the data into IFTTT. Just fill in the "YOUR ACCESSS TOKEN GOES HERE" (if you don't have an access token click Generate Access Token) and enter your ID in the "YOUR ID GOES HERE".
Toggle the drop down below to see the Body data required for each request type.
Parameter | Description | Type |
---|---|---|
isApplication | This tells the api whether return a BabyData object (documented below) or SSML. If you pass true you'll receive BabyData, if you pass false you'll receive SSML. | boolean |
onlyHeader | This tells the API whether or not you want BabyTransaction data. It's best to set this to true. | boolean |
numberOfDays | This limits the number of days that get returned in BabyCount data. Our online viewer only returns 5 days for example. | integer |
A request that adds a wet diaper, then tells the API to return SSML.
{
"id": "FAKE",
"accessToken": "2019-08-19:d0a58739-ee99-44c8-ad28-d099273aa6f3",
"event": "AddWet",
"babyName" : "",
"eventTime" : ""
}
A request that adds a wet diaper, then tells the API to return BabyData, but limits it to 5 days and only returns the BabyCount data (not BabyTransaction).
{
"id": "FAKE",
"accessToken": "2019-08-19:d0a58739-ee99-44c8-ad28-d099273aa6f3",
"event": "AddWet",
"babyName" : "",
"eventTime" : "",
"isApplication":true,
"onlyHeader":true,
"numberOfDays":5
}
In order to use our public API with IFTTT follow these steps. If you are not planning on using IFTTT you can skip lower.
{
"status": true,
"statusMessage": "",
"ssml": "",
"data": {
"ifttt": null,
"lastStats": { },
"lastNStats": { },
"countsInTheLast": {
"hours24": { },
"hours12": { },
"hours6": { },
"hours1": { }
},
"dueDate": "2018-07-02",
"deletedBabies": [],
"babies": [],
"seenThings": [ ],
"previous": [ ],
"guid": "string",
"id": "string",
"timezone": "unknown",
"babystats": [ ],
"transactions": [ ],
"weights": [ ],
"notes": [ ],
"sleep": [ ],
"pumping": [ ],
"kick": [ ],
"startSleep": {},
"startFeeding": {},
"uom": "ml",
"uomType": "us"
}
}
Parameter | Description | Type |
---|---|---|
status | The status of the request (true or false). | boolean |
statusMessage | An error message. This will be populated when the request fails to give you information on why it failed. | string |
ssml | If the request had the isApplication=false, then this will be populated with SSML based on the request. | string |
data | This is the start of the BabyData object. | object |
data.ifttt | This will be populated with the IFTTT url used by the user. All public requests will have this value nulled out. | string |
data.lastStats |
lastStats will have the last babyTransaction that was tracked for each stat type. For example, if you tracked an AddWet. You will see: "lastStats":{ "AddWet" { babyTransaction } } Then when you tracked an AddFeeding you would see: "lastStats": { "AddFeeding": { babyTransaction }, "AddWet": { babyTransaction } } The last count tracked by each type will be stored here. This makes it easier for the viewer to get the last stat for display. |
name value pair of babyTransaction |
data.lastNStats |
lastNStats will have the last 10 babyTransaction that was tracked for each stat type. For example, if you tracked an AddWet. You will see: "lastNStats":{ "AddWet" [ { babyTransaction }, { babyTransaction }, ... ] } Then when you tracked an AddFeeding you would see: "lastNStats": { "AddFeeding": [ { babyTransaction }, { babyTransaction }, ... ] "AddWet": [ { babyTransaction }, { babyTransaction }, ... ] } The last count tracked by each type will be stored here. This makes it easier for the viewer to get the last stat for display. |
name value pair of an array of babyTransaction |
data.countsInTheLast | countsInTheLast will be a pre-calculated the number of stats that occurred in 4 different durations, hours24, hours12, hours6 and hours1. The type of the data will be an aggregate babyCount. | babyCount |
data.dueDate | The dueDate tracked by the user. | date |
data.deletedBabies | Deleted babies are never truely deleted. We just move the baby from the babies array to the deletedBabies array in case it needs to be reverted. | array of baby |
data.babies | The list of babies. This is ONLY used if the user has converted their account to allow for multiple babies. In 90% of instances it is not used. | array of baby |
data.seenThings | This is not needed for you. I use this internally so I can track if a user saw a particular screen so I can tailor the message. | array of seenThings |
data.previous | This is the last count operation that was done. I use it internally for the RemovePrevious transaction (IE "undo"). | array of babyTransaction |
data.guid | guid is a unique GUID generated for the user. It is only used internally and doesn't mean anything to you externally. | string |
data.id | id is the unique ID that is exposed externally for the user. | string |
data.timezone | timezone is the timezone configured by the user so you know what times to display. In general dates are logged in UTC and converted to the local time based on the user's configuration. The babyCount object is also calculated based on the timezone as it's date sensitive. |
string: unknown pacific central eastern mountain atlantic hawaiian alaska unitedkingdom germany arizona india newfoundland bangkok sidney gulf hongkong |
data.babystats | babystats is a calculated field. It contains the rollup of all stats by day. You can use noCountsByDay to control if this is sent in the response. noCountsByDay = true means this array will be empty. You can also use numberOfDays to control the number of days returned. These 2 fields are to help your app be more responsive. Instead of sending all data in the request you can just have it send a little bit. | array of babyCount |
data.transactions | transactions is the list of all AddWet, AddFeeding and AddStool transactions. You'll notice that weights, notes, kicks, and pumpings are all separated out into different fields. The reason for wets, feeding, and stools to be grouped is they are considered the base data that someone would track. Also, it was what I originally started with, so I chose to keep it consistent for backwards compatibility with any old android apps. | array of babyTransaction |
data.weights | weights are the array of weight transactions. | array of babyTransaction |
data.notes | notes are the array of note transactions. | array of babyTransaction |
data.sleep | sleep are the array of sleep transactions. | array of babyTransaction |
data.pumping | pumping are the array of pumping transactions. | array of babyTransaction |
data.kick | kick are the array of kick transactions. | array of babyTransaction |
data.kick | kick are the array of kick transactions. | array of babyTransaction |
data.startSleep | startSleep will be populated with a babyTransaction that indicates the user has started sleep. | babyTransaction |
data.startFeeding | startFeeding will be populated with a babyTransaction that indicates the user has started feeding. | babyTransaction |
data.uom | Please ignore this field it is no longer used on the BabyData object. The only place uom is used is on the babyTransction object. | ignore |
data.uomType | uomType is the type of UOM the user wants the data spoken or displayed to him. Values could be us or metric. | uomType |
{
"uom": "oz",
"breastSide": 0,
"uid": "0a0661d1-c747-4817-a380-bf274fb8f69f",
"requestType": 2,
"note": null,
"weight": 0,
"wet": 0,
"stool": 0,
"feeding": 1,
"bOz": 0,
"sleep": 0,
"feedingMinutes": 0,
"transactionDateTime": "2018-06-19T23:22Z"
}
Parameter | Description | Type |
---|---|---|
uom | The UOM the count was logged with. The default is oz. This is to allow a user to log feedings and pumpings in either oz OR ml. All counts are actually stored as oz and based on the uom field it will convert. The conversion factor from oz to ml is 29.5735. | oz ml |
breastSide | This is used when the user logs the breast side. The value will actually be stored as the integer value of the enumeration. This isn't as readable so I apologize, but I kept it to be backwards compatible. | integer: unknown = 0 left = 1 right = 2 both = 3 |
uid | uid is the unique ID for this count. It can be used in the RemoveTransaction and the UpdateTransaction calls. | string |
requestType | requestType is the type of the count. The value will actually be stored as the integer value of the enumeration. This isn't as readable so I apologize, but I kept it to be backwards compatible. | integer: AddWet = 1 AddFeeding = 2 AddStool = 3 AddWeight = 20 AddNote = 23 AddSleep = 29 AddPumping = 43 AddKick = 46, |
note | The note logged for the note count. | string |
weight | The weight logged for the weight count. The data will be stored in ounces. | decimal |
wet | wet is a legacy field. It's unneeded for you. But, what it represents is it will be 1 when the requestType is AddWet. You can ignore. | integer |
feeding | feeding is a legacy field. It's unneeded for you. But, what it represents is it will be 1 when the requestType is AddFeeding. You can ignore. | integer |
bOz | bOz is the bottle ounces. Data is stored in ounces and you can use the UOM to convert based on the uomType the user has configured. AddPumping or AddFeeding counts could have bOz populated if the user has tracked it. | decimal |
sleep | sleep is the number of minutes tracked for sleep. Data is stored in minutes. | integer |
feedingMinutes | feedingMinutes is the number of minutes tracked for a feeding. Data is stored in minutes. | integer |
transactionDateTime | transactionDateTime is the time the count was tracked. Counts are only tracked down to the minute (no seconds). The Z at the end is only to indicate the time is in UTC time. | date: yyyy-MM-ddThh:mmZ |
{
"spokenName": "coleman",
"displayName": "Coleman",
"id": "731954344",
"isDefault": false
}
Parameter | Description | Type |
---|---|---|
spokenName | The name expected to be spoken. "add feeding for {coleman}". The reason there is a spoken and a display field is to give the users the ability to tinker with it if Alexa doesn't understand it completely. So, they can help guide the assistant by changing it. All counts tracked with a babyName are fuzzy matched to find the baby. | string |
displayName | The name expected to be displayed. | string |
id | The id of the baby. | string |
isDefault | Indicates which baby is the default baby. This is used when the user tracks a stat without specifying a baby name. | boolean |
{
"uom": "oz",
"bOz": 0,
"wet": 1,
"stool": 1,
"feeding": 4,
"feedingMinutes": 0,
"date": "2018-01-12",
"sleepCount": 0,
"sleep": 0,
"pumping": 0,
"pOz": 0,
"kicks": 0
}
Parameter | Description | Type |
---|---|---|
uom | uom should be ignored on the babyCount. | ignore |
bOz | The aggregate bottle ounces for the day. Bottle ounces in the babyCount are just the feeding bottle ounces. | decimal |
wet | The aggregate wet counts for the day. | integer |
feeding | The aggregate feeding counts for the day. | integer |
feedingMinutes | The aggregate feeding minutes counts for the day. Data is stored in minutes. | integer |
date | The date of the count. Data is stored as yyyy-MM-dd, and it does take into account the local timezone. | date yyyy-MM-dd |
sleepCount | The aggregate sleepCount counts for the day. | integer |
sleep | The aggregate sleep minutes for the day. Data is stored in minutes. | integer |
pumping | The aggregate pumping counts for the day. | integer |
pOz | The aggregate pumping ounces for the day. Data is stored in ounces. | integer |
kicks | The aggregate kick counts for the day. | integer |
You can now integrate directly with IFTTT. You can configure which stats you subscribe to and everytime that stat is triggered you can have it kick off some action on IFTTT. Want to have it log a stat every time to Google Drive? Want to start tracking sleep every time you turn off the lights in the babies room? Maybe you just want to change the light color everytime you change a diaper? The power is in your hands.
1. Enter your Baby Stats ID below, then click Load.
2. Next enter your IFTTT key. If you have previously subscribed it would have auto populated when you clicked Load ID Information. Help finding your IFTTT key
3. Next, highlight the events on the left and click Add Subscription for all of the subscriptions you want IFTTT to listen for.
4. Now save your subscriptions. This will update Baby Stats with the events you want IFTTT to know about. Next you will need to configure IFTTT.
5. Navigate to IFTTT and click on "New Applet".
6. Select "Webhooks" and Receive a web request.
7. Enter the event name of one of the subscriptions you subscribed to above.
8. Choose your "action", in this example you'll see how to create a Google Sheets.
9. You should be good to go now!
To find your key login to IFTTT and navigate to Webhooks and click on Settings.
You will see a URL. You can copy the whole URL and paste it into the text box, we will strip out all the URL parts for you.