Export Google Fit Daily Steps, Weight and Distance to a Google Sheet

Updated on Friday, April 28, 2023

Comments Page 4

Return to post.



Hi Rob, thanks for the quick reply.

I also noticed that I have different-yet-similar issues with my other google fit connections, which together with the time they emerged suggests they might be tied to the change to daylight saving time.

I will definitely try to set the trigger (which I do not remeber being here when I first got the script from you, by the way, thanks!)

Robert Ellison

Hi Ondra. I don't think it's the script. I just tested pulling 60 days and got reasonable dates. Could be something in your sheet - check the format for the column.

I'd also suggest setting up a trigger, see the instructions in the post. That way you don't need to remember to use the menu, it will just pull in the last day every day.


Hi Robert, me again:)

I adapted the script so that I have to possibility to pull more days at once (as sometimes I do not have the time to to it every day) - like this:

getMetricsForDays(0, 3, 'Metrics'),

I added more functions like this so that I can choose how many days I want to pull (you get the picture, I hope).

Up till yesterday, it was working with no problems, but since yesterday, when I pull more days than one, I get the dates in a strange format. The first day is displayed as before, but second and all subsequent dates get displayed as "day-1 23:00:00"; plus it now adds one more row, which has only date "today 23:00:00" with no other values...

Is there any issue in the script, or could it be a change in the fit API?


for people who are getting the "403. Truncated server response: { "error": { "code": 403, "message": "datasource not found or not readable" error- the issue for me was that I didn't have data for all of the data types the script looks for in my Google Fit account (hence it not finding it...). The way to solve it was to remove the bits about the data types I didn't need, and leave in the bits I do want to keep


Robert Ellison

Gustavo, I can't help much more as I don't have a lot else in my account. The trick is to look for the data source name and ID, and to check if you need any additional OAuth scopes.


Hello Robert,

Thank you very much for all the help you provided.

I'm really dumb and I can't implement more data to get.

I took a look at the API Explorer link, but I didn't understand anything.

Is there any way to get all the data and put it in the columns, something more generic?

Thank you again


Ahh, that's where:) I saw there were three values, but could not find where to change it in the script. Thanks again!

Robert Ellison

Hi Ondra, See https://developers.google.com/fit/datatypes/aggregate - it looks like weight has average, max and min. Try changing value[0] to value[2] when fetching the weight. The script is pulling data daily, if there isn't more than one measurement per day I'd imagine that all three would be the same.


Hi Robert,

this is super useful, thank you!

Could you please help me just replace the the average weight with the minimum value for weight?I cannot seem to find that anywhere..



Robert Ellison

Change the 1's in getMetricsForDays(1, 1, 'Metrics'); to 0's - that should pull today rather than yesterday. If this works change the script trigger to run more frequently.

Add Comment

All comments are moderated. Your email address is used to display a Gravatar and optionally for notification of new comments and to sign up for the newsletter.

I Thought He Came With You is Robert Ellison's blog.



Average Server Response Time in Azure Metrics