02-23-2015 14:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-23-2015 14:56
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi there,
I use the Fitbit.Net client for my C# app.
In the Fitbit documentation, there is a list of possible subscription types - from the documentation :
"Fitbit supports the following collection types: activities, foods, sleep, body"
But in the Fitbit.Net client lib, I can subscribe to the following :
"activities, body, foods, meals, sleep, user, weight"
What confuses me, is that the officielt documentation does not have ie. the "weight" subscription, but I can certainly subscribe to it via the Fitbit.Net client, and it starts pushing data to me each time the weigth is changed.
So - could anyone give me an officielt list of subscription types ?
Also, I think I read about a "all" subscription type, but that is not included in th Fitbit.Net client package.
Cheers,
Tony
Answered! Go to the Best Answer.

- Labels:
-
.NET
-
Subscriptions API
Accepted Solutions
02-25-2015 10:49 - edited 02-25-2015 10:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-25-2015 10:49 - edited 02-25-2015 10:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hi Everyone. So, everyone is mostly correct in everything said so far.
I had to look this up, but if you head on over to the source code where we set subscriptions in Fitbit.NET you should search for this method (as of 2/25/15 it's line 552) in the FitbitClient.cs class:
public ApiSubscription AddSubscription(APICollectionType apiCollectionType, string uniqueSubscriptionId, string subscriberId)
For weight, I specifically mention where we go it from in comments (phew, I certainly would have forgotten)
else if (apiCollectionType == APICollectionType.weight) //untested and the docs don't show it, but the Fitbit4J enum does have this { subscriptionAPIEndpoint = string.Format("/1/user/-/weight/apiSubscriptions/{0}-weight.xml", uniqueSubscriptionId); }
Looking back at the Fitbit4J library, I think I stuck pretty close to that implementation.
The "All" is the "User" type. It's set here:
else if (apiCollectionType == APICollectionType.user) { subscriptionAPIEndpoint = string.Format("/1/user/-/apiSubscriptions/{0}-user.xml", uniqueSubscriptionId); }
I don't remember why we did that and not the "all" the way it's listed (basically the exact same URI endpoint, minus the "-user.xml"). Maybe someone at Fitbit HQ can confirm the -user.xml equates to "all" ? I might have gotten this right out of the Fitbit4J implementation rather than the documentation.
ALL THAT SAID -- we're moving away from this library, will put it in non-maintenance mode, and release a V2 that is
- not dependent on RestSharp (even John Sheehan, who started the project no longer uses it),
- is Portable Class Library (PCL) compatible,
- and supports C# 5 async keywords (because really, why do threads need to wait for HTTP, surely you must have something better for them to be doing during that time).
- is JSON based as XML is being deprecated (the great JSON/XML war had not yet been won when I first wrote this library)
- OAuth 2.0 is coming, so we'll have a relevant timepoint for folks to make a big refactor to flip the switch
Take a look on my async-portable branch:
https://github.com/aarondcoleman/Fitbit.NET/tree/async-portable
or Adam's Master branch:
https://github.com/WestDiscGolf/Fitbit.NET

02-23-2015 15:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-23-2015 15:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Here is official api subscriptions notifications wiki:
https://wiki.fitbit.com/display/API/Fitbit+Subscriptions+API
you'll find all supported notifications type there.
Senior Software Developer at Fitbit

02-24-2015 01:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-24-2015 01:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I know, thats where I got the list of possible subscriptions.
But, I better direct my question to the developer of the Fitbit.net library.
Does any of those subscriptions "overlap" each other - i always gets 2 subscriptions, whenever there is happening anything ?

02-25-2015 08:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


02-25-2015 08:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
You're more then welcome to direct your question to the developer of Fitbit.NET library, although I don't think Fitbit API forum is right place for it.
Senior Software Developer at Fitbit

02-25-2015 09:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post



02-25-2015 09:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@aarondcoleman often hangs around these parts. His excellent library's GitHub project is at https://github.com/aarondcoleman/Fitbit.NET

02-25-2015 10:49 - edited 02-25-2015 10:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-25-2015 10:49 - edited 02-25-2015 10:52
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
Hi Everyone. So, everyone is mostly correct in everything said so far.
I had to look this up, but if you head on over to the source code where we set subscriptions in Fitbit.NET you should search for this method (as of 2/25/15 it's line 552) in the FitbitClient.cs class:
public ApiSubscription AddSubscription(APICollectionType apiCollectionType, string uniqueSubscriptionId, string subscriberId)
For weight, I specifically mention where we go it from in comments (phew, I certainly would have forgotten)
else if (apiCollectionType == APICollectionType.weight) //untested and the docs don't show it, but the Fitbit4J enum does have this { subscriptionAPIEndpoint = string.Format("/1/user/-/weight/apiSubscriptions/{0}-weight.xml", uniqueSubscriptionId); }
Looking back at the Fitbit4J library, I think I stuck pretty close to that implementation.
The "All" is the "User" type. It's set here:
else if (apiCollectionType == APICollectionType.user) { subscriptionAPIEndpoint = string.Format("/1/user/-/apiSubscriptions/{0}-user.xml", uniqueSubscriptionId); }
I don't remember why we did that and not the "all" the way it's listed (basically the exact same URI endpoint, minus the "-user.xml"). Maybe someone at Fitbit HQ can confirm the -user.xml equates to "all" ? I might have gotten this right out of the Fitbit4J implementation rather than the documentation.
ALL THAT SAID -- we're moving away from this library, will put it in non-maintenance mode, and release a V2 that is
- not dependent on RestSharp (even John Sheehan, who started the project no longer uses it),
- is Portable Class Library (PCL) compatible,
- and supports C# 5 async keywords (because really, why do threads need to wait for HTTP, surely you must have something better for them to be doing during that time).
- is JSON based as XML is being deprecated (the great JSON/XML war had not yet been won when I first wrote this library)
- OAuth 2.0 is coming, so we'll have a relevant timepoint for folks to make a big refactor to flip the switch
Take a look on my async-portable branch:
https://github.com/aarondcoleman/Fitbit.NET/tree/async-portable
or Adam's Master branch:
https://github.com/WestDiscGolf/Fitbit.NET

02-26-2015 08:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

02-26-2015 08:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
aron, thanks for clearing that up.
My confusion came from subscribing to "activities" and "user" for the same user, which resulted in double notifications each time.
Now I only subscribe to "user" which is like the "all" I was asking about.
Also thanks for the other links, I will definately check it out.
And hey, thanks for your work on Fitbit.NET - it kickstarted my project 🙂
