Add Komoot activity import with guided browser-based batch flow #25
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: McPringle/fitpub#25
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "McPringle/komoot-import"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
This PR adds a Komoot import flow to FitPub.
The goal of this feature is:
komootActivityIdso imported activities can be recognized laterThis PR focuses on the import foundation and the end-user workflow. It does not introduce a background job system or a permanent Komoot connection.
What is implemented
Komoot import view
A new Komoot import page is available from the upload/import navigation.
The page provides:
The credentials are only used for the current request and are not stored in FitPub.
Loading Komoot activities
The page can load Komoot activities for the given account and optional date range.
The loaded list shows:
The type shown in the list is the mapped FitPub type, not the raw Komoot sport value. This allows the user to see how each activity would be imported.
Import status in the list
Each activity shows whether it is already imported or still new.
The UI distinguishes between:
Matching and deduplication
Imported activities are linked to Komoot through
komootActivityIdstored on the FitPub activity.This is used to:
Import execution
The import runs as a browser-driven batch flow:
Each activity is imported by:
komootActivityIdtitledescriptionvisibilityactivityTypeThrottling and rate-limit protection
To reduce the risk of Komoot rate limiting, delays are applied intentionally.
Configurable delays are available for:
Cancellation
A running import can be stopped from the UI.
Behavior:
Constraints and behavior made explicit in the UI
The page explains important limitations:
Import flow
1. Fill in the form
The user enters:
Screenshot:
2. Load Komoot activities
The user loads Komoot activities.
The list shows:
Screenshot:
3. Start the import
The import button becomes available after activities are loaded.
When started:
Screenshot:
4. Import completion or stop
After completion:
Screenshot:
Technical notes
sourceFileFormatkomootActivityIdOut of scope
This PR does not include:
Summary
This PR introduces a complete first Komoot import experience in FitPub:
Thanks for the request, this seems to have been a lot of work.
I'm not sure that this feature matches the software, though. It seems to violate Komoots Terms of Service and uses an internal API with a spoofed Browser agent. Aside from the legal considerations, this seems error prone and prone to break.
I'm currently in the middle of enabling a full fledged OIDC flow to enable third party clients. This importer could be a standalone software using this API instead.
Until then, you can export many activities from Komoot, and upload them via batch import as a ZIP. I did this with ~800 activities from Strava, this uses a stateful batch approach and works well.
@ -0,0 +1,22 @@package net.javahippie.fitpub.model.dto;DTOs in this PR are all records. While I generally like them, I'd prefer the DTO to mimic the existing ones, classes with Lomboks
@Dataannotation. If the DTOs switch to records, it should be done for all, not fragmentedI don't think that this belongs into the activity table. I'd prefer a separate table to track the Komoot import status – there it could also be properly non-nullable
@ -0,0 +1,478 @@package net.javahippie.fitpub.service;This seems to use an inofficial, internal API of Komoot which is prone to be changed or break. Also, from my understanding this breaks the Komoot Terms of Service. The fact, that the User Agent needs to spoofed in order for this to works shows, that this code does something that Komoot explicitly does not want. I fear that this change will be a) hard to maintain in the future and b) might open this project to a lawsuit by Komoot.
See above, should be a seperate table
Thanks for the review, I'll have a look at it soon.
@ -0,0 +1,22 @@package net.javahippie.fitpub.model.dto;Okay, I'll switch the implementation to classes to mimic the esisting ones.
I thought about it yesterday, too. I'll change it accordingly.
You’re right that this relies on an undocumented, internal Komoot API. That comes with risks, especially around long-term stability, and I don’t want to downplay that.
A few clarifications:
Regarding the concerns about scope and risk: this is already implemented as a best-effort integration with clear boundaries.
FitPub already supports file-based imports (GPX/FIT). However, when importing activities that were exported from other platforms such as Komoot, these files are inherently lossy. In practice, important metadata is often missing: the activity name is frequently not preserved and the description is not included at all. The Komoot import addresses this gap by providing a more complete data set.
In addition, a direct integration enables access to further data in the future, for example metadata or media such as photos associated with an activity. This is not possible with a pure GPX export/import workflow.
Looking ahead, once OIDC support in FitPub is available, the authorization mechanism could be adapted accordingly. Based on my current understanding, this would mainly affect the authentication flow, while the underlying endpoints remain the same. In that case, the interaction would effectively use the same backend interfaces but via an officially supported authentication mechanism, rather than relying on a session-based login.
From a legal perspective, my understanding is that this mirrors what a user can already do via the web interface (accessing their own data). However, I agree that this area is not clearly defined, so being transparent about the nature of the integration is important.
If these trade-offs are not acceptable for the project, I’m also fine with keeping Komoot support out of scope.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.