How To Download Fitbit Data Using Google Spreadsheets: An Update

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.

  1. 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.
  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”
  3. 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.
  4. 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.
  5. 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.
  6. 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.

This entry was posted in QS Resource and tagged , , , , . Bookmark the permalink.

155 Responses to How To Download Fitbit Data Using Google Spreadsheets: An Update

  1. spg says:

    Very nice, thanks. Anyone know of something for MyFitnessPal data?

  2. Lucy Buykx says:

    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”

    • Ernesto Ramirez says:

      Thanks Lucy!

      • Sander Minderhout says:

        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.

  3. Geek On Acid says:

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

    • Ernesto Ramirez says:

      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.

      • Matt says:

        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

  4. Mr. Gunn says:

    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?

  5. Julia says:

    This is great! Thanks for making the video.

  6. Scott says:

    Thanks for the video!

  7. Tucker says:

    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.

  8. Jason says:

    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

    • Brian says:

      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.

    • Jason says:

      anyone??

      • subaron says:

        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.

  9. Nicolas Perrault III says:

    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!

  10. Pingback: Fitbit Lab

  11. Jack Martin says:

    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.

  12. Matt says:

    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…

  13. Thomas says:

    This is great. Thanks! However, how do I update the script to convert weight and distance from metric?

    • John says:

      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.

  14. Pingback: March Personal Challenge : Be More Active « Sometimes, those who wander really are lost

  15. John says:

    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.

    • John says:

      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.

  16. Jonathan Hyland says:

    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.

  17. John says:

    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.

  18. Jeff says:

    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!

  19. Angela says:

    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.

  20. Pingback: 3 Months of Fitbit | Colin Sullender

  21. spg says:

    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?

  22. Heather says:

    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!

    • Jonathan Mace says:

      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.

      • Ernesto Ramirez says:

        Thanks Jonathan!

      • Yeah, what he said. Thanks!!!

      • EventHorizon says:

        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.

        • haleyma says:

          Were you able to resolve this? I’m having the same problem.

          • YoMama says:

            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” }

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

  24. stevecaks says:

    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?

    • Ernesto Ramirez says:

      Hi Steve,

      You can put whatever you want in the website. I don’t think it matters too much!

  25. Sardauker says:

    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 :)

    • Sardauker says:

      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?

  26. Sardauker says:

    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.

      • Sardauker 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…

  27. Sardauker says:

    (i forgot a Thank You :) )

  28. Catherine says:

    Thanks for the video!

  29. Allen Price says:

    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.

  30. Alana says:

    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)

  31. Marc_Hav says:

    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

  32. Mark Leavitt says:

    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)

    • spg2.0 says:

      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.

    • Marc_Hav says:

      Hi Mark,
      I’m willing to be a beta tester. Which credentials do you need ?

      • Mark Leavitt says:

        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

  33. Rod says:

    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.

    • Mark Leavitt says:

      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.

  34. Jeff Yablon says:

    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!

  35. Jeff Yablon says:

    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?

  36. Jeff Yablon says:

    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 …

  37. Pingback: Achieving Influency, Doing It (Literally) One Step at a Time

  38. Pingback: FitBit script to automatically export FitBit data to Google Docs spreadsheet | JeremyHaggard.com

  39. Carlos says:

    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.

  40. Inge says:

    Authorize script is not working, it just says: running … and never goes away.

    • Mark Leavitt says:

      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

      • Inge says:

        Hi Mark,

        I have tried your suggestion with 4 different browsers. No luck.

        • Mark Leavitt says:

          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

          • Inge says:

            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 ?

  41. Alex says:

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

    • Tom Brown says:

      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.

  42. Inge says:

    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.

  43. piers says:

    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

  44. J Jones says:

    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!

    • J Jones says:

      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

  45. Pingback: Koppel Fitbit data aan Google Drive spreadsheet - Project: leven

  46. Jake says:

    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?

  47. Vijay says:

    Super Cool.

    Thanks for the effort. Works perfectly as given.

    Great Job.

  48. Yvonne says:

    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?

  49. some guy says:

    In my spreadsheet, activeScore went to -1 throughout. There was data there yesterday. Has this happened to anyone else?

  50. spg says:

    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.

  51. Rock says:

    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.

  52. John Moore says:

    Anybody have luck modifying the script to get blood pressure? Thanks.

  53. haleyma says:

    This is very cool. Thank you.

  54. Zilvinas Ace says:

    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?

  55. Pingback: Freeing my Fitbit data | bonnie barrilleaux

  56. haleyma says:

    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.

    • wb says:

      I’ve been getting this error message the last few days also… any hints would be appreciated.

    • Jim Hamilton says:

      Utilities.jsonParse is deprecated for bugs. Try using JSON.parse or eval() careful using the latter. The error is likely not with getcontenttext.

      Jim

  57. Javi says:

    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!

  58. Jesse says:

    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!

    • Jesse says:

      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…

  59. chance says:

    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.

  60. subaron says:

    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.

  61. Jim Hamilton says:

    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

  62. Jim Hamilton says:

    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

  63. Jim Hamilton says:

    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

  64. Bisono says:

    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?

  65. Jim Hamilton says:

    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

    • Bisono says:

      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.

    • Bisono says:

      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.

  66. Jim Hamilton says:

    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

  67. Jim Hamilton says:

    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

  68. Judy Giordano says:

    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!

  69. Jim Hamilton says:

    Glad everything worked for you. Thanks for your help testing.

    Jim

  70. joe f says:

    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.

    • Eric Blue says:

      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.

    • Jim Hamilton says:

      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

  71. Jen says:

    Thanks I just sent a request to join your beta!

  72. First of all. Love this tool! Thanks for building it.

    Does anyone know if it will be supported in the new google sheets?

  73. Woody says:

    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?

  74. Ryan says:

    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

    • John Moore says:

      For the time being, I’m using Microsoft HealthVault to pull my blood pressure data from Fitbit.

      • Ryan says:

        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.

  75. nenakat@gmail.com says:

    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!

  76. Pingback: My Struggle with Fitbit API | P337

  77. Kurt says:

    I, too, am getting “Apps Script – Error attempting authorization”. I have double-checked my keys and everything seems in order. Any ideas?

  78. Nico says:

    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!

  79. Rustle98 says:

    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?

  80. DG12 says:

    Thanks Ernesto Ramirez . Perhaps the beginning of this article coupled be revised ??

  81. Bob Leedom says:

    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!

  82. John Dugan says:

    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.

  83. AJ McSedge says:

    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

  84. Nick Heiner says:

    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.

  85. Tom Bruning says:

    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.

    • Sara says:

      I’m having this problem as well. Would also welcome suggestions.

      • Nathan Bousfield says:

        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.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.