timvancann / py-google-fit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

py_google_fit

A convenience package for accessing your Google Fit data. It wraps the google python into a few functions to easily access your data. This library is written with read-only intention in mind. There are no helper functions to write to your Google Fit data.

Getting started

Clone this repo and install it into your python environment

git clone https://github.com/timvancann/py-google-fit.git
cd py-google-fit && python setup.py install

Authentication

Start by creating an instance of the GoogleFit object:

from py_google_fit.GoogleFit import GoogleFit
fit = GoogleFit(client_id, client_secret)

Fill in your own client_id and client_secret, create them in your Google developer console

To authenticate, call the authenticate function:

fit.authenticate()

By default it will request read access to three google fit scopes of your account: body, activity and nutrition. If you haven't ran this function before. A browser will open asking you to give access.

Getting your data

Currently supported data is steps and weight. Feel free request more or create a PR.

To get your stepcount for today up till now:

from py_google_fit.GoogleFit import GFitDataType
fit.average_today(GFitDataType.STEPS)

And similar for your weight:

fit.average_today(GFitDataType.WEIGHT)

To get some trend data, a rolling average is usually a good metric:

fit.rolling_daily_average(GFitDataType.STEPS, n=14)

About


Languages

Language:Python 100.0%