Welcome to komPYoot’s documentation!

komPYoot package

komPYoot.api

Created on Tue Aug 2 12:51:22 2022.

@author: Nishad Mandlik

class API[source]

Bases: object

Class for interfacing with the Komoot API.

Refer to https://static.komoot.de/doc/external-api/v007/index.html

__init__()[source]

Initialize a Komoot API object.

Return type

None.

download_tour_gpx(tour_id, download_dir)[source]

Download tour in the GPX format.

Parameters
  • tour_id (str) – Tour ID.

  • download_dir (str) – Path of the directory where the downloaded tour will be saved.

Raises

RuntimeError – If no user is logged-in.

Returns

file_name if download is successful, None otherwise.

Return type

str or None

get_user_disp_name()[source]

Return the display name of the logged-in user.

Raises

RuntimeError – If no user is logged-in.

Return type

str.

get_user_email()[source]

Return the email ID of the logged-in user.

Raises

RuntimeError – If no user is logged-in.

Return type

str.

get_user_id()[source]

Return the user ID of the logged-in user.

Raises

RuntimeError – If no user is logged-in.

Return type

str.

get_user_pic_url()[source]

Return the display picture URL of the logged-in user. If picture is not set, None is returned.

Raises

RuntimeError – If no user is logged-in.

Return type

str or None.

get_user_tours_list(tour_type=None, tour_status=None, sport=None, tour_owner=None)[source]

Get the list of tours for the logged-in user, according to the user-defined filters.

Parameters
  • tour_type (TourType or None, optional) – Bitwise OR-ed flags for filtering multiple tour types. The default is None.

  • tour_status (TourStatus or None, optional) – Bitwise OR-ed flags for filtering multiple tour statuses. The default is None.

  • sport (Sport or None, optional) – Bitwise OR-ed flags for filtering multiple sports. The default is None.

  • tour_owner (TourOwner or None, optional) – Bitwise OR-ed flags for filtering activities according to creator (self or others). The default is None.

Raises

RuntimeError – If no user is logged-in.

Returns

tours – List of dictionaries containing details of tours.

Return type

list

login(email_id, password)[source]

Authenticate user credentials and generate access token for the Komoot API.

Parameters
  • email_id (str) – Email ID for Komoot account.

  • password (str) – Password for Komoot account.

Returns

True if login is successful, False otherwise.

Return type

bool

upload_tour_gpx(sport, file_path, duration=None)[source]

Upload a GPX file as a recorded activity.

Parameters
  • sport (Sport) – Type of sport for the tour.

  • file_path (str) – Path of the GPX file.

  • duration (int or None, optional) – Time in motion (in seconds) for the tour. If None, Komoot assumes the duration of the entire tour to be the time in motion. The default is None.

Raises

RuntimeError – If no user is logged-in.

Returns

True, if upload is successful, False otherwise.

Return type

bool

class AutoFlag(value)[source]

Bases: IntFlag

Flag Enum with auto value generation.

class Sport(value)[source]

Bases: AutoFlag

Flag Enum for Sports.

Obtained from https://static.komoot.de/doc/external-api/v007/sports.html

ALPINE_SKIING = 2097152[source]
BIKE_TOURING = 4[source]
BIKING = 1[source]
CROSS_COUNTRY_SKIING = 1048576[source]
E_BIKE_TOURING = 2[source]
E_GRAVEL_BIKING = 32[source]
E_MT_BIKING = 128[source]
E_MT_BIKING_ENDURO = 1024[source]
E_ROAD_CYCLING = 8[source]
GRAVEL_BIKING = 64[source]
HIKING = 8192[source]
MOUNTAINEERING = 65536[source]
MT_BIKING = 256[source]
MT_BIKING_DOWNHILL = 512[source]
MT_BIKING_ENDURO = 2048[source]
NORDIC_WALKING = 262144[source]
OTHER = 33554432[source]
ROAD_CYCLING = 16[source]
ROCK_CLIMBING = 131072[source]
RUNNING = 16384[source]
SKATING = 32768[source]
SKI_TOURING = 524288[source]
SLEDGING = 4194304[source]
SNOWBOARDING = 8388608[source]
SNOWSHOEING = 16777216[source]
UNICYCLING = 4096[source]
class TourOwner(value)[source]

Bases: IntFlag

Enum for tour owner (logged-in user or other user).

OTHER = 2[source]
SELF = 1[source]
class TourStatus(value)[source]

Bases: AutoFlag

Flag Enum for Tour Status (Public, Private).

PRIVATE = 2[source]
PUBLIC = 1[source]
class TourType(value)[source]

Bases: AutoFlag

Flag Enum for Tour Type (Planned, Recorded).

PLANNED = 1[source]
RECORDED = 2[source]

ReadMe

Python Interface for Komoot API

Indices and tables