Search code examples
rapihttrfitbit

What function in R package httr performs request and imports activities from Fitbit API?


I have used the httr package in R to obtain access to the Fitbit API, but I'm uncertain on which function I should use to extract activities from the API.

Any help would be much appreciated. Please provide example code with the function.


I believe I have found one possible answer.

Using the setup inputs from this stackoverflow answer/question: httr fitbit API question.

Once I gained authorization I then used the httr function GET.

GET(url= paste0("http://api.fitbit.com/1/user/-/activities/date/2013-06-07.json"), config=sig)

In the config argument, the sig variable was derived from the answer/question linked above.


Solution

  • Try this:

    activities <- GET(url = "http://api.fitbit.com/1/user/-/activities/date/2013-06-07.json",
                      config=sig)
    content(activities)
    

    That will give you the results in a list from which you can more easily extract what you are after.