Giter Site home page Giter Site logo

rwithings's Introduction

rwithings

The goal of rwithings is to enable data extraction from the Withings Health Mate API into R. You will need to follow the instructions on the linked developer's guide to create a Withings account and a Withings developer app.

This package is still quite young, so there could very well be some remaining issues.

Installation

You can install the development version of rwithings with the following:

devtools::install_github("mathesong/rwithings")

Prerequisites

Before being able to use this package, and the Withings Health Mate API, you will need to create a Withings account and a Withings developer app. Instructions are provided in the developer's guide.

Note: when setting up an app, the Callback URL should be set to http://localhost:1410/. This is not supposed to be allowed, but it does seems to work, and I haven't been able to make it work using another address. If anyone has any input on this, please do make an issue.

Examples

API Functions

The functions of the package basically correspond to the same commands listed in the developer's guide, with similar input arguments. Below are some examples.

client_id <- 12345
client_secret <- "hunter2"

token <- withings_auth(client_id, client_secret)

getmeas(token, meastype = 1, category=1, "2018-01-01", "2018-10-18")
getsleep(token, "2018-10-16", "2018-10-18")
getsleepsummary(token, "2018-10-16", "2018-10-18")

In the case of entering in start and end dates, there are conversions in place so that you can enter it as a character vector in YYYY-MM-DD format to make quick queries more easy.

CSV Functions

The API used not to have functions for extracting heart rate data. This data could only be obtained by following these instructions to obtain a csv file. The data arrive in a format which is a bit messy to work with, so I also included some functions for munging the raw data. Most of the raw data is structured according to start, duration and value columns, so for these csv files, the command to read them works as follows:

hr_data <- read_csv_startdurval('raw_tracker_hr.csv')

The API has been expanded to include HR data now as intraday activity, which can be extracted using the getintradayactivity() function. Tthe CSV munging command remains in place regardless as it's still useful for processing large amounts of data at once without running into API request limits.

rwithings's People

Contributors

fjukstad avatar mathesong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rwithings's Issues

Issue with rbind

When I try to call

rwithings::getmeas(token, meastype = 1, category=1,startdate = '2020-05-24', enddate = '2020-05-25')

I get the following error:
Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match

I've been able to resolve the error by running a chunk like this, based off of the underlying code in the getmeas function:

out$body$measuregrps %>% 
  unnest(measures) %>% 
  mutate_at(vars(c(date,created)), list(~ as.POSIXct(., tz=tz, origin="1970-01-01")))

I don't know if it's worth replacing rbind, but wanted to give you a heads up!

Switch / work with multiple users of one account

I started working with your package and it is really helpful! Especially your withings_auth solution is very convenient.

I would like to work with the data of all users on my account (i.e. set all the heart rates in relation to time, temperature, etc.). Is there a quick way for switching between users (of one Health Mate account)?
And if there is no other way: how do I log out (efficiently)?
Someone else been there and found a way?

Yours sincerly,
M.H.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.