Thunkable integrating with google fit

I would like to request the thunkable staff team to add a feature that data can be fetched from googlefit

1 Like

Thanks for the request @lolxdyt6950as - as wearables continue to grow in popularity this is something we’ll have to consider going forward.

In the meantime, do you know if Google Fit has an API?

If so, then you can pull this data into your Thunkable app today with our Web API component.

Hope that helps!

1 Like

Yes! Google Fit has APIs

Can you help me set these up?
Here is the API info: Android APIs  |  Google Fit  |  Google Developers

If it works, then maybe a pedometer will be possible in thunkable, i think?

now what should i do here?

1 Like

If you’re new to using APIs the check out the Thunkable Academy

There are several tutorials there to help you go from novice to advanced user in just a few steps!

Let us know how it goes!

I can not find a link to connect with the web api
Im stuck here. Help

dang ok i found yet another way to integrate google fit

just have to decompile the app and put it in android studio
then set it up as google intended lol

edit: no i have problems still
new problem forum link: Decompiling a app

1 Like

Using the web api would be much simpler than decompiling the app. Are you a traditional developer and using noCode as a bridge gapper?

What issues are you experiencing using the webAPI. Looks like you need to integrate OAuth from google. are you familiiar with doing that?

1 Like

Google Fit has REST API end pints which you can use. The API is as follows:

GET https://www.googleapis.com/fitness/v1/users/{userId}/dataSources/{dataSourceId}/datasets/{datasetId}

Following is the explanation of the parameters:

  • userId should be me
  • dataSourceId you will need another API to find it out if you do not have it stored.
  • datasetId is the start time and end time in the form of EPOCH using the format startTime-endTime.

To obtain the dataSourceId use the following API:

GET https://www.googleapis.com/fitness/v1/users/userId/dataSources

The user ID running the API should have authorization to the following (from Google Docs)


No, im not familier with web api…

2: no im not a traditional developer, i was just using thunkable cuz its easy and fast
3: i dont know how to use webapi
4: no im not

edit: muneer answered me and explained :slight_smile:

thanks dude. your explaination was good but i am not understanding {datasetId}

  • datasetId is the start time and end time in the form of EPOCH using the format startTime-endTime.
  • How do i fetch the user id
1 Like

You need an access token. You can do this in a variety of ways.

how will i get a access token?

It’s quite a bit of setup. Atm, you need a supporting website which can be hosted on your Firebase instance.

If you’re interested in learning, I offer paid coaching sessions to bring you up to speed quickly! :slight_smile:

i cant afford paid courses :frowning:

maybe now i have to figure it out

An Epoch is a time represented in the number of milliseconds since 1970

The time I stared this response the Epoch was
1662225491628

Google require that in nanoseconds so add 000 to it.

2 Likes

and how to get the datasourceId?

1 Like

See my message, you need to use the other API that I explained in my answer.

now i have use these api to check:

  • userID: me
  • datasourceId: unable to fetch
  • datasetID: 000

this is what returned:
{
“error”: {
“code”: 401,
“message”: “Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.”,
“errors”: [
{
“message”: “Login Required.”,
“domain”: “global”,
“reason”: “required”,
“location”: “Authorization”,
“locationType”: “header”
}
],
“status”: “UNAUTHENTICATED”,
“details”: [
{
“@type”: “type.googleapis.com/google.rpc.ErrorInfo”,
“reason”: “CREDENTIALS_MISSING”,
“domain”: “googleapis.com”,
“metadata”: {
“method”: “google.android.fitness.v1.FitnessService.ListDataSources”,
“service”: “fitness.googleapis.com”
}
}
]
}
}

1 Like

You need to select a dataSourceId.

You can use Google Playground to define the scope which is required and to get OAuth credentials.

1 Like

i got the oauth credentials but now what will i but in data source?

2 Likes