Close

FitBit API Part 1: Getting the data

A project log for Sci-fi grade Home Automation

A system that ties some home automation with various APIs and hardware hacks.

conradcnconradcn 03/15/2014 at 03:450 Comments

FitBit wouldn't let me use their API officially without a significant amount more effort than I was willing to put into this project (They wanted a website, among other things. Psh.), so I loaded up my trusty Fiddler and opened a session to their site. The dashboard program gets data with two basic calls:

A post to http://www.fitbit.com/login with my account credentials

A post to https://www.fitbit.com/ajaxapi with any API calls I want to make (using the cookies from the first session)

The ajax API just takes in JSON strings as input and returns the requested JSON as output. With a little experimentation, I found the format to be the following:

The request I was interested in (sleep data) is a URL-encoded JSON string with the following structure

request={"template":"/mgmt/ajaxTemplate.jsp","serviceCalls":[{"name":"activityTileData","args":{"dateFrom":"2014-03-13","dateTo":"2014-03-13"},"method":"getSleepTileData"}]}

Part 2 will cover converting the data to a usable dashboard.

Discussions