Module Expr Str ImportFrom alias alias ImportFrom alias alias ImportFrom alias Import alias Import alias Import alias Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr ListLoad Str Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str Str FunctionDef arguments args defaults body Return Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Str Str Call AttributeLoad NameLoad attr Str Str Call AttributeLoad NameLoad attr Str Str Call AttributeLoad NameLoad attr Str Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad NameLoad decorator_list Expr Str FunctionDef arguments args NameParam defaults body If Call AttributeLoad NameLoad attr NameLoad body Return Call AttributeLoad NameLoad attr NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Expr Call NameLoad Str NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Assign NameStore BinOpMod Str NameLoad Assign NameStore Num For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad TupleLoad Call NameLoad Call AttributeLoad SubscriptLoad NameLoad Index Num attr SubscriptLoad NameLoad Index Num AugAssignAdd NameStore SubscriptLoad NameLoad Index Num Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad TupleLoad Call NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore Call NameLoad Expr Call NameLoad NameLoad Str NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Num Expr Call NameLoad NameLoad Str NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Num Expr Call NameLoad NameLoad Str NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Num Expr Call NameLoad NameLoad Str NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call NameLoad Num decorator_list If CompareEq NameLoad Str body Assign NameStore Call NameLoad NameLoad Expr Call NameLoad NameLoad BinOpSub Call AttributeLoad Call AttributeLoad NameLoad attr attr Call NameLoad keyword Num Expr Call AttributeLoad NameLoad attr
N/A N/A 
This is an example script to dump the fitbit data for the previous day into a sqlite database.
This can be set up in a cronjob to dump data daily.

Create a config file at ~/.fitbit.conf with the following:

[fitbit]
user_id: 12XXX
sid: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
uid: 123456
uis: XXX%3D
dump_dir: ~/Dropbox/fitbit
db_file: ~/data/nameofdbfile.sqlite

The database has a table for each of steps, calories, active_score, and sleep. There is also a table with extension _daily for each that contains accumulated data per day.

The timestamp in the table is a unix timestamp. Tables are set up so that the script can be run repeatedly for the same day. Newer data replaces older data for the same timestamp. This is so data can be caught up if the fitbit does not sync every day.
 time mktime sleep datetime datetime timedelta os path N/A ConfigParser N/A sqlite3 N/A fitbit N/A CONFIG N/A N/A ConfigParser ConfigParser N/A N/A N/A CONFIG read N/A fitbit.conf N/A N/A path expanduser ~/.fitbit.conf N/A DB_FILE N/A N/A path expanduser N/A N/A CONFIG get fitbit db_file client N/A N/A N/A N/A N/A N/A N/A fitbit Client N/A N/A CONFIG get fitbit user_id N/A N/A CONFIG get fitbit sid N/A N/A CONFIG get fitbit uid N/A N/A CONFIG get fitbit uis N/A create_table N/A N/A table db N/A N/A N/A N/A N/A db execute N/A create table %s (datetime integer PRIMARY KEY ON CONFLICT REPLACE, %s integer) N/A table table N/A N/A N/A db execute N/A create table %s_daily (date integer PRIMARY KEY ON CONFLICT REPLACE, %s integer) N/A table table N/A N/A  Connects to the DB, creates it if it doesn't exist. Returns the connection.
 connect_db N/A N/A filename N/A N/A N/A N/A N/A path isfile filename N/A N/A N/A N/A sqlite3 connect filename N/A N/A db N/A N/A sqlite3 connect filename N/A N/A create_table steps db N/A N/A create_table calories db N/A N/A create_table active_score db N/A N/A create_table sleep db N/A db N/A dump_to_db N/A N/A db data_type date data N/A N/A N/A insertString N/A insert into %s values (?, ?) data_type N/A sum 0 N/A row data N/A N/A N/A N/A db execute insertString N/A N/A mktime N/A N/A N/A row N/A 0 timetuple N/A row N/A 1 N/A sum N/A row N/A 1 N/A N/A N/A db execute N/A insert into %s_daily values (?, ?) data_type N/A N/A mktime N/A N/A date timetuple sum N/A N/A N/A db commit N/A dump_day N/A N/A db date N/A N/A N/A c N/A client N/A N/A dump_to_db db steps date N/A N/A c intraday_steps date N/A N/A sleep 1 N/A N/A dump_to_db db calories date N/A N/A c intraday_calories_burned date N/A N/A sleep 1 N/A N/A dump_to_db db active_score date N/A N/A c intraday_active_score date N/A N/A sleep 1 N/A N/A dump_to_db db sleep date N/A N/A c intraday_sleep date N/A N/A sleep 1 N/A N/A N/A __name__ __main__ N/A N/A db N/A connect_db DB_FILE N/A N/A dump_day db N/A N/A N/A N/A N/A datetime now date N/A timedelta days 1 N/A N/A N/A db close