misfit package

Misfit API Python Client Implementation. Facilitates connection to Misfit’s REST API and retrieving user data.

Submodules

misfit.auth module

class misfit.auth.MisfitAuth(client_id, client_secret, redirect_uri='http://127.0.0.1:8080/', state=None, scope=['public', 'birthday', 'email'], success_html=None, failure_html=None)[source]
authorize_url()[source]

Build the authorization url and save the state. Return the authorization url

fetch_token(code, state)[source]

Fetch the token, using the verification code. Also, make sure the state received in the response matches the one in the request. Returns the access_token.

browser_authorize()[source]

Open a browser to the authorization url and spool up a CherryPy server to accept the response

index(state, code=None, error=None)[source]

Receive a Misfit response containing a verification code. Use the code to fetch the access_token.

misfit.misfit module

class misfit.misfit.Misfit(client_id, client_secret, access_token, user_id=None)[source]
profile(object_id=None)[source]
device(object_id=None)[source]
goal(start_date=None, end_date=None, object_id=None)[source]
summary(start_date, end_date, detail=False)[source]
session(start_date=None, end_date=None, object_id=None)[source]
sleep(start_date=None, end_date=None, object_id=None)[source]
class misfit.misfit.UnicodeMixin[source]

Bases: object

class misfit.misfit.MisfitObject(data)[source]

Bases: misfit.misfit.UnicodeMixin

set_value(name, value)[source]
class misfit.misfit.MisfitProfile(data)[source]

Bases: misfit.misfit.MisfitObject

class misfit.misfit.MisfitDevice(data)[source]

Bases: misfit.misfit.MisfitObject

class misfit.misfit.MisfitGoal(data)[source]

Bases: misfit.misfit.MisfitObject

percent_complete()[source]

Using the number of points received, and comparing to the target points, return the percent complete (from 0-100). Returns None if the target is 0.

class misfit.misfit.MisfitSummary(data)[source]

Bases: misfit.misfit.MisfitObject

class misfit.misfit.MisfitSession(data)[source]

Bases: misfit.misfit.MisfitObject

class misfit.misfit.MisfitSleepDetail(data)[source]

Bases: misfit.misfit.MisfitObject

class misfit.misfit.MisfitSleep(data)[source]

Bases: misfit.misfit.MisfitObject

misfit.cli module


Usage:
  misfit authorize --client_id=<client_id> --client_secret=<client_secret> [--config=<config_file>]
  misfit profile [--user_id=<user_id>] [--object_id=<object_id>] [--config=<config_file>]
  misfit device [--user_id=<user_id>] [--object_id=<object_id>] [--config=<config_file>]
  misfit goal (--start_date=<start_date> --end_date=<end_date>|--object_id=<object_id>) [--user_id=<user_id>] [--config=<config_file>]
  misfit summary --start_date=<start_date> --end_date=<end_date> [--detail] [--user_id=<user_id>] [--config=<config_file>]
  misfit session (--start_date=<start_date> --end_date=<end_date>|--object_id=<object_id>) [--user_id=<user_id>] [--config=<config_file>]
  misfit sleep (--start_date=<start_date> --end_date=<end_date>|--object_id=<object_id>) [--user_id=<user_id>] [--config=<config_file>]
  misfit --version
  misfit --help

Options:
  -h --help                        Show this screen.
  --version                        Show version.
  --client_id=<client_id>          App key of your Misfit app.
  --client_secret=<client_secret>  App secret of your Misfit app.
  --config=<config_file>           Use the config file specified [default: ./misfit.cfg]
  --user_id=<user_id>              Misfit User ID.
  --object_id=<object_id>          ID of a single Misfit object.
  --start_date=<start_date         Date at the start of a range: Eg. 2014-11-20.
  --end_date=<end_date>            Date at the end of a range: Eg. 2014-11-30.
  --detail                         If specified, print summary detail for each day.

class misfit.cli.MisfitCli(arguments)[source]
read_config()[source]

Read credentials from the config file

write_config(access_token)[source]

Write credentials to the config file

get_resource(arguments)[source]

Gets the resource requested in the arguments

authorize()[source]

Authorize a user using the browser and a CherryPy server, and write the resulting credentials to a config file.

misfit.notification module

misfit.notification.string_to_sign(data)[source]

Build a signed SNS string from a dict

class misfit.notification.MisfitMessage(data)[source]

Bases: misfit.misfit.MisfitObject

DELETED, CREATED and UPDATED are the three known actions you will find in the action property

DELETED = 'deleted'
CREATED = 'created'
UPDATED = 'updated'
class misfit.notification.MisfitNotification(data)[source]

Bases: misfit.misfit.MisfitObject

verify_signature()[source]

Verify the signature of the SNS message.

raises cryptography.exceptions.InvalidSignature

misfit.exceptions module

exception misfit.exceptions.MisfitException[source]

Bases: exceptions.Exception

exception misfit.exceptions.MisfitHttpException(code, message, response=None)[source]

Bases: misfit.exceptions.MisfitException

Base class for all HTTP exceptions raised by the Misfit API. All exceptions will have three attributes.

  • code: The status code of the HTTP response, defaults to 500
  • message: The messages returned from the Misfit API
  • response: If we have one, this attribute will be the response object, of type requests.models.Response. It’s useful to have access to this because each response contains useful headers. For example, if the library throws an exception of type MisfitRateLimitError you can retrieve a time stamp for when the rate limit resets with the following code: exc.response.headers['x-ratelimit-reset']
static build_exception(exc)[source]
exception misfit.exceptions.MisfitNotFoundError(code, message, response=None)[source]

Bases: misfit.exceptions.MisfitHttpException

exception misfit.exceptions.MisfitBadRequest(code, message, response=None)[source]

Bases: misfit.exceptions.MisfitHttpException

exception misfit.exceptions.MisfitBadGateway(code, message, response=None)[source]

Bases: misfit.exceptions.MisfitHttpException

exception misfit.exceptions.MisfitUnauthorized(code, message, response=None)[source]

Bases: misfit.exceptions.MisfitHttpException

exception misfit.exceptions.MisfitForbidden(code, message, response=None)[source]

Bases: misfit.exceptions.MisfitHttpException

exception misfit.exceptions.MisfitRateLimitError(code, message, response=None)[source]

Bases: misfit.exceptions.MisfitHttpException

exception misfit.exceptions.MisfitUnknownError(code, message, response=None)[source]

Bases: misfit.exceptions.MisfitHttpException