HealthKit

Has anyone had a look at Apple’s HealthKit API yet?

  • I’m curious if the set of data types is fixed or extensible?
  • Couldn’t find any mention of a Web API :frowning:
  • Timestamps appear to be stored as NSDates, which have no timezone offsets :frowning:

We poked around a bit the day of the announcement. Randy finally found some sample code using the HealthKit API in the iOS 8 section of the Apple developer site.

I’m not familiar enough with iOS well to have noticed them using NSDates without timezone offsets. If that turns out to be the case, it’s a really really bad sign for getting anything useful out of this. :frowning:

We couldn’t tell much from the sample (it was pretty sparse), but we saw no evidence of extensible data types. My memory is that there were statically defined types for things like weight and BP. It may be that extensibility exists and just wasn’t in the sample, but we couldn’t find anything that smelled like support for that.

It also smelled to me like HealthKit is an iOS-only SDK. I suspect we’re not going to see them doing anything to support server push (except as backup data in the roach motel that is iCloud), account binding, or APIs. I could be wrong. It would be nice if I am wrong. However, if we look at the example of iCloud it seems really unlikely that Apple would provide a web API, or the other affordances we’d need to treat the HealthKit stuff as a connectable data source.

I think it’s likely that to get anything out of this one of us with a decently extensible server back end system would have to make an iOS app using the HealthKit API.

Sadly, I don’t think my iOS development foo is up to adding it to either the fluxtream-capture-ios code base or our newer efforts where we’re leveling up on using Trigger.io.

The Sense.os guys, one of whom was pretty engaged at the the QSEU14 API Breakout session, seem like a potential candidate. From what I’ve seen, their back-end system could probably handle it if they chose to devote the resources to making that happen.

Anne

The sample code btw can be found at https://developer.apple.com/library/prerelease/ios/samplecode/Fit/Introduction/Intro.html.

From what I can see (having watched the WWDC session and poked around on the forums), Anne is correct:

  1. There is a fixed set of data types.
  2. There is no web api
  3. Timestamps indeed do not have timezone offsets

#3 looks like a near-fatal oversight. I have enquired as to whether there is some ameliorating mechanism (such as timezone or place channels), but I can’t see evidence of such. I have actually filed a bug about this, and will be curious to see what the feedback is.

#2 is because it’s not relevant to the purpose. Healthkit is an on-device health-data store. The idea is that apps can share data with one another via the Healthkit database, and the user is given fine grained control of what apps can access what data.

#1 is because HealthKit provides a permissions system that allows users to control which apps have what data, and they can’t ask good questions about arbitrary types.

If it were a well designed implementation (see #1 and #3), this would seem like a good thing. User control of permissions is good, and a unified api to a wide variety of apps and data sources is good too.

As Anne speculates, there is no special relationship between Healthkit and iCloud other than than that the device filesystem may be backed up there. Apple is not maintaining a cloud database for health data.

According to people who spoke with Apple engineers at WWDC, there is nothing to stop an app from copying data out of the HealthKit store and transmitting is to any remote store. From their perspective, the user will have had to actively authorize the app to access the data and so is taking responsibility for what happens next.

If it is good enough, and is adopted, it looks to me as though HealthKit would do a great deal to open access to health data on iOS.

Think of HealthKit as a typical 1.0 release that doesn’t try to do everything, but rather helps Apple do a few things well, mostly just the fitness scenarios that are part of Apple Watch. The current type identifiers are hard-coded for: body measurements, fitness (steps, flights climbed, etc.), vital signs (blood pressure, temp, etc.), instrumentation results (blood glucose, alcohol content, etc.), nutrition (fat, cholesterol, vitamins, etc.), a sleep placeholder (just start/end), some misc identifiers, and that’s it. There are also WorkoutActivity types for dozens of specific exercise sports like lacrosse, water polo, even fishing and yoga. There is a built-in identifier called “NikeFuel”, to give you an idea how app-specific the 1.0 API is.

The inability to create custom types is probably by design in 1.0: it greatly simplifies the Health app setup process for users.

Lack of timezone support is just not a priority for the first release because Apple probably figures any app that cares (e.g sleep analysis) will do its own analysis taking timezones into account, and then present cumulative summaries to the other apps (e.g. number of minutes asleep).

I doubt they will release a cloud component anytime soon. Right now it doesn’t even sync across devices because for privacy reasons it never goes off the device except in encrypted backups. I’m not saying they won’t add support for timezone or custom types, but they’re probably not in a hurry.

Custom workout types (and data types) can be added later, but changing the timestamps would break a lot of things, plus you’d then have to deal with a mix of timestamps with and without timezones. Cumulative summaries are even more problematic than point-in-time measurements without timezones, because their startDate/endDate is at midnight.

Interesting announcement that Jawbone will release a new app that opens it up to the Apple watch and other devices. I really hope that doesn’t mean they will stop supporting Bodymedia’s activity monitor software. From what I have seen, the Up app isn’t competitive as far as letting you export food log data. I am watching all news associated with HealthKit with great interest!

I’m looking for documentation for HealthKit’s XML export format–any pointers?

Still couldn’t find any documentation; is anyone willing to share a sample file exported from Apple’s Health app?

I haven’t seen an export function within the health app. Where did you hear about it ?

I expect there are apps out there or coming soon that allow export but I haven’t heard of a standard format. I’ll probably be adding export to my own app in the not too distant future. But in the meantime if you know of any free ones I’d be happy to do trial exports for you. QS access pulls statistics aggregated into hourly or daily buckets but I’m guessing your looking for something a bit more raw.

Apple doesn’t appear to mind folks pulling data out of healthkit and even sending it off to other cloud services, they just don’t want devs to put it in iCloud funny enough.

Ernesto was kind enough to send me some data exported from the Health app, see my write-up at http://blog.zenobase.com/post/100624681047.

Are there any food trackers that send food information along with the actual time it was logged? It seems like both MyFitnessPal and Fatsecret only send a generic 00:00 event (or in Fatsecret’s case, 0900, 1300, and 1800).

Jawbone’s app lets you log food with a timestamp. But their food database isn’t great, and I don’t know if they are planning to integrate with Google Fit…

In my opinion, Apple Health is quite a disappointment. Steps data was at first recorded on a minute resolution, but now it is 5 or 10 minutes. I’ve heard reports that some users’ phones crash when they export large data sets, so I have no confidence that my data will always be accessible. The data types are limiting and short sighted. For example, what use is recording blood glucose without also providing for recording insulin? With these limitations, the best recommendation I have is to find/develop a cloud API service that backs up and provides access to the data, along with other data not included in Apple Health. Does anyone have ideas what this cloud API service could be?

Both Google Fit and Microsoft HealthVault are more flexible and extensible than HealthKit, and both services have a Web API, too.

Personally, I am partial towards the generic data model in Zenobase :slight_smile:

Thanks, the Zenobase analysis looks very cool. Is there an iOS app that continuously uploads apple health data to Google Fit or Microsoft HealthVault, (or Zenobase)?

If there is, I’d love to know, too…

I’m working on a similar app. What would your interest be? :slight_smile:

Awesome. I’d love to help beta test it. My application is a T1D Decision support tool, described a bit in this thread:
https://forum.quantifiedself.com/thread-hr-activity-monitor-api-recommendations-needed-for-diabetes-decision-support-tool

I’d also be interested to beta test. I’m surprised (or maybe not?) Apple doesn’t have a web api for it, but I can’t find one.