Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to access the activities of multiple users in one call from client ?

ANSWERED

I am using Fitbit4J API in my J2EE based web application. I have implemented fitbit's OAuth api and stored the user's token and verifier in database. Which I use later to fetch the new data from fitbit server i.e. number of steps walked. Since in production environment I may have hundreds of users which authorized my app using OAUTH, How can I refresh their data periodically automatically without user intervention ?

 

I have used getActivities(LocalUserDetail localUser, FitbitUser fitbitUser, LocalDate date)
 method of FitbitApiClientAgent for getting the latest data of single user and it is working. Is their any method which takes a list of users and than retrieves the latest data from there account ? That will save hundreds of network calls.

 

If you any other alternate solution please share,

Best Answer
1 BEST ANSWER

Accepted Solutions

@amitKumar wrote:

Since in production environment I may have hundreds of users which authorized my app using OAUTH, How can I refresh their data periodically automatically without user intervention ?


After the user has authorized your application, store the user's access token and secret. Your application can then access the user's data whenever you want without any additional interaction.

 


amitKumar wrote:

I have used getActivities(LocalUserDetail localUser, FitbitUser fitbitUser, LocalDate date)
 method of FitbitApiClientAgent for getting the latest data of single user and it is working. Is their any method which takes a list of users and than retrieves the latest data from there account ? That will save hundreds of network calls.


No, your application will need to make 1 network request for each user resource that you want to retrieve. If your application properly uses HTTP keep-alive, the overhead is minimal.

View best answer in original post

Best Answer
0 Votes
5 REPLIES 5

@amitKumar wrote:

Since in production environment I may have hundreds of users which authorized my app using OAUTH, How can I refresh their data periodically automatically without user intervention ?


After the user has authorized your application, store the user's access token and secret. Your application can then access the user's data whenever you want without any additional interaction.

 


amitKumar wrote:

I have used getActivities(LocalUserDetail localUser, FitbitUser fitbitUser, LocalDate date)
 method of FitbitApiClientAgent for getting the latest data of single user and it is working. Is their any method which takes a list of users and than retrieves the latest data from there account ? That will save hundreds of network calls.


No, your application will need to make 1 network request for each user resource that you want to retrieve. If your application properly uses HTTP keep-alive, the overhead is minimal.

Best Answer
0 Votes

Sir;

You are saying the overhead is minimal, but imagine my app has people from say 500 companies, each with say 500 users. Next say each month I pull all their data to generate a report for their insurance carriers. Lets say I pull their number of steps, minutes where their heart rates are above a set threshold, number of stairs climbed, total activity time, average sleep length, weight before and after. If I were to make a discrete call for each of these 2500 people for each metric, seven, that is 17500 calls. Even if the transaction overhead were minimal, it adds up really fast at this rate.

Could not the API be extended to allow me to send in a set of user credentials, and a set of data to retrieve with a start/end datetime for just 1 pull?

Best Answer

Hi

 

I suppose that you haven't any method for having a bunch of activities filtered by location and date but not by user. What I want is for example, the list of running activities in a city in May, without users information (for keeping save the privacity).

 

Is it possible to have this by your API? If not, Would be possible to buy a report with this information?

 

Thank you so much.

Best Answer
0 Votes

@PhillipGoin wrote:
Could not the API be extended to allow me to send in a set of user credentials, and a set of data to retrieve with a start/end datetime for just 1 pull?

Effectively, you can do this with the time series endpoints for the type of data that you're desiring.

 

Many requests for smaller amounts of data are more efficient in practice. This is an intentional API design decision. If you want to create a report, that logic must live in your application, not the API. There is practically no overhead in making many calls if you use HTTP keep-alive and connection pooling. The rate limit is per user per hour, so there is also no rate limit problem.

Best Answer
0 Votes

SergioAguado wrote:

I suppose that you haven't any method for having a bunch of activities filtered by location and date but not by user. What I want is for example, the list of running activities in a city in May, without users information (for keeping save the privacity).


Data is owned by an individual and third-party applications access data on behalf of that person. If you want to do aggregations, you'll need to request each individual's data.


@SergioAguado wrote:
Is it possible to have this by your API? If not, Would be possible to buy a report with this information?

Fitbit doesn't sell user data or do custom API integrations. You might be able to use a product like Fitabase to generate the type of report you're describing.

Best Answer
0 Votes