Editors Note: We’ve updated this post to reflect Google’s move to a new version of their spreadsheet application. The newest version no longer support the Script Gallery mentioned here. We have included a link in the instruction steps below that allows you to use the old version of Google Spreadsheets. We’ll keep an eye out and update this post again if the old version is taken down. We’ve also included a new set of instructions if you’d like to use the new Google Spreadsheets. This involves slight editing to a simple script (updated 09/22/14).
Interested in downloading your minute-by-minute Fitbit data? Check out our new how-to here! (updated 09/26/14)
We’ve updated the script to reflect Fitbit’s move to only accept HTTPS requests to access their API. Make sure to update your own scripts if you’ve modified the one linked below in Step 4 (updated 10/15/14).
If you’re like me, then you’re always looking for new ways to learn about yourself through the data you collect. As a long time Fitbit user I’m always drawn back to my data in order to understand my own physical activity patterns. Last year we showed you how to access your Fitbit data in a Google spreadsheet. This was by far the easiest method for people who want to use the Fitbit API, but don’t have the programming skills to write their own code. As luck would have it one of our very own QS Meetup Organizers, Mark Leavitt from QS Portland, decided to make some modifications to that script to make it even easier to get your data. In this video below I walk you through the steps necessary to setup your very own Fitbit data Google spreadsheet.
Step-by-step instructions after the jump.
- Set up your Google spreadsheet and script
- Create a new google spreadsheet. Important: You must use the old version of Google Sheets. You can access that here - g.co/oldsheets (If you want to use the new version of Google Spreadsheets skip to Step 2.)
- Go to Tools->Script Gallery
- Enter “fitbit” in the search box and hit search
- Install the “Fitbit Download” script by clicking install.
- Click authorize in the dialog box.
- Click “ok” in the new window that opens.
- The script is now installed on your spreadsheet.
- Close the script gallery dialog box.
- Create a new google spreadsheet. Important: You must use the old version of Google Sheets. You can access that here - g.co/oldsheets (If you want to use the new version of Google Spreadsheets skip to Step 2.)
- Set up your FitBit Developer account and register an app.
- Go to dev.fitbit.com and sign in using your FitBit credentials.
- Click on the “Register an App” at the top right corner of the page.
- Fill in your application information. You can call it whatever you want.
- Make sure to click “Browser” for the Application Type and “Read Only” for the Default Access type fields.
- Read the terms of service and if you agree check the box and click “Register”
- Copy the API keys
- Copy the Consumer Key.
- Copy the Consumer Secret.
- You can save these to a text file, but they are also available anytime you return to dev.fitbit.com by clicking on the “Manage my Apps” tab.
- Authorize the Fitbit Download Script
- Go back to your Google spreadsheet.
- Go to Tools->Script editor
- If you have chosen to run the new version of Google Spreadsheets you must download this script, copy it’s contents, and paste into the script editor window. Make sure to delete all text in the editor before pasting. You can then follow along with the instructions below.
- Select “setup” in the Run drop down menu. This will open a dialog box in your spreadsheet.
- In your spreadsheet past the Consumer Key and Consumer Secret that you copied from your application on dev.fitbit.com.
- Enter the day to start retrieving data. If you know when you purchased your Fitbit I would suggest using that date.
- Select the data you want to save to your spreadsheet. By default all available Fitbit data is selected.
- Click “save setup”
- Go back to your script editor window
- Select “authorize” in the Run drop down menu. This will open a dialog box in your spreadsheet. Click yes.
- A new browser window will open and ask you to authorize the application to look at your Fitbit data. Click allow to authorize the spreadsheet script.
- Download your Fitbit Data
- Go back to your script editor window
- Select “sync” in the Run drop down menu. This will download your Fitbit data to the spreadsheet.
- Set up an automatic trigger to automatically update your spreadsheet with new data on a specific schedule.
- Go to Tools->Script Editor
- Go to the “Resources” menu and select “current project’s triggers”
- Add a new trigger that runs “sync” that is ‘time driven’ and choose an interval for the spreadsheet to update. I currently have mine set to “daily” updating between “midnight to 1am” but feel free to choose something different.
- Click save.
Now that you’ve set it all up your Fitbit data will automatically be downloaded to that spreadsheet. As you may know, there are a wide variety of charts and Google Gadgets that you can use to visualize that data.
If you’re using this method to look at your Fitbit data we want to know! Use the comments below to tell us what you’re learning from your Fitbit data and what types of visualizations or analysis you find most useful.
Very nice, thanks. Anyone know of something for MyFitnessPal data?
Many thanks for this. Few comments about the above article:
In 2. when you register your website url, note that Fitbit’s verification algorithm requires “http://” in front of your domain (duh‽)
1n 4. you’ll find the date field at the bottom of the script in yyyy-mm-dd format
In 5. “Sync” not “syn”
Thanks Lucy!
Dear Ernesto,
The google sheet works absolutely fine.
I am a doctor and use the fitbit flex on different patiënts (elderly).
I can change the name of the user on the website. How can I get the name in the spreadsheet? Do you know the name of the variable? It is not ‘name’ or ‘username’.
Thanks for this piece of work.
That’s great, thanks! Do you know about any option to get a data by hours (or even minutes if possible)? It would be great to look at the activity patterns in a finer resolution (that is hourly rather then daily, for example).
That actually requires the partner level API access from fibit. You can contact them and access that data. If that interests you I suggest looking into the Fitbit API Google Group.
Other than using Fitabase, does someone know of a method to download intraday (by minute) data to Google Docs? I have access to the intraday data. Can someone advise how to modify this script to allow for data by minute?
Thanks
I am quite keen on getting this data as well. Have been given access to this data by the Fitbit team already.
It’s great to have these instructions for people who are intimidated by code, but really, wouldn’t it be so much easier to say 1) download this file 2) add your info here 3) receive CSV file?
This is great! Thanks for making the video.
Thanks for the video!
I am a professional commodity trader that loves to use fitbit export data in conjunction with excel to devise a plethora of charts/analysis, many of which are taken from traditional technical analysis. Examples include weight charts with 7 day moving average and Bollinger bands, which represent + and – 2 standard deviations from the mean and describe my expected range of weight values. Other examples include the use conditional if/then statements to analyze and compare metrics on days that I work out, drink alcohol, meditate, etc, with “regular” days. The list goes on and on and I’ve actually recently started a personal blog to cover this exact topic: http://sciencetrainer.blogspot.com/
I haven’t updated it in a while, but keep an eye out, I will be going into detail on these and other related topics in the days and weeks ahead.
This is fantastic!
Thanks Ernesto and Mark.
I do all my food entry in MyFitnessPal (PC and android app) – which IMHO is a much better way than using Fitbit’s limited calorie/food management section.
Is it possible to have this Google Spreadsheet also grab the diet/meal values from Fitbit?
I know that the data is there, as when I did exported my Fitbit data (7 day trial only – from the webpage), it downloaded all the MyFitnessPal data that it had synced over the previous months.
Any ideas how would I go about adding these fields into the Google Spreadsheet?
Fitbit currently imports/provides:
1. Total kCals for each meal type (eg: Breakfast, Lunch, Dinner, Snack) for each day.
2. Overall macronutriet breakdown for each day (eg: Calories, Protein, Fats, Carbs, Fiber, Sodium, Water, etc).
Thanks
Jason
I had same question. The default “loggables” don’t include some the the basics. I am tracking water. Also, wondering if you can include custom tracker data.
anyone??
To add water you need to add this line in the loggables
“foods/log/water”,
For those with fitbit devices that track floors and elevations:
“activities/log/floors”,
“activities/log/elevation”,
The other sleep metrics:
“sleep/startTime”,
“sleep/efficiency”,
“sleep/minutesToFallAsleep”,
“sleep/minutesAfterWakeup”,
If anyone knows how to bring in heart rate and body measurements from the log. Please do let me know.
This is really useful, I finally could lay hand on what’s rightfully mine.
One thing, though. It would be really great, and much more interesting, if we could download all of our intraday data. The data exists, one can view it on Fitbit’s site, but there’s yet no way to download it, not even through the premium service!
Hi NIcolas – Our experience is that it is sometimes possible to get permission directly from Fitbit to look at this data, and I know Fitbit is cooperating with public health and academic researchers to study intraday data with permission from users, but you’re right, as of now there is no standard way for regular users to get it. I hope and expect that this will change!
Pingback: Fitbit Lab
I have been learning so much for Quantified Self today. This is great.
Google Spreadsheets are just excellent. Once you get the data, Google has a lot of different options for you to arrange and view the information.
I had a thought for a workaround to get intra-day data, and would love some feedback.
The hack assumes
a)your device is set to sync regularly (via smartphone background sync or the like), and
b) the fitbit download script “sync” was set on an hourly trigger
What I haven’t looked into is whether there is a way in google spreadsheets to add a “timestamp” column to record the time of each sync, and then run a simple subtraction formula in an additional column to get your hourly data?
I also don’t know how often the fitbit one will “background” sync with one’s smartphone, if that option is checked…
@Matt – you can use the “=now()” in google docs to record a timestamp – hope that helps.
This is great. Thanks! However, how do I update the script to convert weight and distance from metric?
On the FitBit website, change the country for the food database in your settings, to US for Imperial measures. UK is metric, aside from weight, which is in decimal Stones. Any other country and it’s all metric.
Pingback: March Personal Challenge : Be More Active « Sometimes, those who wander really are lost
Thanks for the script!
Unfortunately, I can’t get it to download any data other than today’s, no matter what start date I provide. Any ideas why that might be the case? I’ve been wearing my Fitbit since August 2012.
Today I can download two days of data. It seems that the earliest data I can download data is the day I registered the script app. Anyone else experiencing that? It doesn’t matter what date I set the start date to in the script setup.
Thanks. This is great. Anyone else having an issue where the dates are off? It seems like all the dates are one greater than they should be except for the last row which is correct. This shows as the last 2 rows having the same date.
The Step 4 actions can be performed without going to the script editor. They can be accomplished from the Fitbit menu on the spreadsheet itself.
It is actually confusing to go to the script editor because when you click Run->setup in the script editor the dialog you want to interact with pops up in the spreadsheet. In a tabbed browser that dialog is no apparent because you’re looking at the script editor tab.
I suggest rewriting Step 4 to do both the setup and authorize actions from the Fitbit menu without ever going to the script editor.
This is great! I’m hoping to get some good information out of this data. However, when my spreadsheet syncs to my account, the dates and data seem to be out of sync slightly. For instance, today’s data is downloaded twice – once for my steps and calories burned, and then another set of separate data (i.e., an entirely different row) for my calories in, BMI, and weight. any thoughts why this is happening? I was hoping to find that this has happened to someone else as well.
Thanks again for the great information!
Would it be possible to add Fitbit’s “Total Time Asleep” data to this script?
If you sleep in multiple sessions or nap, the minutesAsleep data will be inaccurate because it captures only one session from the day.
Pingback: 3 Months of Fitbit | Colin Sullender
I was able to figure out the calculation for minute to fall asleep and Sleep efficiency, however, the API dose not seem to pull floors climbed. Any solutions?
Hi SPG, Did you ever find a way to download the number of Floors from Fitbit and the Google API? K
Yes the code was updated to include steps, however the Calories do not download with the updated script
Is there anyway to get the weight data to show in pounds rather than whatever format it is coming through in the spread sheet? I can’t seem to find any info on that column. Thanks!
To use pounds rather than kilograms, you need to edit the script. The script needs to tell fitbit to give us back the data using pounds instead of kilos.
In the script, go to line 126-130. It should look like this:
var options = {
“oAuthServiceName”: “fitbit”,
“oAuthUseToken”: “always”,
“method”: “GET”,
};
We modify it to add an additional option so that fitbit knows to use pounds instead of kilos:
var options = {
“oAuthServiceName”: “fitbit”,
“oAuthUseToken”: “always”,
“method”: “GET”,
“headers”: { “Accept-Language”: “en_US” }
};
Save the script, then run sync. All units will now be in US units.
Thanks Jonathan!
Yeah, what he said. Thanks!!!
I tried this and it changes nothing in the spreadsheet.
Any other thoughts? Do I have to delete the data and start over maybe?
When I sync I get a few errors.
A pop up appears and is titled Apps Script Error downloading activities/log/steps
(however I have all my steps). I click OK and then I get a red box at the top:
TypeError:Cannot call method “getContentText” of undefined.
Were you able to resolve this? I’m having the same problem.
1. make sure you add a comma after the “GET” line
2. Remove smart quotes in the line you add
“oAuthServiceName”: “fitbit”,
“oAuthUseToken”: “always”,
“method”: “GET”,
“headers”: { “Accept-Language”: “en_US” }
OMG.
This is awesome. I have an extensive set of spreadsheets I’ve been manually curating to help me keep off 186 lbs. (weighted moving average of pounds, tracking body composition, estimating TDEE based on what the scale does, etc.)
Now I’ll only have to track my food in LoseIt as usual, and if I get one of those wi fi scales I won’t even have to log my weight by hand…
THANK YOU.
Thats awesome 4a.
I’ve been trying to figure out how to do something like that.
Don’t suppose any of your spreadsheets are shared/available online?
Thanks.
Yessir, they ARE online!
:
Enjoy!
Oops, let me reformat that. :-p
Basic Data
Calories and estimated TDEE
That should work.
Thanks!!
OK, I’m registering the application and the “dev.” site wants to know the application website. I don’t have a website so what do I put in the three boxes below the description box?
Hi Steve,
You can put whatever you want in the website. I don’t think it matters too much!
hi.
first, thank you for the script
My problem is I can’t get the caloriesIn data, even I can see them on Fitbit dashboard.
Does it depend from the origin of the data, Myfitnesspal?
Is it possible to specify in which Sheet to sync? -if I let the script sync by trigger, it appends data in front of the first sheet, already filled by Withings and IFTTT… I have to run sync manually when in another sheet. Thank you
about my first question: caloriesIn is the only one data not synced.
it comes from MFP, as said, and I see that in the setup it is food/log/calories.
have I to change something like activities/log/calories?
aaand now the script returns an error on caloriesIn.
did they change the variable name?
I log my food with LoseIt, and the “caloriesIn” value for each day is correct within +/- 1 cal of what LoseIt says.
Now it works again (insert puzzled face here).
I still have a hole of 11 days in the sync… the CaloriesIn column is eleven cells shorter.
I have only to tweak the sheet, I know, but…
(i forgot a Thank You
)
Thanks for the video!
Thanks for the instructions. Just now getting into exercise and QS. We have a QS meetup here tomorrow, so finding this guide today has great timing.
Awesome. Where is “here” Allen?
Alexandria, VA – here is the link: http://www.meetup.com/DC-Quantified-Self/events/111835612/
Thank you for the brilliant script! It’s very easy and straightforward to set up and run.
However, I do have the same issue as Jonathan Hyland above, the dates seem to be off a day, apart from the caloriesIn which seem to be OK (the calories are syncing from MyFitnessPal, so it could be they are correct because they sync a day later, haven’t looked into it in more detail)
Hi Ernesto,
I also track my Blood Pressure in Fitbit, how can I also get those values to show up in the spreadsheet ? (Average BP/day would be enough)
Thanks in advance for your answer.
Marc
I’m glad to hear so many people are having success with the script, and want more functionality than the original script provided. I will revisit the Fitbit API and see if some of these requests (such as downloading BP and other logged parameters) can be satisfied.
I only have steps data in my own records, so I’ll need a few beta testers who have BP, weight, and other logged parameters, and who are willing to share credentials with me so I can test on their data. Anyone interested?
Mark Leavitt (PDX QS Organizer and Fitbit download script tweaker)
I use the script to download my data daily, while I do not use the BP feature there are a few things that I use that are not downloaded. They are Floors Climbed; Time to Bed (AM PM format); Time in Bed (HH:MM format). I am willing to help test.
Hi Mark,
I’m willing to be a beta tester. Which credentials do you need ?
If you are interested in being a beta tester, please connect up with me via email so we can keep your credentials off the web. just remove the ?’s from this and you have my email address: m?ark@mark?leavitt.?com
Is there any way I could set the sync to hourly and get emailed reminders of my daily step count throughout the day? I can’t find a way to set emailed notifications about my progress.
Rod: That’s an interesting idea! I believe something like that could be done. See this video on using twilio with Google apps script to send SMS and voice. How many think this would be a killer feature? Maybe we can get some programming help from others.
Please excuse how dense this might seem, but:
“Now that you’ve set it all up your Fitbit data will automatically be downloaded to that spreadsheet. As you may know, there are a wide variety of charts and Google Gadgets that you can use to visualize that data. For instance, here’s my Fitbit data from 1/1/13 to 2/18/13:”
Where are these gadgets/how does on use them?
Thanks!
Hi Jeff,
Google Gadgets are just different visualization methods that Google has available for spreadsheet data. You can learn more here: https://support.google.com/drive/answer/99488?hl=en
And wait, something else just occurred to me:
Where’s the REST of my data?
As in: what this spreadsheet pulls is great, but it’s only what the device tracks automagically, right? Where’s my food intake/composition information? Does Fitbit keep that for themselves or is it also API accessible?
Food data is available through the API, it just wasn’t implemented in this script. I believe a new version of the script will include calorie intake data.
Check out what Fitbit has available through the API here: https://wiki.fitbit.com/display/API/API-Get-Foods
Ernesto, thanks for both responses.
Gadgets, by the way, is no more
, but I see it’s just a matter of creating my own graphs so … no biggee.
What I’d love to see is the de-conglomeration of the food data. Caloric intake is not so special and is actually represented well enough in your work (did I say thanks enough? ). But, for example, I’ve noticed as I’ve been using my Flex for the last few weeks that my protein intake is relatively low compared to what I always believed it to be, and calories don’t really give that information up unless FitBit’s data repository is splitting the information behind foods we log into permanent (held by them … yikes … insurance companies getting access … ) data categories that can be pulled. Given the speed with which the dashboard does the calculations I believe that must be so, but … I’m going a lot of wondering.
I didn’t realize all of this was so easily accessible, and I presume it’s the same API that FitBit is pulling from (OK, I HOPE this is right) to sell their $50/annum reporting service.
Fascinated … thanks again …
Pingback: Achieving Influency, Doing It (Literally) One Step at a Time
Pingback: FitBit script to automatically export FitBit data to Google Docs spreadsheet | JeremyHaggard.com
Hi… Thanks for making the video!
I have a question. How would I go if I only want the steps taken. I need the break down of steps like they display on the dashboard by 5 minutes increments. For example “105 steps taken from 10:00 to 10:05. As right now Im doing manually and is a very tedious job.
Thanks for you help.
Authorize script is not working, it just says: running … and never goes away.
Inge, I have seen this problem occur. Please try clearing the browser cache, closing the browser, and retry the authorize command. If that doesn’t work, see if there is a popup blocker operating for the browser, and if so, disable it temporarily. Good luck!
Mark
Hi Mark,
I have tried your suggestion with 4 different browsers. No luck.
Inge, if you would like we could use Google hangout or Skype to screen share, and try to troubleshoot. The script editor has some basic debugging/logging tools that we can run while attempting to authorize. It might help me figure out what’s not working. What time zone are you in?
Mark
Hi Mark,
I am not sure how to manage a screen share. Stupid, I know
I do have another question. What do you fill in on the the fitbit dev authorization screen? You say to call the app whatever you like . but should it not be the same name as the google spreadsheet ? What do you fill in on the other fields: application website, organization, call back URL. And how should the google spreadsheet be authorized, just me ?
Hello Mark,
Thanks for this excellent script!
It works great with day-to-day data, however I would like to visualize minute-to-minute resolution. I have a fitbit partner account. Would it be possible to extract minute-to-minute data by using your script? If not, do you have any suggestion how to do it in the fastest way? .. I am actually a researcher, currently in a rush to process some data so I am trying to avoid reading fitbit documentations and writing scripts from the scratch
Thank you in advance!
Best,
Alex
Inge > the same problem occurred to me. I resolved it by changing the settings in “Manage my apps” from “desktop” to “browser”. (it’s actually well explained above but I put it on “desktop” by mistake so this resulted in endless “running”.
Hi Alex,
did you find a way to do what you were asking in your post? Although I think you will only be able to get down to a 5-min resolution and not minute-to-minute resolution… I’ve seen this raised a couple of times but couldn’t find a satisfactory answer.
I’d be very interested if someone found a way to update the script to get data down to a greater resolution than on a daily basis.
Hello Mark,
Solved the problem. I did it all again and suddenly realized that the second “authorize” is not in the Fitbit pull down menu but on the script editor menu. Very stupid of me.
It is all working fine now.
Hi Ernesto and Mark-
Many thanks for posting this- very elegant and excellent instructions.
One quick follow up- I successfully generated the sheet and pulled some data, but am having the same problem as ‘John’ on March 7, where I’m only getting one day returned. Any ideas what I might be doing wrong as I should have a couple of month’s worth of data available.
Any help very much appreciated
cheers
Piers
Hi – I have a flex and a one under different email accounts. My flex is linked to gmail, the one is linked to a different account. Is there any way to authorize the one and have both datasets download to my google spreadsheet? It looks like I have to set up another gmail account to access the non-gmail tracker….
Any help would be greatly appreciated!
got it — had to change the login during the authorization step…. it worked! 2 spreadsheets with data that I can now merge into 1! You guys rock!
Thanx,
J
Pingback: Koppel Fitbit data aan Google Drive spreadsheet - Project: leven
Love the script. Although I have weight data showing for the last couple of weeks, the BMI and fat data suddenly stopped. Fitbit website and mobile app show the weight data, BMI, and fat data, but the Google spreadsheet cells for the past 2 weeks are just blank. Any ideas?
Super Cool.
Thanks for the effort. Works perfectly as given.
Great Job.
In the past couple of days, something strange has happened to the Activity Score readings: now that column is reading “-1″. I noticed this in Beeminder, where the entries for 28 and 29 September show “-1″. In the Googledocs spreadsheet I created using these instructions, the entire column has “updated” to “-1″. What’s the recommended solution here? I’m guessing that Fitbit has changed some detail of its API (the other columns seem fine) and that has effected the data coming into both my Beeminder graph and the spreadsheet. So will copying the API keys and setting things up anew help? Or is there a better solution?
I think I found the answer for myself with this notice: https://groups.google.com/forum/#!topic/fitbit-api/8IRaX6RW7g4
Apparently the Active Score was confusing users so it has been abandoned by Fitbit…
In my spreadsheet, activeScore went to -1 throughout. There was data there yesterday. Has this happened to anyone else?
I only see -1 as well.
Not sure what happened to the Active Score it is missing on the dashboard also. Sent an email to fitbit but have not heard back from them.
Thanks very much for developing and sharing this. I have the same question several others asked.
“Anyone else having an issue where the dates are off? It seems like all the dates are one greater than they should be except for the last row which is correct. This shows as the last 2 rows having the same date.”
Any help with this would be much appreciated.
Anybody have luck modifying the script to get blood pressure? Thanks.
This is very cool. Thank you.
Very helpful info and thanks for making your code available. Quick question: why don’t I see the numbers for stairs climbed, anyway to add that up?
Pingback: Freeing my Fitbit data | bonnie barrilleaux
So, for the last two days, I’m getting an email from google saying the script failed to run on the trigger with this error message:
12/23/13 12:54 AM sync TypeError: Cannot call method “getContentText” of undefined. (line 145, file “fitbitdownload”) time-based 12/23/13 12:54 AM
This is line 145:
var o = Utilities.jsonParse(result.getContentText());
It is not clear to me what the problem is with getContentText, anyone know? Seems like it ran for a couple of days and then the last two days started shooting this error. I’ve just started looking into it, but hoped someone else might have solved it already. Thanks.
I’ve been getting this error message the last few days also… any hints would be appreciated.
Utilities.jsonParse is deprecated for bugs. Try using JSON.parse or eval() careful using the latter. The error is likely not with getcontenttext.
Jim
I’m following all the steps, but when I try Authorize, the script remains running and no dialogs appear. Does anyone have the same problem?
Thanks for sharing your work!
I am also having problems with the “Authorize” step. I have correctly entered all information in the “Setup” phase, but the “Authorize” script fails to run. Has something changed with Fitbit policy or with the Fitbit API? Any help would be great!
I also seem to have fallen victim to not reading… I was clicking “Authorize” on the Fitbit pull-down menu instead the spreadsheet rather than in the script editor…
I was very excited to find this and hoped to learn a little about programming along the way. However, after following the instructions a few times, I am still getting rows of dates, but no values for steps. Calories are recorded (at a default rate, I assume) as are 1440 sedentary minutes (24 hours per day). I am also unable to see today’s steps in the fitbit iphone app, which makes me thing that the problem lies with my device.
If there’s a “for dummies” text, please point me in that direction, though I suspect this activity is not for dummies.
I have been entering the following info on the fitbit website:
Resting Heart Rate
Normal Heart Rate
How do I download it.
/body/RestingHeartRate – did not work
As a test I even tried the following, but was not able to get it to work.
/body/bicep
/body/log/bicep
Did not find any documentation on the Fitbit wiki site either.
I am also interested in importing body measurements like waist, bicep etc. I tried the same as subaron did to add body body/bicep body/log/bicep etc to loggables. I get error downloading …error 400 I think. What am I missing?
Thank you very much for your work on this.
Jim
Ok, I found the problem with importing body measurement data. The api will not except a date range with the /body/ resource. When only the start date is submitted in the GET the 400 error goes away. Furthermore, the /body/ resource has a bunch of data fields within it that must be parsed out and dealt with(titles created, data filled) one date at a time. This indicates to me that all the data should probably be handled differently, and some way of selecting each measurement in the setup function would be nice.
I was able to print one value to a test spreadsheet by editing as follows.(don’t do this to your live spreadsheet lol)
for (var activity in activities) {
var currentActivity = activities[activity];
try {
var result = UrlFetchApp.fetch(“http://api.fitbit.com/1/user/-/”
+ currentActivity + “/date/” + getFirstDate() + “.json”, options);
} catch (exception) {
Logger.log(exception);
Browser.msgBox(“Error downloading ” + currentActivity);
}
var o = Utilities.jsonParse(result.getContentText());
var cell = doc.getRange(‘d10′);
cell.setValue(o.body.bicep);
also I added “body”, to the LOGGABLES and selected it exclusively via setup()
I’d love to help but I really am not the guy to write this code
Thanks again
Jim
Ok, impatient as I am, I went ahead and wrote code for importing body measurements.
Caveat: my code is long winded and far from eloquent. Clumsy at best.
But it works, I’ll clean it up tonight and then I’m happy to share it.
The same methods I used can be used to pull any data down from fitbit, but further looped parsing will need to be added to accommodate food logs and activity logs.
Currently my code must run on the same synced sheet as the rest of it. So you may want to make a copy before testing.
Happy quantifying!
Jim Hamilton
Hi, this is pretty good stuff, but I have one question, Can I automatically download, lets say just the steps for a given day for multiple users?
Bisono, yes you can. But it would be easiest IMO to do this with multiple spreadsheets and 1 script/user per spreadsheet. Set these scripts to time trigger, and write a script to import the spreadsheets’ data into one sheet.
It could be done in one sheet with one script with some pretty major changes as it would require multiple authorizations, multiple oauth tokens etc. Also username would have to be logged into the sheet, it is not currently.
And of course you are trying to display 3 dimensions of data in 2 dimensions, so layout should be a concern. How many users are you talking about?
Jim
I kind of change the code to do what I want, but I guess every user that I need to pull the steps out of it, they need to allow this app? I would like to do 5 spreadsheet 30 people each sheet.
For some users, Im able to retrieve the steps, but others not, because authorization. Do you know if those users by changing their privacy setting, I then will be available to retrieve that info? Thanks for your answer.
I THINK so, haven’t tested it. You would need their encoded user id I think.
This is the last letters and numbers after the last / of public URL, can be found on users profile page. you would then enter that info in place of the dash (-) in the fetch, and not use the oAuth token. Again, I have not tried this but I believe its possible if they have this data set to “Anyone” in their privacy settings. If it works it wouldn’t be too much trouble to do this in one script.(for someone good at writing scripts, but I’m happy to help.)
Hope that helps
Jim
To whomever is interested,
I now have functions written into this script for body measurements, heart rate, and blood pressure. I am still cleaning it up a bit, but I am happy to make it available to anyone that wants it. Its still a bit clunky, and there may be date related errors that I haven’t found yet. I am new to JSON, FitBit, and Google Docs, lol.
Once its tested a bit, I am happy to help modify this for everyone’s needs.
Jim Hamilton
I would be very interested Jim on how you were able to modify the script for the additional parameters. How would I go about doing this also?
Ryan, it is a few hundred lines of code added to the script. I’d be happy to email it to you or post it somewhere.
Jim
Jim, that would be amazing if you could! I have created an email ryan_quantified@hotmail.com. Your work on figuring this out is very much appreciated. I tried but my coding knowledge is very limited. Thank you again in advance!
Ryan.
Jim,
I would be very interested in your modifications to retrieve Blood Pressure information.
Could you please mail it to me as well at vaidspud@yahoo.com ?
Thanks for all your efforts on this.
T.Savage
T Savage,
You bet. sorry just got the note. Give me a bit to find the right code and make a change to the readme and I’ll send it to you ASAIC.
jim
Thank you very much. I look forward to seeing it!
T
Hi – Could you email me the code used to retrieve the heart rate metrics?
timbeyers@gmail.com
Thanks.
Jim, I too, would be very interested in your code for retrieving blood pressure. Thanks so much.
Hi Jim,
I would love to see the code. Maybe I could use it as a base to get the carb/protein/fat information. Could you email it to twilliamslynch@yahoo.com?
Really appreciate the help,
Thanks,
Teresa
Hi Jim,
I would love to have a copy of this script. Could you share with erodriguez87@gmail.com
thanks!
Eddie Rodriguez
Could I get a copy as well? ruddenca (at) gmail (dot) com . Thanks!
Hello,
Thank you for this fantastically informative tool! I have encountered an error when at the authorize step. A box appears “App Script Error Attempting Authorization” with an “ok” tab. Can anyone please help?
Thank you!
Glad everything worked for you. Thanks for your help testing.
Jim
has anyone figured a way to rig a silent alarm to remind you to get up and move if you have been sedentary too long? I’m thinking you could create an active pct base don the sum of the active minutes / minutes sedentary and set an alarm if it fell below a target threshold.
Hi Joe,
This is a feature I’ve recently added to TRAQS (http://traqs.me). Silent alarms are created based on inactivity, and thresholds are defined based on daily/weekly goals. The plan is to include this in the next beta round in a few weeks If you’re interested feel free to signup for the beta and we’ll get you on the list to try it out as soon as it’s ready.
Thanks, I just sent a request to join beta~!
Joe, that would be one way to do it. However, you will be getting lots of alarms after you first get up. The target percentage would change throughout the day. I would go about it as follows: set to sync every 30 min. compare steps with steps 30 minutes ago, if difference < 50 set alarm for now() plus 5 minutes. put all this in an 'if 6am < now() < midnight {}' so you don't get alarms all night, then json.stringify the alarm time and post to fitbit.
hope that helps, lemme know what you come up with
jim
Thanks I just sent a request to join your beta!
First of all. Love this tool! Thanks for building it.
Does anyone know if it will be supported in the new google sheets?
I have a physical exam tomorrow and I just discovered this script. I’m trying to modify to retrieve blood pressure, also, but I can’t figure out the parameters. Could you send me the data, also or post your code?
Hi Ernesto,
Any luck getting the BP export into your script? I want to be able to spit out my BPs to take to my doctor!
Thanks!
RY
For the time being, I’m using Microsoft HealthVault to pull my blood pressure data from Fitbit.
Unfortunately HealthVault is not available in Canada, so I’m out of luck I guess for the time being. Guess I will have to start keeping it in a spreadsheet as well.
In my case, it refuses to authorise the device. It either gives me an “authorization error”, or gets stuck at “running script”. i have tried getting and setting new keys, but nothing seems to make it work. Any ideas?
Thanks!
Pingback: My Struggle with Fitbit API | P337
I, too, am getting “Apps Script – Error attempting authorization”. I have double-checked my keys and everything seems in order. Any ideas?
Have you or anyone else found a solution to this problem?
The spreadsheet isn´t working any longer since 1. April 2014 for me. I now geta daily error message “TypeError: Methode “getContentText” von undefined kann nicht aufgerufen werden. (Zeile 145, Datei “fitbitdownload”)” from Google Apps.
I remember I got a mail from fitbit that they would change something regarding their developer APIs a few weeks ago, so I suppose they changed the method how one can get his data, and the script is therefor not working any longer.
Please leave a comment if you are still able to collect your fitbit data with this script (or what I need to change to get it working again) – or add a comment on an alternative way to get to your data, if you know one.
Thanks & stay fit!
Google drive has moved from “script gallery” to “Add-ons” store and it does not list the FitBit Download anymore? Is anyone else having trouble getting this set up?
I have the same problem.
Same here
This is a big issue and thanks for pointing it out. You can still access (for now) the old version of Google Spreadsheets and use the Script Gallery using this link: https://g.co/oldsheets
Thanks Ernesto Ramirez . Perhaps the beginning of this article coupled be revised ??
Hi, Ernesto,
I tried accessing “the old version of Google Spreadsheets” etc per your 25 June comment, but nothing about FitBit appears in any menu that I see, and there’s no obvious place to paste my Client Key and Client Secret.
Programming a spreadsheet is unfamiliar to me, so I’d second DG12′s suggestion for an update to the directions at the start of this article if you get the time.
Thanks so much for this!
I had success getting the script working in the ‘new’ Google Sheets by opening up the script editor, creating a new spreadsheet script, copying and pasting the code, and running the steps as described above.
I’ve just done one sync, so no long term testing, but hopefully it continues to work.
Hi guys – switched to the updated script + new google spreadsheet but I get errors when it tries to run overnight along the lines of ‘please select an actice sheet first (line 125, file code). When I manually run the sync from the spreadsheet, I get an error message “Error downloading activities/log/activityCalories” after which the sync continues if I close he error message.
Is this something any one else has faced/ resolved?
Regards,
AJ
I’ve actually made a much easier way to do this: it’s online at http://fitbit-export.azurewebsites.net/. It’s open source, there’s a link from that page to view the source code if you’re interested.
Activities: distance in the exported file is different from the value in Fitbit Dashboard. Is it a bug?
Are the units the same on the dashboard and the spreadsheet?
I get the following error: Please select an active sheet first. (line 114, file “Code”) when I try to run the script from a time trigger. The script works run manually. Any help is greatly appreciated.
I’m having this problem as well. Would also welcome suggestions.
the code seems to be having an issue figuring out which sheet to sync the data to. on line 124, change the code from this:
var doc = SpreadsheetApp.getActiveSpreadsheet();
To this (replace raw data with the name of the sheet you are syncing to):
var doc = SpreadsheetApp.getActiveSpreadsheet() .getSheetByName(‘raw data’);
I’ve been working on a better fix for myself, but this seems to solve it if you don’t have any other Google Spreadsheets with a sheet named the same thing.
Thanks for solving this for me. The spreadsheet tab is unique, and will always be unique so this solution works fine for me. Again Thank you
When I make this change, I get this error for the following line:
TypeError: Cannot call method “setFrozenRows” of null. (line 125, file “fitbitdownload”)
Not sure what the problem is. Any ideas?
I don’t know if you figured it out yet, but I was having the same problem. What I finally ended up doing to get it to work was to replace:
var doc = SpreadsheetApp.getActiveSpreadsheet();
With this:
var doc = SpreadsheetApp.openById(“DOCUMENT_ID_GOES_HERE”);
doc.getSheetByName(“Sheet1″);
Putting getSheetByName as it’s own line cleared up the setFrozenRows error, and then I found that without specifying both the ID and the sheet name, everything worked fine manually, but failed on the timed trigger. This method has it all working for me now.
Thank you so much for this write up! This is a great way to get at the raw Fitbit data.
I notice is the form to register an app, company, company website, ect. are required. Is it possible to utilize this great tool as an individual?
Hi Mike,
Sure thing. You can fill in dummy information or your personal website/name if you’d like. Should still work.
Is this app still functioning? I am showing the app is deprecated after running the raw code when authorize.
I am Getting an error message: Apps Script, Error attempting authorization. Any thoughts?
Hi
Just getting started with the API and I was getting the same error. As of Nov 3, connections to api.fitbit.com are restricted to HTTPS. Just search through the script and change http to https and ‘you off to the races’.
I followed all the steps, but when I copied and pasted the script, this is the message I get:
ScriptProperties API is deprecated.Expand
File: fitbitdownload Line: 177
Method Utilities.jsonParse is deprecated.Expand
File: fitbitdownload Line: 289
Do you know what could be getting wrong?
THanks
Great post. This is a strong step forward for me to liberate and use my Fitbit Data. I’d been using a plugin for wordpress, but now i’ll be able to use IFTTT alongside Google Docs.
Thanks.
Pingback: Review - FitBit Flex - The Random Bits & Bytes Blog
I’ve copied the code and getting this error when I try to authorize:
ScriptProperties API is deprecated.Expand
File: Code Line: 181
Method Utilities.jsonParse is deprecated.Expand
File: Code Line: 43
Is there an update to this code?
Thanks in advance.
Pingback: 2014 in numbers | Donald R Noble's website
Pingback: 4 Ways Routines Trump New Year Resolutions - Red Gram Living
Pingback: Shopping for a Tracker | IoT Spoon
Pingback: How To Fix Fitbit Parse Error in Windows
I’m getting an API depreciated error saying to calls may be removed in the future
ScriptProperties API is deprecated.Collapse
File: Fitbit_Data.gs Line: 181
The API has been marked as deprecated which means that the feature should be avoided and may be removed in the future. Consider using an alternative solution.
Method Utilities.jsonParse is deprecated.Collapse
File: Fitbit_Data.gs Line: 43
The method has been marked as deprecated which means that the feature should be avoided and may be removed in the future. Consider using an alternative solution.
Pingback: Fitbit App Tutorial | Wearable Tech Store
Please downlod fitbit
I found Fitbit Flex manual here http://www.userlib.com/fitbit-flex-manual-tutorial/
Pingback: Get fitbit steps on your personal website [Revised] | P337
Looks like this finally broke–Google involuntarily moved my Fitbit spreadsheet to the “new” Google sheets, and I got this error:
Start Function Error Message Trigger End
5/6/15 12:23 AM sync Please select an active sheet first. (line 128, file “fitbitdownload”) time-based 5/6/15 12:23 AM
If anyone hit this and can give me a fix, I’d appreciate it! Google help says that at this point, I cannot revert to the old version of Sheets.
Here’s how I solved it.
I download/store the data in a sheet called “Raw data”.
In function sync(),
After:
var doc = SpreadsheetApp.getActiveSpreadsheet();
Add:
SpreadsheetApp.setActiveSheet(doc.getSheetByName(“Raw data”));
Save and re-run sync to verify.
Enjoy.
Thanks so much–that fixed it.
I can’t get my “authorize” function to work. It keeps telling me “Authorization is required to perform that action.” I believe it’s supposed to open a dialog box and then a webpage that allows you to ‘authorise’ access to your fitbit account, but mine doesn’t do anything at all, just comes back with that error message. Any ideas?
I am having the same issue as Rowena. Any ideas on a fix?
I had the same problem. Try to run the “authorize” function in Debug Mode (the icon look like a bug).
This fix worked. Thank you Elie.
Thanks Elie, this worked!
Is there already a good fix for the trigger?
Thanks,
Kevin
Script is using OAuthConfig which has been shut down. Learn more at http://goo.gl/IwCSaV
actually, I can’t understand what happens, and what I am supposed to do
I’ve received the same error today and no matter what I try, I can’t fix it. I was able to find a solution in ‘Library’ on July 7th but it’s back to the same error from them and it’s unrepairable. Please help! I’m NOT a techie at all. Just a dedicated Fitbit user who relies on the daily downloaded Google spreadsheet to keep me focused.
thank you
Same happening with me too! Can’t figure out why all of a sudden this change. It was working fine last week.
If you search the forum on fitbit for “Google apps script for minute-by-minute data stopped working suddenly” and follow all the messages, you will find the solution. It worked for me….finally!!!
Fran,
What forum should we search?
The Fitbit Community Help Forums
Thanks, it helped a lot.
Now I just need a way to make the list “appended” instead of “first the newest”
ATP I am ordering data manually, but…
Thanks again
done with another sheet and SORT. if anybody has a fastest way…
https://github.com/slarson/Fitbit-for-Google-App-Script
Are you going to be updating this information since Google is using a new OAuth script. I know absolutely nothing about this kind of scripting but want to update my Google doc spreadsheet to keep up with my Fitbit data.
I tried to follow the Video but with the new googledoc form, I only find under “Add on” one result if I look for “fitbit”.
This result, however, is not “FitBit download” but “FitBit Activity Importer” and it only imports a few data and only from the last 30 days.
Moreover I dont Need an application Login for that.
Can you tell me how I can get all the Information you get in the Video?
Script gallery is now the add-on store
In the new Google Sheets, the script gallery has been replaced with the add-on store. Click the new Add-ons menu to get started.
There is only 1 option there: Fitbit Activity importer. Which appears to not work.
I have this error :
Script is using OAuthConfig which has been shut down. Learn more at http://goo.gl/IwCSaV (line 28, file “Code”)
do you know how to manage it ?
The website http://www.wellnessbear.com has free Fitbit data trend reports with option to export to Excel.
Does anyone know how to pull macros data (carbs, protein, fat) using this script? I’ve tried adding several types of calls but nothing is working. I don’t know how to format the request to get that information, or is it even more involved?
I’ve tried:
“foods/log/summary”
“foods”
“foods/summary/carbs”
“foods/carbs”
“foods/log/carbs”
“foods/log”
“summary/carbs”
“foods/log/summary/carbs”,
Brilliant App !! Thx for offering that, but unfortunately I fail
I followed all Steps, but i fail on Step : authorize
Script-Debugger tells me : TypeError: Funktion setProjectKey in Objekt [object Object] nicht gefunden
But I’ve set ProjectKey (which I can also find in the Poperties of the project)
What am I doing wrong ?
My silent hope is : Can this API-Interface fetch more data then only 30days ? Would be great !
Cheers
Stephan