Overview

This is a complete python implementation of the FitBark API.

It uses OAuth2 for authentication.

Quickstart

Here is an example of authorizing with OAuth 2.0:

# You'll have to gather the tokens on your own, or use
# ./gather_keys_oauth2.py
authd_client = fitbark.FitBark('<consumer_key>', '<consumer_secret>',
                               access_token='<access_token>', refresh_token='<refresh_token>')
authd_client.sleep()

FitBark API

Some assumptions you should note. Anywhere it says date=None, it should accept either None or a date or datetime object (anything with proper strftime will do), or a string formatted as %Y-%m-%d.

class fitbark.FitBark(client_id, client_secret, access_token=None, refresh_token=None, expires_at=None, refresh_cb=None, redirect_uri=None, **kwargs)[source]

Before using this class, you must request access to the FitBark developer API here. Once approved, you will get the client id and secret needed to instantiate this class. Before authorizing a user, ensure you update the redirect URIs by following the “SETTING OAUTH 2.0 REDIRECT URI’S VIA API” section under their “Authentication” docs. See gather_keys_oauth2.py for a reference implementation of the authorization process. You should save access_token, refresh_token, and expires_at from the returned token for each user you authorize.

When instantiating this class for use with an already authorized user, pass in the access_token, refresh_token, and expires_at keyword arguments. We also strongly recommend passing in a refresh_cb keyword argument, which should be a function taking one argument: a token dict. When that argument is present, we will automatically refresh the access token when needed and call this function so that you can save the updated token data. If you don’t save the updated information, then you could end up with invalid access and refresh tokens, and the only way to recover from that is to reauthorize the user.

activity_series_get(slug, date_from=None, date_to=None, resolution='DAILY')[source]

Get historical series data between two specified date times. The maximum range is 42 days with daily resolution, and 7 days with hourly resolution.

Parameters:
  • slug (uuid) – uuid of the dog to look up
  • date_from (datetime, date, str) – the start of the date range to look up
  • date_to (datetime, date, str) – the end of the date range to look up
  • resolution (str) – DAILY or HOURLY breakdown
Returns:

list of records breaking activity down

Return type:

json

activity_totals_get(slug, date_from=None, date_to=None)[source]

Get historical activity data by totaling the historical series between two specified date times.

Parameters:
  • slug (uuid) – uuid of the dog to look up
  • date_from (datetime, date, str) – the start of the date range to look up
  • date_to (datetime, date, str) – the end of the date range to look up
Returns:

list of records breaking activity down

Return type:

json

daily_goal_get(slug)[source]

Get a dog’s current daily goal and future daily goals set by an authorized user (if any).

Parameters:slug (uuid) – uuid of the dog to look up
Returns:list of daily goals and dates set
Return type:json
daily_goal_update(slug, data)[source]

Set the daily goal for a specified dog, and get a response with future daily goals (if any). By default, a future daily goal is repeated for all future dates until another user-set goal is found. The daily goal can only be set for future dates, starting from the current date. The daily goal value needs to be a positive number.

Parameters:
  • slug (uuid) – uuid of the dog to modify
  • data (dict) – dictionary containing two values, daily_goal and date
Returns:

list of all future daily goals

Return type:

json

dog_get(slug)[source]

Get various information about a certain dog including name, breed, gender, weight, birthday and picture.

Parameters:slug (uuid) – uuid of the dog to look up
Returns:dog’s info
Return type:json
dog_picture_get(slug)[source]

Get the Base64 encoded picture for a specified dog.

Parameters:slug (uuid) – uuid of the dog to return
Returns:base64 encoded string of image
Return type:json

Get a list of users currently associated with a specified dog, together with the type of relationship (Owner or Friend) and privacy settings for each user (how far back in time the activity data is visible).

Parameters:slug (uuid) – uuid of the dog to look up
Returns:list of users
Return type:json
dog_similar_stats_get(slug)[source]

Get this dogs, and similar dogs, statistics.

Parameters:slug (uuid) – uuid of the dog to look up
Returns:statistics for dogs similar to the requested dog
Return type:json
time_breakdown_get(slug, date_from=None, date_to=None)[source]

Get the time (in minutes) spent at each activity level for a certain dog between two specified date times.

Parameters:
  • slug (uuid) – uuid of the dog to look up
  • date_from (datetime, date, str) – the start of the date range to look up
  • date_to (datetime, date, str) – the end of the date range to look up
Returns:

total minutes of each activity level (play, active, rest) for the period & dog

Return type:

json

user_picture_get(slug)[source]

Get the Base64 encoded picture for a specified user.

Parameters:slug (uuid) – uuid of the user to look up
Returns:base64 encoded string of image
Return type:json
user_profile_get()[source]

Get various information about the specified user including name, username (email address), profile picture and Facebook ID.

Returns:user details
Return type:json

Get the dogs related to the logged in user.

Returns:list of dogs
Return type:json

Indices and tables