Fitbit instructions

Using Alteryx to download Fitbit data
Thank you for attending our first Alteryx user group meeting this week. As promised I wanted to follow
up with some documentation of the workflows we reviewed. Find below steps for using the attached
Fitbit workflow:
Fitbit uses an authentication process known as OAuth2. This requires users to give permission before an
application can access their data. Getting this set up requires a Fitbit developer account and a redirect
URL to post the authorization response to. Let’s walk through this process:
1. Go to https://dev.fitbit.com/ and create an account with Fitbit.
2. Once complete you will see register an app at the top of the page. Click here and you will see
the following form, most fields are required but will not be used:
Application Name: You can name the application anything you
want. This Alteryx workflow was created to track a company
fitness challenge so I named my application with our company
name.
Description: Again you can put anything you want here. A short
description of what your application will be used for is ideal. If
needed you can display this on the authorization screen.
Application Website: This field will not be used in our
application. Any address in an http:// format will work.
Organization: Enter your name or your companies name here.
Organization Website: This field will not be used in our
application. Any address in an http:// format will work.
Oauth 2.0 Application Type: I chose client for this option. Once
you are familiar you may want to create a personal application
as it gives you access to minute by minute fitness data. The
attached workflow pulls daily totals so a client application is
sufficient.
Callback URL: This field is the most important. After signing into Fitbit users will be directed to this
URL to confirm the authentication was successful. I have created a very simple public website on
AWS that you can use - https://s3.amazonaws.com/arkafit/index.html. This site will also parse the
appropriate authorization information from the redirect URL on to the webpage for easy
consumption. For those wanting to create their own website I have placed the parsing JavaScript
directly in the HTML so it can be viewed in the browser.
Access Type: I chose read only as I am not using Alteryx to write back to Fitbit.
Don’t forget to accept the terms of service.
3. Once complete you will be given the following information about your new application (Your
information will be different than what is shown below):
4. Now it’s time to authenticate your Fitbit! Adjust the following URL to match your new
application OAuth 2.0 client ID:
https://www.fitbit.com/oauth2/authorize?client_id=XXXXX&response_type=token&redirect_uri=htt
ps://s3.amazonaws.com/arkafit/index.html&scope=activity%20heartrate%20nutrition%20profile%2
0location%20settings%20sleep&expires_in=31536000
Let me explain this URL a bit. Everything before your client ID is the standard Fitbit base URL and
everything starting with the client ID forward is a URL parameter. Parameters are connected by the
& symbol. The first 3 parameters are mandatory – Client_id, Response_type, and redirect_uri. Per
the steps above you already know your client ID and redirect URI, the response type parameter
indicates that this request will return a security token. This token will be shown on the redirect site.
Everything that comes next is optional. The scope parameter indicates what type of data your
application is requesting access to (users can change this during the authentication process), to
make this tutorial more universal I am requesting access to almost everything. However, if your
Fitbit device does not track heart rate you could remove the following argument from the scope
parameter: %20heartrate%20 (note %20 is the same as a space).
The last piece of the URL is how long the authentication lasts. I have set this to 1 year
5. Once the URL above is adjusted users that navigate there will be pushed through the following
process:
Log into Fitbit
Confirm authorization
consent
Arrive at redirect URL
You now have all the information you need to use the attached workflow!
Using the workflow
The workflow has two inputs. The first contains all the API strings for the calls we want to make to
Fitbit (no need to change this), the second is where you will enter your user information:
Fill out this text input tool with the information displayed from the end of step 5. That’s it! You can
now run the workflow and view your Fitbit data in the browse tool at the end of the workflow! This
workflow does only pull the last 7 days of data. If you want to pull longer periods of time you can
adjust the API strings in the text input tool:
Adjusting the 7d value to 30d, or max will pull 30 days of data or your entire fitness history
respectively. You can find all the available parameters in the fitbit API developer docs.
We use this Alteryx workflow to visualize our exercise in a Tableau dashboard, and compete in an
office challenge. If you do something similar I would love to see the end result!
Thank you again for coming to the user group!
Kevin