fitbitr

An R package for interacting with your Fitbit data

https://github.com/mrkaye97/fitbitr

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.5%) to scientific vocabulary

Keywords

fitbit r rstats
Last synced: 6 months ago · JSON representation

Repository

An R package for interacting with your Fitbit data

Basic Info
Statistics
  • Stars: 15
  • Watchers: 2
  • Forks: 7
  • Open Issues: 0
  • Releases: 2
Topics
fitbit r rstats
Created almost 5 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog Contributing License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# fitbitr - Explore your Fitbit data in R


[![R-CMD-check](https://github.com/mrkaye97/fitbitr/workflows/R-CMD-check/badge.svg)](https://github.com/mrkaye97/fitbitr/actions)
[![CRAN Version](http://www.r-pkg.org/badges/version/fitbitr)](https://CRAN.R-project.org/package=fitbitr) ![](http://cranlogs.r-pkg.org/badges/grand-total/fitbitr)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)



`fitbitr` makes it easy to interface with Fitbit data in R.

Installation
------------

You can install the CRAN version of `fitbitr` with:

``` r
install.packages("fitbitr")
```

Or you can install the latest development version from Github:

``` r
# install.packages("devtools")
devtools::install_github("mrkaye97/fitbitr")
```


Setup
------------

There are a few steps you'll need to do before you can start pulling your Fitbit data:

1. Make an app [here](https://dev.fitbit.com/apps/new).
2. Fill in the fields as you like (see image below for guidance). 

    
    ```{r, echo = FALSE}
    knitr::include_graphics("https://raw.githubusercontent.com/mrkaye97/fitbitr/master/inst/app_setup.png")
    ```


3. You'll be redirected to a page with your credentials. **Make sure you keep the Client ID, Client Secret, and Redirect URL. You'll need them to finish the setup process**. You can always refer back to [the apps page](https://dev.fitbit.com/apps) to find them again.

4. Generate a token:

    ```r
    library(fitbitr)

    .fitbitr_token <- generate_fitbitr_token(
      oauth_app_name = ,
      client_id = ,
      client_secret = 
      callback = 
    )
    ```

    * If you want to edit the scopes that are enabled, you can do so with the `scopes = c('scopes', 'you', 'want', 'enabled')` argument. You can find information on the available scope options [here](https://dev.fitbit.com/build/reference/web-api/oauth2/#scope).
    * If you want to cache your token, you can do so by specifying either `cache = TRUE` or `cache = `. See the docs on `httr::oauth2.0_token()` for details.

5. And that's it! You now have your Fitbit API credentials set up. `fitbitr` tracks them behind the scenes for you, so all that you need to do at the start of each R session is `generate_fitbitr_token()`. On a session restart, `generate_fitbitr_token()` will try to laod a token from your `.httr-oauth` if it exists.

Using `fitbitr`
------------
Once you have a token, using `fitbitr` is very straightforward:

    ```r
    > get_steps("2020-05-21", "2020-05-28")
    # A tibble: 8 × 2
      date       steps
           
    1 2020-05-21  3734
    2 2020-05-22  5107
    3 2020-05-23  5640
    4 2020-05-24  6595
    5 2020-05-25  8466
    6 2020-05-26  5833
    7 2020-05-27  8616
    8 2020-05-28  3161
    ```

`fitbitr` tries to return a useful, tidy object back to you from the API.

Known Issues / Futute Work
------------

Given the structure of the Fitbit API, it doesn't appear to be currently possible to use `fitbitr` _outside_ of an interactive session. And furthermore, it doesn't help that Fitbit refresh tokens only last 8 hours, at which point you'd need another interactive session to generate a new one.

For these reasons, it is not advised to try to use `fitbitr` non-interactively, such as in a Shiny app server, a CI/CD process, a background job, etc.

Owner

  • Name: Matt Kaye
  • Login: mrkaye97
  • Kind: user
  • Location: Cambridge, MA
  • Company: @klaviyo

GitHub Events

Total
  • Push event: 2
  • Fork event: 1
Last Year
  • Push event: 2
  • Fork event: 1

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 193
  • Total Committers: 1
  • Avg Commits per committer: 193.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 64
  • Committers: 1
  • Avg Commits per committer: 64.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
mrkaye97 m****7@g****m 193

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 5
  • Total pull requests: 6
  • Average time to close issues: about 2 months
  • Average time to close pull requests: 16 days
  • Total issue authors: 5
  • Total pull request authors: 3
  • Average comments per issue: 1.6
  • Average comments per pull request: 0.83
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • insperatum (1)
  • cstephens32 (1)
  • tsahota (1)
  • andremi (1)
  • durraniu (1)
Pull Request Authors
  • mrkaye97 (4)
  • naltmann (1)
  • cstephens32 (1)
Top Labels
Issue Labels
wontfix (3)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 275 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
cran.r-project.org: fitbitr

Interface with the 'Fitbit' API

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 275 Last month
Rankings
Forks count: 14.9%
Stargazers count: 15.6%
Average: 29.3%
Dependent packages count: 29.8%
Dependent repos count: 35.5%
Downloads: 50.6%
Maintainers (1)
Last synced: 7 months ago

Dependencies

DESCRIPTION cran
  • dplyr * imports
  • httr * imports
  • janitor * imports
  • jsonlite * imports
  • lubridate * imports
  • magrittr * imports
  • purrr * imports
  • rlang * imports
  • tibble >= 2.0.0 imports
  • tidyr * imports
  • checkmate >= 2.0.0 suggests
  • covr * suggests
  • spelling * suggests
  • testthat >= 3.0.0 suggests
.github/workflows/R-CMD-check.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/pkgdown.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite