Data visualization of
hikes across the world

...insert here some bs wanderlust inspirational quote

For the last few years, I have been recording different parameters for the hikes I've done around the world. I want to pair this data along my Fitbit's API to visualize my body data while hiking. The goal is to learn API data access using the Python Requests package, data manipulation with Pandas, and Plotly graphing tools.


Skillset

  • HTTP requests
  • OAuth2.0
  • Python
  • Jupyter Notebook
  • Pandas
  • Data Visualization
  • Plotly
  • API json manipulation

Process

Accessing the Data

I will be using the two apps above as my data sources. The altimeter app produces a CSV file that can be parsed using Python's pandas package. For the Fitbit app, I will be creating an account and accessing their API.

Accurate Altimeter

This is a pretty good app that allows to measure your current altitude at any moment. It has the capability to record continuously and set them up at different time steps. You can also set the triangulization method to derive your altitude from the internet or use your phone's GPS instead. This is really helpful for those remote hikes where internet is spotty. However, my favorite feature is the ability to export your history to a CSV and its compatibilty with Google Drive. This is my main method to download the data without requiring to access the app's API.

Fitbit

Obtaining data from Fitbit is trickier. There is an option to download a CSV file from Fitbit's online account, but the file contains only a mere summary. Instead, their intraday time series boasts a lot more options, allowing to extract data at different time steps for a wider category of activities. To do so, we'll need to access Fitbit's API.

I've split this walkthrough in 3 main steps:

  1. Creating and registering an application
  2. First, Fitbit requires to create and register an application on their developer's site. This can be done by simply filling out the application on this link. Make sure you select "Personal" under the "OAuth2.0 Application Type" field. This allows to request any intraday time series without any additional access approvals. However, by selecting this field, your application will be limited to pulling personal data only.

  3. Authentication and authorization token
  4. Fitbit has upgraded their authentication requirements to OAuth2.0 only. Their website has amazing documentation explaining both types of authentication flows you can obtain. I decided to use the "Authorization Code Flow" and my initial code was based on this thorough post by Paul's Geek Dad Blog.
    However, I found his authorization code request a bit restrictive, thus I refactored using Python's Requests package instead.

  5. Requesting data
  6. To call the intraday time series I downloaded this Fitbit API client implementation package created by orcasgit. To install the package, clone the github repo:

    git clone git@github.com:orcasgit/python-fitbit.git


Graphs

Check my graphs and data in my Plotly dashboard.
All my graphs are interactive! You can hide each hike by clicking on it or double-click on one to select it.