Skip to content

Add plan_tour() for creating planned tours - #29

Open
sebastianzabel wants to merge 3 commits into
Tsadoq:mainfrom
sebastianzabel:feature/plan-tour
Open

Add plan_tour() for creating planned tours#29
sebastianzabel wants to merge 3 commits into
Tsadoq:mainfrom
sebastianzabel:feature/plan-tour

Conversation

@sebastianzabel

Copy link
Copy Markdown

Summary

  • Adds plan_tour() method to KomootConnector that creates planned tours (not recorded tours)
  • Uses Komoot's internal routing API (same as the web-based route planner) to route between waypoints
  • Two-step process: route via /api/routing/tour, then save via /api/v007/tours/ as tour_planned

Motivation

Currently upload_tour() can only create recorded tours from GPX/FIT files. There is no way to programmatically create a planned tour — the kind you'd create in Komoot's web route planner. This is useful for automated route planning, batch tour creation, and integration with external tools.

Usage

from kompy import KomootConnector

k = KomootConnector("email", "password")
result = k.plan_tour(
    waypoints=[
        {"lat": 53.14, "lng": 8.21},
        {"lat": 53.08, "lng": 8.31},
        {"lat": 53.14, "lng": 8.21},
    ],
    tour_name="Weekend Loop",
    sport="racebike",
)
print(result["url"])  # https://www.komoot.com/tour/123456

Parameters

Parameter Type Default Description
waypoints List[Dict] required List of {"lat": float, "lng": float} dicts (min. 2)
tour_name str required Name of the planned tour
sport str "racebike" Sport type (any SupportedActivities value)
constitution int 3 Fitness level 1-5
date str now ISO date string for the planned tour
status str "friends" Privacy status

Returns

{
    "tour_id": 123456,
    "url": "https://www.komoot.com/tour/123456",
    "distance": 29.6,   # km
    "duration": 77,      # minutes
    "type": "tour_planned",
    "name": "Weekend Loop",
}

Test plan

  • Tested with real Komoot account — tours appear as planned tours in the app
  • Verified routing works for racebike, multiple waypoints, round trips
  • Unit tests (not yet added)

🤖 Generated with Claude Code

sebastianzabel and others added 3 commits April 23, 2026 16:14
…g API

Currently, kompy can only upload recorded tours via upload_tour(). This adds
support for creating planned tours using the same routing engine as Komoot's
web-based route planner.

The new plan_tour() method:
- Takes a list of waypoints and routes between them using Komoot's routing API
- Saves the result as a planned tour (tour_planned), not a recorded tour
- Returns tour_id, URL, distance, and duration
- Supports sport type, fitness level (constitution), date, and privacy settings

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The routing endpoint only exists on www.komoot.com/api, but the save
endpoint works on api.komoot.de/v007/tours/ — consistent with all
other endpoints in the library.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add sport type validation against SupportedActivities
- List common sport types in docstring (racebike, touringbicycle, mtb, hike, jogging, mtb_easy)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sebastianzabel

Copy link
Copy Markdown
Author

@Tsadoq would be nice if you can approve my pr :-)

@Tsadoq
Tsadoq self-requested a review May 13, 2026 07:34
@Tsadoq

Tsadoq commented May 13, 2026

Copy link
Copy Markdown
Owner

@Tsadoq would be nice if you can approve my pr :-)

Sorry for delay, approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants