Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Exporting sleep data to REDCap

ANSWERED

Hello,

 

Our team is trying to understand what the effort and overall process would be to extract Sleep data from FitBit devices (multiple study participants) into REDCap software for analysis for a research project.

 

Would this involve developing our own code to extract the required data for upload into REDCap, or is there an automated way to extract the data? If it requires developing code, is there any existing code that could be leveraged?

 

Thank you!

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Hi @Haley_M 

 

There will be some sort of development needed to extract your participants data out of Fitbit.   You can use any programming language as long as there is a supported OAuth2 library for it.   I've seen some researchers use script languages.   We have some sample code in our documentation.   I've come across a lot more through internet searches.

 

The process for retrieving the user's data is

1. Register your application at dev.fitbit.com

2. Present the authorization string to your participants

3. The participants consent to share their data with your application

4. Retrieve the authorization code and swap it out for the access token and refresh token.

5. Use the access token with the sleep endpoints to retrieve the user's data.

6. when the access token expires, use the refresh token to obtain a new access token and refresh token.

 

Hopefully, this information will get you started.   If you have other questions, please let us know.

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google

View best answer in original post

Best Answer
7 REPLIES 7

Hi @Haley_M 

 

There will be some sort of development needed to extract your participants data out of Fitbit.   You can use any programming language as long as there is a supported OAuth2 library for it.   I've seen some researchers use script languages.   We have some sample code in our documentation.   I've come across a lot more through internet searches.

 

The process for retrieving the user's data is

1. Register your application at dev.fitbit.com

2. Present the authorization string to your participants

3. The participants consent to share their data with your application

4. Retrieve the authorization code and swap it out for the access token and refresh token.

5. Use the access token with the sleep endpoints to retrieve the user's data.

6. when the access token expires, use the refresh token to obtain a new access token and refresh token.

 

Hopefully, this information will get you started.   If you have other questions, please let us know.

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer

Gordon,

Thank you very much, this is very helpful info to get us started. Appreciate the quick reply!

Haley

Best Answer
0 Votes

Hi Haley,

 

Do you know R at all? You can use R, along with the fitbitr and REDCapR package to commit data to REDCap's API without having to upload it. 

Not sure which institution you're at but I'm on the REDCap team at a large hospital and I'm working my way through this myself. Having to give any pointers if needed. Feel free to message me with any questions.

 

Kiley

 

Best Answer
0 Votes

Hello Gordan,

I have a similar question as the OP.  I should preface by saying I am an API novice, and I am afraid I don't even know what "application" refers to.  I am a sleep researcher and an educator but new to using Fitbit for sleep tracking.  For starters, I'm using Fitbit Charge 5 in a college class that I'm teaching.  I will provide each student with a Charge 5, and I would like to work with them to analyze their sleep and activity data (among others).  In essence, I would like to access their data (with their permissions) like I would a research participant's data.  How would you recommend going about that?  [The registration page also asks for links to terms of service and privacy policies.  Since this is for a class I'm teaching, I do not have that information.  How should I proceed?]

Relatedly, I tried to export my data as a user, and the only sleep metric it downloaded was the "sleep score".  How do I go about downloading other sleep data?  [I've only collected data for one night so far.]

Thanks for your help!

-Irene.

Best Answer
0 Votes

Hi @eyepecan 

My apologies for the delay in responding.  I didn't see your question until now.

The recommended method for querying other user's data is through the Web API.   This does take some technical knowledge.   Some researchers are familiar with scripting languages.   These can be used to query the user's data as long as there is an OAuth2 library available.  Another option is using Google Sheets to pull the student's data.  We have an example in our documentation.  See https://dev.fitbit.com/build/reference/web-api/developer-guide/libraries-and-sample-code/.

Once you have the application or script working, you can email your students the authorization URL so they can consent to share their data then you can pull their data.

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hello Kiley,

Were you able to figure out how to download participants data using R?

Jen

Best Answer
0 Votes

Hi Jen,

Yup, I was able to successfully pull the data into REDCap using R. If you have any questions about how to do so, feel free to send my way.

Kiley

Best Answer
0 Votes