Versions in this module Expand all Collapse all v0 v0.1.0 Oct 15, 2026 Changes in this version + var ErrAuthentication = errors.New("garminconnect: authentication failed") + var ErrConnection = errors.New("garminconnect: connection error") + var ErrInvalidArgument = errors.New("garminconnect: invalid argument") + var ErrInvalidFileFormat = errors.New("garminconnect: invalid file format") + var ErrNotFound = errors.New("garminconnect: not found") + var ErrTooManyRequests = errors.New("garminconnect: too many requests") + var ExerciseCategories = []string + var Exercises = []Exercise + var SportCardioTraining = SportType + var SportCycling = SportType + var SportHiking = SportType + var SportMultiSport = SportType + var SportRunning = SportType + var SportStrengthTraining = SportType + var SportSwimming = SportType + var SportWalking = SportType + func As[T any](raw json.RawMessage, err error) (T, error) + func PaceToMPS(minutes, seconds int, units string) float64 + func ParseActivityDetailMetrics(details json.RawMessage) ([]map[string]any, error) + func SpeedToMPS(speed float64, units string) float64 + func StatusCode(err error) int + func TokenFilePath(path string) (string, error) + type ActivityDownloadFormat int + const FormatCSV + const FormatGPX + const FormatKML + const FormatOriginal + const FormatTCX + type BodyComposition struct + ActiveMet *float64 + BMI *float64 + BasalMet *float64 + BoneMass *float64 + MetabolicAge *float64 + MuscleMass *float64 + PercentFat *float64 + PercentHydration *float64 + PhysiqueRating *float64 + VisceralFatMass *float64 + VisceralFatRating *float64 + Weight float64 + type Client struct + Log *slog.Logger + OnTokens func(tokenJSON string) + SkipStrategies map[string]bool + VerifyLogin bool + func NewClient(domain string) (*Client, error) + func (c *Client) Dump(path string) error + func (c *Client) Dumps() string + func (c *Client) IsAuthenticated() bool + func (c *Client) Load(path string) error + func (c *Client) Loads(s string) error + func (c *Client) Login(ctx context.Context, email, password string, promptMFA func() (string, error), ...) (needsMFA bool, err error) + func (c *Client) Request(ctx context.Context, method, path string, opts *RequestOptions) ([]byte, error) + func (c *Client) ResumeLogin(ctx context.Context, code string) error + type DailyCalories struct + Active *float64 + CalendarDate string + Resting *float64 + Total float64 + type DailyValue struct + CalendarDate string + Value float64 + type EndCondition struct + ConditionTypeID int + ConditionTypeKey string + DisplayOrder int + Displayable bool + type Error struct + Err error + Kind error + Msg string + StatusCode int + func (e *Error) Error() string + func (e *Error) Is(target error) bool + func (e *Error) Unwrap() []error + type ExecutableStep struct + Category string + ChildStepID *int + EndCondition *EndCondition + EndConditionValue *float64 + EquipmentType map[string]any + ExerciseName *string + SecondaryTargetType *TargetType + SecondaryTargetValueOne *float64 + SecondaryTargetValueTwo *float64 + SecondaryZoneNumber *int + StepOrder int + StepType *StepType + StrokeType map[string]any + TargetType *TargetType + TargetValueOne *float64 + TargetValueTwo *float64 + Type string + WeightUnit map[string]any + WeightValue *float64 + ZoneNumber *int + func CooldownStep(durationSecs float64, order int) *ExecutableStep + func DistanceIntervalStep(distanceMeters float64, order int, primary, secondary *Target) (*ExecutableStep, error) + func IntervalStep(durationSecs float64, order int, primary, secondary *Target) (*ExecutableStep, error) + func RecoveryStep(durationSecs float64, order int) *ExecutableStep + func StrengthExerciseStep(category string, order, reps int, exerciseName string, weightKG *float64) *ExecutableStep + func StrengthRestStep(durationSecs float64, order int) *ExecutableStep + func WarmupStep(durationSecs float64, order int) *ExecutableStep + type Exercise struct + Category string + Exercise string + Name string + func FindExercises(term string) []Exercise + func ResolveExercise(name string) (Exercise, bool) + type Garmin struct + Client *Client + DisplayName string + FullName string + ProfileID int64 + UnitSystem string + func New(email, password string, opts ...Option) *Garmin + func (g *Garmin) AddBodyComposition(ctx context.Context, ts time.Time, bc BodyComposition) (json.RawMessage, error) + func (g *Garmin) AddGearToActivity(ctx context.Context, gearUUID string, activityID int64) (json.RawMessage, error) + func (g *Garmin) AddHydrationData(ctx context.Context, valueML float64, ts time.Time, cdate string) (json.RawMessage, error) + func (g *Garmin) AddJetlagTrip(ctx context.Context, start, end string, flights []JetlagFlight) (json.RawMessage, error) + func (g *Garmin) AddWeighIn(ctx context.Context, weight float64, unit string, ts time.Time) (json.RawMessage, error) + func (g *Garmin) AddWeighInWithTimestamps(ctx context.Context, weight float64, unit string, local, gmt time.Time) (json.RawMessage, error) + func (g *Garmin) ConfirmMenstrualPeriodStart(ctx context.Context, periodStart string, periodLength, cycleLength int, ...) (json.RawMessage, error) + func (g *Garmin) ConnectAPI(ctx context.Context, path string, params url.Values) (json.RawMessage, error) + func (g *Garmin) CountActivities(ctx context.Context) (int64, error) + func (g *Garmin) CreateGear(ctx context.Context, s GearSpec) (json.RawMessage, error) + func (g *Garmin) CreateManualActivity(ctx context.Context, start, timeZone, typeKey string, distanceKM float64, ...) (json.RawMessage, error) + func (g *Garmin) CreateManualActivityFromJSON(ctx context.Context, payload any) (json.RawMessage, error) + func (g *Garmin) DeleteActivity(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) DeleteBloodPressure(ctx context.Context, version int64, cdate string) (json.RawMessage, error) + func (g *Garmin) DeleteJetlagTrip(ctx context.Context, tripID int64) (json.RawMessage, error) + func (g *Garmin) DeleteWeighIn(ctx context.Context, weightPK int64, cdate string) (json.RawMessage, error) + func (g *Garmin) DeleteWeighIns(ctx context.Context, cdate string, deleteAll bool) (int, error) + func (g *Garmin) DeleteWorkout(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) Download(ctx context.Context, path string) ([]byte, error) + func (g *Garmin) DownloadActivity(ctx context.Context, id int64, format ActivityDownloadFormat) ([]byte, error) + func (g *Garmin) DownloadHealthSnapshot(ctx context.Context, date string) ([]byte, error) + func (g *Garmin) DownloadWorkout(ctx context.Context, id int64) ([]byte, error) + func (g *Garmin) GetActivities(ctx context.Context, start, limit int, activityType, subType string) (json.RawMessage, error) + func (g *Garmin) GetActivitiesByDate(ctx context.Context, startdate, enddate, activityType, sortOrder string) (json.RawMessage, error) + func (g *Garmin) GetActivitiesForDate(ctx context.Context, date string) (json.RawMessage, error) + func (g *Garmin) GetActivity(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetActivityDetails(ctx context.Context, id int64, maxChart, maxPoly int) (json.RawMessage, error) + func (g *Garmin) GetActivityExerciseSets(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetActivityGear(ctx context.Context, activityID int64) (json.RawMessage, error) + func (g *Garmin) GetActivityHRInTimezones(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetActivityImages(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetActivityPowerInTimezones(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetActivitySplitSummaries(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetActivitySplits(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetActivityTypedSplits(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetActivityTypes(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetActivityWeather(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetAdaptiveTrainingPlanByID(ctx context.Context, planID int64) (json.RawMessage, error) + func (g *Garmin) GetAdhocChallenges(ctx context.Context, start, limit int) (json.RawMessage, error) + func (g *Garmin) GetAllDayEvents(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetAllDayStress(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetAvailableBadgeChallenges(ctx context.Context, start, limit int) (json.RawMessage, error) + func (g *Garmin) GetAvailableBadges(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetBadgeChallenges(ctx context.Context, start, limit int) (json.RawMessage, error) + func (g *Garmin) GetBloodPressure(ctx context.Context, startdate, enddate string) (json.RawMessage, error) + func (g *Garmin) GetBodyBattery(ctx context.Context, startdate, enddate string) (json.RawMessage, error) + func (g *Garmin) GetBodyBatteryEvents(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetBodyComposition(ctx context.Context, startdate, enddate string) (json.RawMessage, error) + func (g *Garmin) GetCaloriesDaily(ctx context.Context, start, end string) ([]DailyCalories, error) + func (g *Garmin) GetCyclingFTP(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetDailySteps(ctx context.Context, start, end string) (json.RawMessage, error) + func (g *Garmin) GetDailyTrainingStatus(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetDailyWeighIns(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetDeviceAlarms(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetDeviceLastUsed(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetDeviceSettings(ctx context.Context, deviceID int64) (json.RawMessage, error) + func (g *Garmin) GetDeviceSolarData(ctx context.Context, deviceID int64, startdate, enddate string) (json.RawMessage, error) + func (g *Garmin) GetDevices(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetEarnedBadges(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetEnduranceScore(ctx context.Context, startdate, enddate string) (json.RawMessage, error) + func (g *Garmin) GetFitnessAgeData(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetFloors(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetFunctionalThresholdPowerRange(ctx context.Context, start, end, sport, aggregation string) (json.RawMessage, error) + func (g *Garmin) GetGear(ctx context.Context, userProfileNumber int64) (json.RawMessage, error) + func (g *Garmin) GetGearActivities(ctx context.Context, gearUUID string, limit int) (json.RawMessage, error) + func (g *Garmin) GetGearDefaults(ctx context.Context, userProfileNumber int64) (json.RawMessage, error) + func (g *Garmin) GetGearStats(ctx context.Context, gearUUID string) (json.RawMessage, error) + func (g *Garmin) GetGoals(ctx context.Context, status string, start, limit int) (json.RawMessage, error) + func (g *Garmin) GetGolfClubStats(ctx context.Context, limit int) (json.RawMessage, error) + func (g *Garmin) GetGolfScorecard(ctx context.Context, scorecardID int64) (json.RawMessage, error) + func (g *Garmin) GetGolfShotData(ctx context.Context, scorecardID int64, holes string) (json.RawMessage, error) + func (g *Garmin) GetGolfSummary(ctx context.Context, start, limit int) (json.RawMessage, error) + func (g *Garmin) GetGolfUserStats(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetHRVData(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetHRVDataRange(ctx context.Context, start, end string) (json.RawMessage, error) + func (g *Garmin) GetHeartRateZones(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetHeartRates(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetHillScore(ctx context.Context, startdate, enddate string) (json.RawMessage, error) + func (g *Garmin) GetHydrationData(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetInProgressBadges(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetInProgressVirtualChallenges(ctx context.Context, start, limit int) (json.RawMessage, error) + func (g *Garmin) GetIntensityMinutesData(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetJetlagTrips(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetLactateThreshold(ctx context.Context, latest bool, start, end, aggregation string) (json.RawMessage, error) + func (g *Garmin) GetLastActivity(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetLifestyleLoggingData(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetMaxMetrics(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetMaxMetricsRange(ctx context.Context, start, end string) (json.RawMessage, error) + func (g *Garmin) GetMenstrualCalendarData(ctx context.Context, startdate, enddate string) (json.RawMessage, error) + func (g *Garmin) GetMenstrualCycleSummary(ctx context.Context, date string) (json.RawMessage, error) + func (g *Garmin) GetMenstrualDataForDate(ctx context.Context, date string) (json.RawMessage, error) + func (g *Garmin) GetMenstrualLastConfirmed(ctx context.Context, date string) (json.RawMessage, error) + func (g *Garmin) GetMenstrualReports(ctx context.Context, date string, cycles int, next bool, ...) (json.RawMessage, error) + func (g *Garmin) GetMorningTrainingReadiness(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetNextScheduledWorkout(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetNonCompletedBadgeChallenges(ctx context.Context, start, limit int) (json.RawMessage, error) + func (g *Garmin) GetNutritionDailyFoodLog(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetNutritionDailyMeals(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetNutritionDailySettings(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetPersonalRecord(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetPowerZones(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetPowerZonesForSport(ctx context.Context, sport string) (json.RawMessage, error) + func (g *Garmin) GetPregnancySummary(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetPrimaryTrainingDevice(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetProgressSummaryBetweenDates(ctx context.Context, startdate, enddate, metric string, groupByActivities bool) (json.RawMessage, error) + func (g *Garmin) GetRHRDaily(ctx context.Context, start, end string) ([]DailyValue, error) + func (g *Garmin) GetRHRDay(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetRacePredictions(ctx context.Context, startdate, enddate, predType string) (json.RawMessage, error) + func (g *Garmin) GetRespirationData(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetRunningTolerance(ctx context.Context, startdate, enddate, aggregation string) (json.RawMessage, error) + func (g *Garmin) GetScheduledWorkoutByID(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetScheduledWorkouts(ctx context.Context, year, month int) (json.RawMessage, error) + func (g *Garmin) GetSleepDaily(ctx context.Context, start, end string) (json.RawMessage, error) + func (g *Garmin) GetSleepData(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetSpo2Data(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetStats(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetStatsAndBody(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetStepsData(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetStressData(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetTrainingFourWeekLoadBalance(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetTrainingLoadActivities(ctx context.Context, startdate, enddate string, metrics []string, ...) (json.RawMessage, error) + func (g *Garmin) GetTrainingPlanByID(ctx context.Context, planID int64) (json.RawMessage, error) + func (g *Garmin) GetTrainingPlans(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetTrainingReadiness(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetTrainingStatus(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetUserProfile(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetUserSummary(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) GetUserprofileSettings(ctx context.Context) (json.RawMessage, error) + func (g *Garmin) GetWeeklyIntensityMinutes(ctx context.Context, start, end string) (json.RawMessage, error) + func (g *Garmin) GetWeeklySteps(ctx context.Context, end string, weeks int) (json.RawMessage, error) + func (g *Garmin) GetWeeklyStress(ctx context.Context, end string, weeks int) (json.RawMessage, error) + func (g *Garmin) GetWeighIns(ctx context.Context, startdate, enddate string) (json.RawMessage, error) + func (g *Garmin) GetWorkoutByID(ctx context.Context, id int64) (json.RawMessage, error) + func (g *Garmin) GetWorkouts(ctx context.Context, start, limit int) (json.RawMessage, error) + func (g *Garmin) ImportActivity(ctx context.Context, path string) (json.RawMessage, error) + func (g *Garmin) InitMenstrualCycleSetup(ctx context.Context, periodStart string, periodLength, cycleLength int) (json.RawMessage, error) + func (g *Garmin) Login(ctx context.Context, tokenstore string) (needsMFA bool, err error) + func (g *Garmin) Logout(tokenstore string) error + func (g *Garmin) PushWorkoutToDevice(ctx context.Context, workoutID, deviceID int64) (json.RawMessage, error) + func (g *Garmin) QueryGarminGraphQL(ctx context.Context, query any) (json.RawMessage, error) + func (g *Garmin) RemoveGearFromActivity(ctx context.Context, gearUUID string, activityID int64) (json.RawMessage, error) + func (g *Garmin) RequestReload(ctx context.Context, cdate string) (json.RawMessage, error) + func (g *Garmin) ResumeLogin(ctx context.Context, code string) error + func (g *Garmin) ScheduleWorkout(ctx context.Context, workoutID int64, date string) (json.RawMessage, error) + func (g *Garmin) SetActivityDescription(ctx context.Context, id int64, description string) (json.RawMessage, error) + func (g *Garmin) SetActivityExerciseSets(ctx context.Context, id int64, payload any) (json.RawMessage, error) + func (g *Garmin) SetActivityName(ctx context.Context, id int64, title string) (json.RawMessage, error) + func (g *Garmin) SetActivityType(ctx context.Context, id int64, typeID int, typeKey string, parentTypeID int) (json.RawMessage, error) + func (g *Garmin) SetBloodPressure(ctx context.Context, systolic, diastolic, pulse int, ts time.Time, ...) (json.RawMessage, error) + func (g *Garmin) SetGearDefault(ctx context.Context, activityType, gearUUID string, defaultGear bool) (json.RawMessage, error) + func (g *Garmin) UnscheduleWorkout(ctx context.Context, scheduledWorkoutID int64) (json.RawMessage, error) + func (g *Garmin) UpdateJetlagTrip(ctx context.Context, tripID int64, start, end string, flights []JetlagFlight) (json.RawMessage, error) + func (g *Garmin) UpdateMenstrualCalendar(ctx context.Context, startdate, enddate string, cycleDates [][]string, ...) (json.RawMessage, error) + func (g *Garmin) UpdateMenstrualDailyLog(ctx context.Context, date string, l MenstrualDailyLog) (json.RawMessage, error) + func (g *Garmin) UpdateMenstrualSettings(ctx context.Context, settings map[string]any, userSettingsID int64) (json.RawMessage, error) + func (g *Garmin) UpdateWorkout(ctx context.Context, id int64, workout any) (json.RawMessage, error) + func (g *Garmin) UploadActivity(ctx context.Context, path string) (json.RawMessage, error) + func (g *Garmin) UploadWorkout(ctx context.Context, workout any) (json.RawMessage, error) + type GearSpec struct + ActivityTypeKeys []string + Brand string + FirstUseDate string + GearType string + MaxUsageKM float64 + MaxUsageMin float64 + Model string + Name string + Notes string + UsageType string + type JetlagFlight struct + DestinationLocation string + DestinationTimestamp string + DestinationTimezone string + FlightID int64 + OriginLocation string + OriginTimestamp string + OriginTimezone string + TripID int64 + type MenstrualDailyLog struct + Discharge []string + Flow string + Moods []string + Notes *string + OvulationDay *bool + SexDrive string + SexualActivity string + Symptoms []string + type Option func(*Garmin) + func WithCN() Option + func WithLogger(l *slog.Logger) Option + func WithPromptMFA(fn func() (string, error)) Option + func WithRetry(attempts int, minWait, maxWait time.Duration) Option + func WithReturnOnMFA() Option + func WithTokenSaver(fn func(tokenJSON string)) Option + func WithVerifyLogin(v bool) Option + type RepeatGroup struct + ChildStepID *int + EndCondition *EndCondition + EndConditionValue *float64 + NumberOfIterations int + SkipLastRestStep *bool + SmartRepeat bool + StepOrder int + StepType *StepType + Type string + WorkoutSteps []Step + func NewRepeatGroup(iterations int, steps []Step, order int, skipLastRest *bool) *RepeatGroup + func StrengthSet(category string, order, sets, reps int, restSecs float64, exerciseName string, ...) *RepeatGroup + type RequestOptions struct + Body []byte + ContentType string + Headers map[string]string + Params url.Values + type SportType struct + DisplayOrder int + SportTypeID int + SportTypeKey string + type Step interface + type StepType struct + DisplayOrder int + StepTypeID int + StepTypeKey string + type Target struct + func CadenceTarget(lower, upper float64) (*Target, error) + func CustomHeartRateTarget(lower, upper float64) (*Target, error) + func CustomPowerTarget(lower, upper float64) (*Target, error) + func HeartRateZoneTarget(zone int) *Target + func PaceTarget(lower, upper float64) (*Target, error) + func PowerZoneTarget(zone int) *Target + func SpeedTarget(lower, upper float64) (*Target, error) + func SwimCSSOffsetTarget(offsetSeconds float64) (*Target, error) + type TargetType struct + DisplayOrder int + WorkoutTargetTypeID int + WorkoutTargetTypeKey string + type Workout struct + Author map[string]any + Description *string + EstimatedDurationInSecs int + SportType SportType + WorkoutName string + WorkoutSegments []WorkoutSegment + func NewWorkout(sport SportType, name string, estimatedSecs int, steps ...Step) *Workout + type WorkoutSegment struct + SegmentOrder int + SportType SportType + WorkoutSteps []Step