py_trace package

Module contents

Top-level package for Trace Python Client.

class py_trace.Trace(client_key, client_secret, callback_uri=None, access_token=None, sport='snow')[source]
api_request(path, method='GET', **kwargs)[source]

Make a request to the API and parse the results

Parameters:
  • path (str) – API endpoint to hit, must start with /
  • method (str) – HTTP method (Default value = ‘GET’)
  • **kwargs

    Arguments to pass to the request, see requests.request

authenticate(access_token)[source]

Step 4 of auth, authenticate the user by creating a session with the access token. This is optional as it is called by get_access_token. If you already have the access_token, you can call this function directly or pass the access_token when instanciating the class in order to authenticate.

Parameters:access_token (dict) – A dict containing the oauth_token and oauth_token_secret.
create_event_comment(event_id, message)[source]

Add a comment to an event

Parameters:
  • event_id (int,str) – Event ID
  • message (str) – Comment text
create_visit_comment(visit_id, facebook=False, twitter=False, photo=None, hide_resort_name=0, comment=None, equipment=None)[source]

Add comment to a visit

Parameters:
  • visit_id (int,str) – Visit ID
  • facebook (bool) – Whether to post to facebook or not (Default value = False)
  • twitter (bool) – Whether to post to twitter or not (Default value = False)
  • photo – (Default value = None)
  • hide_resort_name – (Default value = 0)
  • comment (str) – Comment text (Default value = None)
  • equipment (list) – List of strings for each equipment item (Default value = None)
create_visit_equipment(visit_id, equipment)[source]

Add equipment info for a visit

Parameters:
  • visit_id (int,str) – Visit ID
  • equipment (list) – List of strings for each equipment item
create_visit_export(visit_id)[source]

Create an export of the visit gpx file

Parameters:visit_id (int,str) – Visit ID
create_visit_overlay(data)[source]

Upload track file to create video overlay

Parameters:data
create_visit_photo(visit_id, photo)[source]

Add a photo to a visit

Parameters:
  • visit_id (int,str) – Visit ID
  • photo
delete_run(run_id)[source]

Delete a run

Parameters:run_id (int,str) – Run ID
get_access_token(oauth_verifier)[source]

Step 3 of auth, get the access token. After the user authorizes the app, we get the access token using the oauth_verifier and then authenticate the user.

Parameters:oauth_verifier (str) – A string containing the verifier
get_authorization_url()[source]

Step 2 of auth, get the authorization URL. It will first get the request token if it needs it.

get_event(event_id)[source]

Get event info

Parameters:event_id (int,str) – Event ID
get_events(min_timestamp=None, max_timestamp=None, limit=None, ffilter=None)[source]

Get all events for yourself

Parameters:
  • min_timestamp (int) – Minimum timestamp to filter results (Default value = None)
  • max_timestamp (int) – Maximum timestamp to filter results (Default value = None)
  • limit (str,int) – Limit the number of entries in responses, if None is given the API defaults to 50 (Default value = None)
  • ffilter (dict) – A filter for fields to be returned, see documentation for more (Default value = None)
get_request_token()[source]

Step 1 of auth, get the request token. This is optional as this is called by get_auth_url if needed.

get_user(user_id='self')[source]

Get user info

Parameters:user_id (int,str) – User ID (Default value = ‘self’)
get_visit_equipment(visit_id)[source]

Get equipment info for a visit

Parameters:visit_id (int,str) – Visit ID
get_visit_events(visit_id, ffilter=None)[source]

Get all events for a visit

Parameters:
  • visit_id (int,str) – Visit ID
  • ffilter (dict) –

    A filter for fields to be returned, see documentation for more (Default value = None)

get_visit_list(user_id='self', ffilter=None)[source]

Get list of user visits

Parameters:
  • user_id (int,str) – User ID (Default value = ‘self’)
  • ffilter (dict) –

    A filter for fields to be returned, see documentation for more (Default value = None)

get_visit_weather(visit_id)[source]

Get weather report for visit if available

Parameters:visit_id (int,str) – Visit ID
get_visits(user_id='self', limit=None, min_timestamp=None, max_timestamp=None, visit_ids=None, ffilter=None)[source]

Get all user visits

Parameters:
  • user_id (int,str) – User ID (Default value = ‘self’)
  • limit (str,int) – Limit the number of entries in responses, if None is given the API defaults to 50 (Default value = None)
  • min_timestamp (int) – Minimum timestamp to filter results (Default value = None)
  • max_timestamp (int) – Maximum timestamp to filter results (Default value = None)
  • visit_ids (list) – List of visit IDs to include (Default value = None)
  • ffilter (dict) –

    A filter for fields to be returned, see documentation for more (Default value = None)

hide_run(run_id)[source]

Hide a run

Parameters:run_id (int,str) – Run ID
like_event(event_id)[source]

Like an event

Parameters:event_id (int,str) – Event ID
share_visit(visit_id, stats, comment=None, photo=None, facebook=True, twitter=True)[source]

Share a visit

Parameters:
  • visit_id (int,str) – Visit ID
  • stats (list) – List of stats to include, one of [total_distance, jumps, air_time, avg_speed, calories, vertical_drop, sustained_speed, slope_time, max_slope, turns_num, longest_ride]
  • comment (str) – Comment text (Default value = None)
  • photo – (Default value = None)
  • facebook (bool) – Whether to post to facebook or not (Default value = True)
  • twitter (bool) – Whether to post to twitter or not (Default value = True)
unlike_event(event_id)[source]

Unlike an event

Parameters:event_id (int,str) – Event ID