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

Adding elliptical activity with a distance via web API

hi guys,

I was trying to add elliptical activity with a distance parameter. With no luck actually.

POST is

https://api.fitbit.com/1/user/-/activities.json?activityId=20047&startTime=02:07:05&date=2018-11-09&durationMillis=600000&distance=1.2&distanceUnit=Kilometer

And it returns this

{
    "activityLog": {
        "activityId": 20047,
        "activityParentId": 20047,
        "activityParentName": "Elliptical",
        "calories": 86,
        "description": "",
        "distance": 0,
        "duration": 600000,
        "hasStartTime": true,
        "isFavorite": false,
        "lastModified": "2018-11-09T08:39:19.035Z",
        "logId": 17993756228,
        "name": "Elliptical",
        "startDate": "2018-11-09",
        "startTime": "02:07",
        "steps": 0
    }
}

 I wonder why as apparently distance is specified as confirmed by activity details here:

            "lastModified": "2018-11-09T08:39:19.000Z",
            "logId": 17993756228,
            "logType": "manual",
            "manualValuesSpecified": {
                "calories": false,
                "distance": true,
                "steps": false

Could you tell me what is wrong? I am changing activity ID to something like 50203, however still nothing.

Best Answer
0 Votes
11 REPLIES 11

Hi @Georgiy,

 

I don't think it's possible to add distance to the public elliptical activity provided by Fitbit.  We state in the documentation "Note: The steps field is only included for activities that have steps ("Walking" or "Running") and distance is only included when it is relevant."

 

As an alternative, you can create a custom activity and call it Elliptical.  Custom activities allow you to specify distance.  This activity will be private to your account, but you can reuse the activityId and enter new distance values.

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @GordonFitbit,

Thank you for the reply. I must have misinterpreted the documentation then. 

I assumed that the distance is relevant in this case since it is "true" in the reply.

My goal was to add elliptical activity with specified distance to compensate wrong elliptical step count (so the daily step goal is achieved). 

As far as I understood, the only way to do so in this case would be to add "walk" activity with specific distance and say 1 calorie spent. Distance added is then in turn recalculated into number of steps. I hoped that it would be the case with elliptical as well (added distance => number of steps)...

Is it correct?

And there is no way to edit existing activity as far as I understood API documents, is not it?

Best Answer
0 Votes

Hi @Georgiy...Let me do a little more research into this question and I'll get back to you.

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Thank you @GordonFitbit!

I do appreciate it.

Best Answer
0 Votes

Hi @Georgiy

 

It appears the section

 

      "manualValuesSpecified": {
        "calories": false,
        "distance": true,
        "steps": false
      },

 

is suppose to represent whether a manual parameter value was specified for calories, distance and steps when executing the Log Activity endpoint.  For distances, this seems to always return true which I believe is the incorrect behavior.  I'm going to submit a ticket to engineering to fix this behavior.

 

Gordon  

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer

Thank you @GordonFitbit!

Could you please clarify documentation a little bit more?

I still wonder whether distance is relevant for elliptical or not?

When I try to add it, distance actually appears in elliptical activity. Not only as "true", but actual number.

And distance is present if some number of steps is counted during exercise.

Seems to be relevant for me.

Best Answer
0 Votes

Hi @Georgiy,

 

I thought you said when adding distance for elliptical, you get zero.  If you're able to add distance for an elliptical activity and it appears when querying the activities' endpoints, please let me know what is the activityId and the endpoint you executed to get a distance value.  Did you create a custom activity for elliptical?  

 

If you've physically been on an elliptical machine, are you seeing a distance value through the Web APIs?  If so, was the activity auto-detected or manually started through the exercise application on the tracker?

 

Gordon

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

Hi @GordonFitbit

 

Apologies for the delay. I could not reproduce the case when distance could be added. I was using activity ID 20047, as it appeared in the log of actual activity.

So now the distance is always 0, when added via API.

It is always present in the log though as manually specified, regardless if any value has been passed:

if I use POST with no distance at all:

https://api.fitbit.com/1/user/-/activities.json?activityId=20047&startTime=16:35:05&date=2018-11-25&durationMillis=600000 

reply seems to be correct:

{
    "activityLog": {
        "activityId": 20047,
        "activityParentId": 20047,
        "activityParentName": "Elliptical",
        "calories": 86,
        "description": "",
        "distance": 0,
        "duration": 600000,
        "hasStartTime": true,
        "isFavorite": false,
        "lastModified": "2018-11-25T16:35:51.703Z",
        "logId": 18281919048,
        "name": "Elliptical",
        "startDate": "2018-11-25",
        "startTime": "16:35",
        "steps": 0
    }
}

but it is still in the log:

            "lastModified": "2018-11-25T16:35:51.000Z",
            "logId": 18281919048,
            "logType": "manual",
            "manualValuesSpecified": {
                "calories": false,
                "distance": true,
                "steps": false

 

  • I can see distance through the Web API. The activity has been started manually through the exercise application on the tracker.
            "activityName": "Elliptical",
            "activityTypeId": 20047,
            "averageHeartRate": 91,
            "calories": 4,
            "caloriesLink": "https://api.fitbit.com/1/user/-/activities/calories/date/2018-11-25/2018-11-25/1min/time/16:30/16:31.json",
            "distance": 0.03828,
            "distanceUnit": "Kilometer",
            "duration": 58000,

            "lastModified": "2018-11-25T15:34:13.000Z",
            "logId": 18300115823,
            "logType": "tracker",
            "manualValuesSpecified": {
                "calories": false,
                "distance": false,
                "steps": false
            },
            "originalDuration": 58000,
            "originalStartTime": "2018-11-25T16:30:55.000+01:00",
            "source": {
                "id": "88524718",
                "name": "Charge 2",
                "type": "tracker",
                "url": "https://www.fitbit.com/"
Best Answer
0 Votes

Hi @GordonFitbit

Could you please clarify if:

  • when added via Web API, distance value is not relevant to default Elliptical activity (ID 20047). despite distance is calculated during manually started default Elliptical activity (ID 20047) on the tracker itself. Ergo - distance cannot be added via Web API to default Elliptical activity (ID 20047). Is that correct?
  • there is no way to edit existing default Elliptical activity (ID 20047) via Web API.

Please note, I do believe that you guys are doing really good work with API and data access and all (compared to e.g. Garmin with none above for end users). I just want to clarify what I can and cannot do. 

Best Answer
0 Votes

Hi @Georgiy,

 

When using the tracker, we're going to use your body movement to try to estimate steps which yields distance.  This may be difficult for us because using an elliptical machine is not the same as walking.  

 

When manually entering elliptical data through the dashboard or Web APIs, it doesn't seem possible to include distance unless you describe the elliptical activity as your own custom activity.  If you would like the ability to manually record distance with the elliptical activity, I would suggest requesting this functionality here: https://community.fitbit.com/t5/Feature-Suggestions/idb-p/features

 

 

Gordon Crenshaw
Senior Technical Solutions Consultant
Fitbit Partner Engineering & Web API Support | Google
Best Answer
0 Votes

hi @GordonFitbit

 

Thank you for the reply. I appreciate the effort and your time.

I think that it is clear for me what I've misunderstood earlier. 

Default Elliptical activity logged by tracker calculates the distance as product of stride length and steps detected.

So I thought that reverse would happen if I add distance via Web API - I will have number of steps then.

And it does not work like this unfortunately.

Thanks again.

Best Answer
0 Votes