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

StackOverflow https://stackoverflow.com/questions/17768235

  •  03-06-2022
  •  | 
  •  

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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top