garminapi

package
v1.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCircuitOpen = errors.New("circuit breaker is open")

ErrCircuitOpen is returned when the circuit breaker is open and not accepting requests.

Functions

func FetchExerciseCatalog added in v1.4.0

func FetchExerciseCatalog(ctx context.Context) (json.RawMessage, error)

FetchExerciseCatalog fetches the public Garmin exercise catalog. This does not require authentication.

Types

type AuthRequiredError

type AuthRequiredError struct {
	Email string
}

AuthRequiredError indicates no authentication credentials were found.

func (*AuthRequiredError) Error

func (e *AuthRequiredError) Error() string

type CircuitBreaker

type CircuitBreaker struct {
	// contains filtered or unexported fields
}

CircuitBreaker implements a simple circuit breaker pattern. It tracks consecutive failures and opens the circuit when a threshold is reached, preventing further requests until a reset timeout elapses.

func NewCircuitBreaker

func NewCircuitBreaker(threshold int, resetTimeout time.Duration) *CircuitBreaker

NewCircuitBreaker creates a circuit breaker with the given threshold and reset timeout. Default: threshold=5, resetTimeout=30s.

func (*CircuitBreaker) Allow

func (cb *CircuitBreaker) Allow() error

Allow checks if a request is permitted. Returns an error if the circuit is open. If the circuit is half-open, it allows one probe request.

func (*CircuitBreaker) Failures

func (cb *CircuitBreaker) Failures() int

Failures returns the current consecutive failure count.

func (*CircuitBreaker) RecordFailure

func (cb *CircuitBreaker) RecordFailure()

RecordFailure records a failed request. If the failure threshold is reached, the circuit opens.

func (*CircuitBreaker) RecordSuccess

func (cb *CircuitBreaker) RecordSuccess()

RecordSuccess records a successful request, resetting the failure count and closing the circuit if it was half-open.

func (*CircuitBreaker) State

func (cb *CircuitBreaker) State() string

State returns the current circuit breaker state as a string (for diagnostics).

type Client

type Client struct {

	// OnTokenRefresh is called after a successful OAuth2 token refresh.
	// Use this to persist refreshed tokens back to storage.
	// If nil, no action is taken (tokens are only updated in-memory).
	OnTokenRefresh func(tokens *garminauth.Tokens)
	// contains filtered or unexported fields
}

Client interacts with the Garmin Connect API.

func NewClient

func NewClient(tokens *garminauth.Tokens, opts ...ClientOption) *Client

NewClient creates a new Garmin Connect API client.

func (*Client) AddBloodPressure

func (c *Client) AddBloodPressure(ctx context.Context, systolic, diastolic, pulse int, timestampLocal, timestampGMT, notes string) (json.RawMessage, error)

AddBloodPressure adds a blood pressure measurement.

func (*Client) AddEvent added in v1.2.0

func (c *Client) AddEvent(ctx context.Context, payload json.RawMessage) (json.RawMessage, error)

AddEvent creates a new calendar event.

func (*Client) AddHydration

func (c *Client) AddHydration(ctx context.Context, date string, amountML float64) (json.RawMessage, error)

AddHydration adds a hydration log entry for the given date. Amount is in milliliters.

func (*Client) AddWeight

func (c *Client) AddWeight(ctx context.Context, weight float64, unitKey string, dateTimestamp string, gmtTimestamp string) (json.RawMessage, error)

AddWeight adds a weigh-in entry.

func (*Client) ConnectAPI

func (c *Client) ConnectAPI(ctx context.Context, method, path string, body io.Reader) (json.RawMessage, error)

ConnectAPI makes a JSON API request to the Garmin Connect API. The response body is returned as a json.RawMessage. For 204 No Content responses (common for delete operations), nil is returned.

func (*Client) CountActivities

func (c *Client) CountActivities(ctx context.Context) (int, error)

CountActivities returns the total number of activities for the authenticated user.

func (*Client) CreateManualActivity

func (c *Client) CreateManualActivity(ctx context.Context, name, activityType, timezone string, distanceMeters float64, durationSeconds float64, startTime string) (json.RawMessage, error)

CreateManualActivity creates a manual activity entry.

func (*Client) DeleteActivity

func (c *Client) DeleteActivity(ctx context.Context, activityID string) error

DeleteActivity deletes an activity by ID.

func (*Client) DeleteBloodPressure

func (c *Client) DeleteBloodPressure(ctx context.Context, date string, version string) error

DeleteBloodPressure deletes a blood pressure entry by date and version. Date format: YYYY-MM-DD.

func (*Client) DeleteCourse added in v1.1.0

func (c *Client) DeleteCourse(ctx context.Context, courseID string) error

DeleteCourse deletes a course by ID.

func (*Client) DeleteEvent added in v1.2.0

func (c *Client) DeleteEvent(ctx context.Context, eventID string) error

DeleteEvent deletes a calendar event by ID.

func (*Client) DeleteWeight

func (c *Client) DeleteWeight(ctx context.Context, date string, version string) error

DeleteWeight deletes a weigh-in entry by date and version (primary key). Date format: YYYY-MM-DD.

func (*Client) DeleteWorkout

func (c *Client) DeleteWorkout(ctx context.Context, workoutID string) error

DeleteWorkout deletes a workout by ID.

func (*Client) Download

func (c *Client) Download(ctx context.Context, path string) ([]byte, error)

Download fetches a binary resource from the API.

func (*Client) DownloadActivity

func (c *Client) DownloadActivity(ctx context.Context, activityID string, format DownloadFormat) ([]byte, error)

DownloadActivity downloads an activity in the specified format.

func (*Client) DownloadCourse added in v1.9.0

func (c *Client) DownloadCourse(ctx context.Context, courseID string, format DownloadFormat) ([]byte, error)

DownloadCourse downloads a course in the specified format.

func (*Client) DownloadWorkout

func (c *Client) DownloadWorkout(ctx context.Context, workoutID string) ([]byte, error)

DownloadWorkout downloads a workout as a FIT file.

func (*Client) GetActivities

func (c *Client) GetActivities(ctx context.Context, start, limit int, activityType string) (json.RawMessage, error)

GetActivities returns a page of activities.

func (*Client) GetActivity

func (c *Client) GetActivity(ctx context.Context, activityID string) (json.RawMessage, error)

GetActivity returns a single activity by ID.

func (*Client) GetActivityDetails

func (c *Client) GetActivityDetails(ctx context.Context, activityID string, maxChart, maxPoly int) (json.RawMessage, error)

GetActivityDetails returns detailed activity data including charts and polylines.

func (*Client) GetActivityExerciseSets

func (c *Client) GetActivityExerciseSets(ctx context.Context, activityID string) (json.RawMessage, error)

GetActivityExerciseSets returns exercise set data for strength training activities.

func (*Client) GetActivityGear

func (c *Client) GetActivityGear(ctx context.Context, activityID string) (json.RawMessage, error)

GetActivityGear returns gear linked to an activity.

func (*Client) GetActivityHRZones

func (c *Client) GetActivityHRZones(ctx context.Context, activityID string) (json.RawMessage, error)

GetActivityHRZones returns heart rate time-in-zone data for an activity.

func (*Client) GetActivityPowerZones

func (c *Client) GetActivityPowerZones(ctx context.Context, activityID string) (json.RawMessage, error)

GetActivityPowerZones returns power time-in-zone data for an activity.

func (*Client) GetActivitySplitSummaries

func (c *Client) GetActivitySplitSummaries(ctx context.Context, activityID string) (json.RawMessage, error)

GetActivitySplitSummaries returns the split summaries for an activity.

func (*Client) GetActivitySplits

func (c *Client) GetActivitySplits(ctx context.Context, activityID string) (json.RawMessage, error)

GetActivitySplits returns the splits for an activity.

func (*Client) GetActivityTypedSplits

func (c *Client) GetActivityTypedSplits(ctx context.Context, activityID string) (json.RawMessage, error)

GetActivityTypedSplits returns the typed splits for an activity.

func (*Client) GetActivityTypes added in v1.8.0

func (c *Client) GetActivityTypes(ctx context.Context) (json.RawMessage, error)

GetActivityTypes returns all activity types from Garmin Connect.

func (*Client) GetActivityWeather

func (c *Client) GetActivityWeather(ctx context.Context, activityID string) (json.RawMessage, error)

GetActivityWeather returns weather data for an activity.

func (*Client) GetAllDayEvents

func (c *Client) GetAllDayEvents(ctx context.Context, date string) (json.RawMessage, error)

GetAllDayEvents returns daily wellness events for a given date. Date format: YYYY-MM-DD.

func (*Client) GetBadgeChallenges

func (c *Client) GetBadgeChallenges(ctx context.Context) (json.RawMessage, error)

GetBadgeChallenges returns badge challenges.

func (*Client) GetBadgesAvailable

func (c *Client) GetBadgesAvailable(ctx context.Context) (json.RawMessage, error)

GetBadgesAvailable returns all available badges.

func (*Client) GetBadgesEarned

func (c *Client) GetBadgesEarned(ctx context.Context) (json.RawMessage, error)

GetBadgesEarned returns all badges earned by the user.

func (*Client) GetBadgesInProgress

func (c *Client) GetBadgesInProgress(ctx context.Context) (json.RawMessage, error)

GetBadgesInProgress returns badges currently in progress.

func (*Client) GetBloodPressure

func (c *Client) GetBloodPressure(ctx context.Context, startDate, endDate string) (json.RawMessage, error)

GetBloodPressure returns blood pressure data for a date range. Date format: YYYY-MM-DD.

func (*Client) GetBodyBattery

func (c *Client) GetBodyBattery(ctx context.Context, startDate, endDate string) (json.RawMessage, error)

GetBodyBattery returns body battery data for a date range. Date format: YYYY-MM-DD.

func (*Client) GetBodyComposition

func (c *Client) GetBodyComposition(ctx context.Context, startDate, endDate string) (json.RawMessage, error)

GetBodyComposition returns body composition data for a date range. Date format: YYYY-MM-DD.

func (*Client) GetCalendarWeek

func (c *Client) GetCalendarWeek(ctx context.Context, date string) (json.RawMessage, error)

GetCalendarWeek returns the calendar data for the week containing the given date. The date must be in YYYY-MM-DD format. The Garmin calendar API uses 0-indexed months.

func (*Client) GetChallenges

func (c *Client) GetChallenges(ctx context.Context) (json.RawMessage, error)

GetChallenges returns active challenges the user is participating in.

func (*Client) GetCourse added in v1.0.0

func (c *Client) GetCourse(ctx context.Context, courseID string) (json.RawMessage, error)

GetCourse returns details for a specific course.

func (*Client) GetCourseElevation added in v1.1.0

func (c *Client) GetCourseElevation(ctx context.Context, points json.RawMessage) (json.RawMessage, error)

GetCourseElevation enriches geo points with elevation data.

func (*Client) GetCourseFavorites added in v1.0.0

func (c *Client) GetCourseFavorites(ctx context.Context) (json.RawMessage, error)

GetCourseFavorites returns the user's favorite courses.

func (*Client) GetCourses added in v1.0.0

func (c *Client) GetCourses(ctx context.Context) (json.RawMessage, error)

GetCourses returns all courses owned by the current user.

func (*Client) GetCyclingFTP

func (c *Client) GetCyclingFTP(ctx context.Context) (json.RawMessage, error)

GetCyclingFTP returns the latest cycling functional threshold power.

func (*Client) GetDailySteps

func (c *Client) GetDailySteps(ctx context.Context, startDate, endDate string) (json.RawMessage, error)

GetDailySteps returns daily step data for a date range. Date format: YYYY-MM-DD.

func (*Client) GetDailySummary

func (c *Client) GetDailySummary(ctx context.Context, displayName, date string) (json.RawMessage, error)

GetDailySummary returns the user's daily summary for a given date. Date format: YYYY-MM-DD.

func (*Client) GetDailyWeighIns

func (c *Client) GetDailyWeighIns(ctx context.Context, date string) (json.RawMessage, error)

GetDailyWeighIns returns weigh-in data for a single day. Date format: YYYY-MM-DD.

func (*Client) GetDeviceAlarms

func (c *Client) GetDeviceAlarms(ctx context.Context) (json.RawMessage, error)

GetDeviceAlarms returns alarms from all devices by fetching device settings for each registered device.

func (*Client) GetDeviceSettings

func (c *Client) GetDeviceSettings(ctx context.Context, deviceID string) (json.RawMessage, error)

GetDeviceSettings returns settings for a specific device.

func (*Client) GetDeviceSolar

func (c *Client) GetDeviceSolar(ctx context.Context, deviceID, startDate, endDate string) (json.RawMessage, error)

GetDeviceSolar returns solar charging data for a compatible device. Date format: YYYY-MM-DD.

func (*Client) GetDevices

func (c *Client) GetDevices(ctx context.Context) (json.RawMessage, error)

GetDevices returns all registered devices for the current user.

func (*Client) GetDisplayName added in v0.3.0

func (c *Client) GetDisplayName(ctx context.Context) (string, error)

GetDisplayName returns the authenticated user's display name from profile settings.

func (*Client) GetEnduranceScore

func (c *Client) GetEnduranceScore(ctx context.Context, date string) (json.RawMessage, error)

GetEnduranceScore returns endurance score data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetEvents added in v1.2.0

func (c *Client) GetEvents(ctx context.Context, startDate string, pageIndex, limit int, sortOrder string) (json.RawMessage, error)

GetEvents returns calendar events starting from a date with pagination.

func (*Client) GetFitnessAge

func (c *Client) GetFitnessAge(ctx context.Context, date string) (json.RawMessage, error)

GetFitnessAge returns fitness age data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetFloors

func (c *Client) GetFloors(ctx context.Context, date string) (json.RawMessage, error)

GetFloors returns floors climbed data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetGear

func (c *Client) GetGear(ctx context.Context, userProfilePK string) (json.RawMessage, error)

GetGear returns all gear for a user profile.

func (*Client) GetGearActivities

func (c *Client) GetGearActivities(ctx context.Context, gearUUID string, limit int) (json.RawMessage, error)

GetGearActivities returns activities linked to a specific gear item.

func (*Client) GetGearDefaults

func (c *Client) GetGearDefaults(ctx context.Context, userProfileNumber string) (json.RawMessage, error)

GetGearDefaults returns default gear per activity type for a user.

func (*Client) GetGearStats

func (c *Client) GetGearStats(ctx context.Context, gearUUID string) (json.RawMessage, error)

GetGearStats returns usage statistics for a specific gear item.

func (*Client) GetGoals

func (c *Client) GetGoals(ctx context.Context, status string) (json.RawMessage, error)

GetGoals returns the user's active goals. If status is non-empty, it filters by goal status (e.g. "active", "completed").

func (*Client) GetHRV

func (c *Client) GetHRV(ctx context.Context, date string) (json.RawMessage, error)

GetHRV returns heart rate variability data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetHeartRate

func (c *Client) GetHeartRate(ctx context.Context, displayName, date string) (json.RawMessage, error)

GetHeartRate returns heart rate data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetHillScore

func (c *Client) GetHillScore(ctx context.Context, date string) (json.RawMessage, error)

GetHillScore returns hill score data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetHydration

func (c *Client) GetHydration(ctx context.Context, date string) (json.RawMessage, error)

GetHydration returns hydration data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetIntensityMinutes

func (c *Client) GetIntensityMinutes(ctx context.Context, date string) (json.RawMessage, error)

GetIntensityMinutes returns intensity minutes data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetLactateThreshold

func (c *Client) GetLactateThreshold(ctx context.Context) (json.RawMessage, error)

GetLactateThreshold returns the latest lactate threshold data.

func (*Client) GetLastUsedDevice

func (c *Client) GetLastUsedDevice(ctx context.Context) (json.RawMessage, error)

GetLastUsedDevice returns the most recently used device.

func (*Client) GetLifestyleLogging

func (c *Client) GetLifestyleLogging(ctx context.Context, date string) (json.RawMessage, error)

GetLifestyleLogging returns lifestyle logging data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetMaxMetrics

func (c *Client) GetMaxMetrics(ctx context.Context, date string) (json.RawMessage, error)

GetMaxMetrics returns VO2max and other max metrics for a given date. Date format: YYYY-MM-DD.

func (*Client) GetMenstrualCycleData

func (c *Client) GetMenstrualCycleData(ctx context.Context, startDate, endDate string) (json.RawMessage, error)

GetMenstrualCycleData returns menstrual cycle data for a given date range. Date format: YYYY-MM-DD.

func (*Client) GetMenstrualCycleSummary

func (c *Client) GetMenstrualCycleSummary(ctx context.Context, startDate, endDate string) (json.RawMessage, error)

GetMenstrualCycleSummary returns menstrual cycle summary data for a given date range. Date format: YYYY-MM-DD.

func (*Client) GetNutritionDailyFoodLog added in v1.6.0

func (c *Client) GetNutritionDailyFoodLog(ctx context.Context, date string) (json.RawMessage, error)

GetNutritionDailyFoodLog returns nutrition food log data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetNutritionDailyMeals added in v1.6.0

func (c *Client) GetNutritionDailyMeals(ctx context.Context, date string) (json.RawMessage, error)

GetNutritionDailyMeals returns nutrition meal summary data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetNutritionDailySettings added in v1.6.0

func (c *Client) GetNutritionDailySettings(ctx context.Context, date string) (json.RawMessage, error)

GetNutritionDailySettings returns nutrition settings for a given date. Date format: YYYY-MM-DD.

func (*Client) GetPersonalRecords

func (c *Client) GetPersonalRecords(ctx context.Context, ownerDisplayName string) (json.RawMessage, error)

GetPersonalRecords returns the user's personal records for a given owner display name.

func (*Client) GetPregnancySummary

func (c *Client) GetPregnancySummary(ctx context.Context) (json.RawMessage, error)

GetPregnancySummary returns pregnancy summary data.

func (*Client) GetPrimaryTrainingDevice

func (c *Client) GetPrimaryTrainingDevice(ctx context.Context) (json.RawMessage, error)

GetPrimaryTrainingDevice returns information about the primary training device.

func (*Client) GetProfile

func (c *Client) GetProfile(ctx context.Context) (json.RawMessage, error)

GetProfile returns the authenticated user's profile settings.

func (*Client) GetRacePredictions

func (c *Client) GetRacePredictions(ctx context.Context, startDate, endDate string) (json.RawMessage, error)

GetRacePredictions returns race prediction data. If startDate and endDate are empty, returns current predictions. Date format: YYYY-MM-DD.

func (*Client) GetRespiration

func (c *Client) GetRespiration(ctx context.Context, date string) (json.RawMessage, error)

GetRespiration returns respiration data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetRestingHeartRate

func (c *Client) GetRestingHeartRate(ctx context.Context, displayName, date string) (json.RawMessage, error)

GetRestingHeartRate returns resting heart rate data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetSPO2

func (c *Client) GetSPO2(ctx context.Context, date string) (json.RawMessage, error)

GetSPO2 returns SpO2 (blood oxygen) data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetSleep

func (c *Client) GetSleep(ctx context.Context, displayName, date string) (json.RawMessage, error)

GetSleep returns sleep data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetSocialProfile

func (c *Client) GetSocialProfile(ctx context.Context) (json.RawMessage, error)

GetSocialProfile returns the authenticated user's social profile. It first resolves the display name via profile settings, then fetches the social profile. The response includes profileId needed by other API calls.

func (*Client) GetSteps

func (c *Client) GetSteps(ctx context.Context, displayName, date string) (json.RawMessage, error)

GetSteps returns step chart data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetStress

func (c *Client) GetStress(ctx context.Context, date string) (json.RawMessage, error)

GetStress returns stress data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetTrainingPlan

func (c *Client) GetTrainingPlan(ctx context.Context, planID string) (json.RawMessage, error)

GetTrainingPlan returns a specific training plan by ID.

func (*Client) GetTrainingPlans

func (c *Client) GetTrainingPlans(ctx context.Context, locale string) (json.RawMessage, error)

GetTrainingPlans returns the user's training plans.

func (*Client) GetTrainingReadiness

func (c *Client) GetTrainingReadiness(ctx context.Context, date string) (json.RawMessage, error)

GetTrainingReadiness returns training readiness data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetTrainingStatus

func (c *Client) GetTrainingStatus(ctx context.Context, date string) (json.RawMessage, error)

GetTrainingStatus returns training status data for a given date. Date format: YYYY-MM-DD.

func (*Client) GetUserSettings

func (c *Client) GetUserSettings(ctx context.Context) (json.RawMessage, error)

GetUserSettings returns the authenticated user's settings.

func (*Client) GetWeeklyIntensityMinutes

func (c *Client) GetWeeklyIntensityMinutes(ctx context.Context, startDate, endDate string) (json.RawMessage, error)

GetWeeklyIntensityMinutes returns weekly intensity minutes data for a date range. Date format: YYYY-MM-DD.

func (*Client) GetWeeklySteps

func (c *Client) GetWeeklySteps(ctx context.Context, endDate string, weeks int) (json.RawMessage, error)

GetWeeklySteps returns weekly step data ending at the given date. Date format: YYYY-MM-DD.

func (*Client) GetWeeklyStress

func (c *Client) GetWeeklyStress(ctx context.Context, endDate string, weeks int) (json.RawMessage, error)

GetWeeklyStress returns weekly stress data ending at the given date. Date format: YYYY-MM-DD.

func (*Client) GetWeighIns

func (c *Client) GetWeighIns(ctx context.Context, startDate, endDate string) (json.RawMessage, error)

GetWeighIns returns weigh-in data for a date range. Date format: YYYY-MM-DD.

func (*Client) GetWorkout

func (c *Client) GetWorkout(ctx context.Context, workoutID string) (json.RawMessage, error)

GetWorkout returns a single workout by ID.

func (*Client) GetWorkouts

func (c *Client) GetWorkouts(ctx context.Context, start, limit int) (json.RawMessage, error)

GetWorkouts returns a page of workouts.

func (*Client) ImportCourseGPX added in v1.1.0

func (c *Client) ImportCourseGPX(ctx context.Context, filePath string) (json.RawMessage, error)

ImportCourseGPX uploads a GPX file and returns parsed course data.

func (*Client) LinkGear

func (c *Client) LinkGear(ctx context.Context, gearUUID, activityID string) (json.RawMessage, error)

LinkGear links a gear item to an activity.

func (*Client) RenameActivity

func (c *Client) RenameActivity(ctx context.Context, activityID string, name string) (json.RawMessage, error)

RenameActivity updates the name of an activity.

func (*Client) RequestReload

func (c *Client) RequestReload(ctx context.Context, date string) (json.RawMessage, error)

RequestReload requests Garmin to reload data for a given date. Date format: YYYY-MM-DD.

func (*Client) RetypeActivity

func (c *Client) RetypeActivity(ctx context.Context, activityID string, typeID int, typeKey string, parentTypeID int) (json.RawMessage, error)

RetypeActivity changes the activity type.

func (*Client) SaveCourse added in v1.1.0

func (c *Client) SaveCourse(ctx context.Context, course json.RawMessage) (json.RawMessage, error)

SaveCourse creates a new course from enriched course data. The course payload must include coursePrivacy (1=public, 2=private, 4=group) and rulePK (must not be null, typically 2).

func (*Client) ScheduleWorkout

func (c *Client) ScheduleWorkout(ctx context.Context, workoutID, date string) (json.RawMessage, error)

ScheduleWorkout schedules a workout on a calendar date.

func (*Client) SearchActivities

func (c *Client) SearchActivities(ctx context.Context, start, limit int, startDate, endDate string) (json.RawMessage, error)

SearchActivities returns activities matching date range and optional filters.

func (*Client) SendCourseToDevice added in v1.0.0

func (c *Client) SendCourseToDevice(ctx context.Context, courseID, deviceID, courseName string) (json.RawMessage, error)

SendCourseToDevice sends a course to a device via the device message API.

func (*Client) SetExerciseSets added in v1.4.0

func (c *Client) SetExerciseSets(ctx context.Context, activityID string, payload json.RawMessage) error

SetExerciseSets sets exercise sets for a strength training activity.

func (*Client) Tokens

func (c *Client) Tokens() *garminauth.Tokens

Tokens returns the current tokens held by the client.

func (*Client) UnlinkGear

func (c *Client) UnlinkGear(ctx context.Context, gearUUID, activityID string) (json.RawMessage, error)

UnlinkGear unlinks a gear item from an activity.

func (*Client) UnscheduleWorkout

func (c *Client) UnscheduleWorkout(ctx context.Context, scheduleID string) error

UnscheduleWorkout removes a scheduled workout from the calendar.

func (*Client) UploadActivity

func (c *Client) UploadActivity(ctx context.Context, filePath string) (json.RawMessage, error)

UploadActivity uploads an activity file (FIT, GPX, or TCX).

func (*Client) UploadBodyComposition

func (c *Client) UploadBodyComposition(ctx context.Context, fitData []byte) (json.RawMessage, error)

UploadBodyComposition uploads a FIT-encoded body composition file.

func (*Client) UploadWorkout

func (c *Client) UploadWorkout(ctx context.Context, workoutJSON json.RawMessage) (json.RawMessage, error)

UploadWorkout uploads a workout from JSON data.

type ClientOption

type ClientOption func(*Client)

ClientOption configures a Client.

func WithBaseURL

func WithBaseURL(u string) ClientOption

WithBaseURL overrides the API base URL.

func WithHTTPClient

func WithHTTPClient(c *http.Client) ClientOption

WithHTTPClient sets a custom HTTP client.

type DownloadFormat added in v1.9.0

type DownloadFormat string

DownloadFormat represents a supported export format.

const (
	FormatFIT DownloadFormat = "fit"
	FormatTCX DownloadFormat = "tcx"
	FormatGPX DownloadFormat = "gpx"
	FormatKML DownloadFormat = "kml"
	FormatCSV DownloadFormat = "csv"
)

type GarminAPIError

type GarminAPIError struct {
	StatusCode int
	Message    string
}

GarminAPIError represents a non-2xx error response from the Garmin Connect API.

func (*GarminAPIError) Error

func (e *GarminAPIError) Error() string

type InvalidFileFormatError

type InvalidFileFormatError struct {
	Format string
}

InvalidFileFormatError indicates an unsupported file format was requested.

func (*InvalidFileFormatError) Error

func (e *InvalidFileFormatError) Error() string

type RateLimitError

type RateLimitError struct {
	RetryAfter string
}

RateLimitError indicates the API returned a 429 Too Many Requests response.

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

type RetryTransport

type RetryTransport struct {
	// Base is the underlying RoundTripper. If nil, http.DefaultTransport is used.
	Base http.RoundTripper

	// MaxRetries429 is the maximum number of retries for 429 responses. Default: 3.
	MaxRetries429 int

	// MaxRetries5xx is the maximum number of retries for 5xx responses. Default: 2.
	MaxRetries5xx int
	// contains filtered or unexported fields
}

RetryTransport wraps an http.RoundTripper and retries requests on 429 (Too Many Requests) and 5xx responses with backoff.

func NewRetryTransport

func NewRetryTransport(base http.RoundTripper) *RetryTransport

NewRetryTransport creates a RetryTransport with sensible defaults.

func (*RetryTransport) RoundTrip

func (t *RetryTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper with retry logic.

type TokenExpiredError

type TokenExpiredError struct {
	Email string
}

TokenExpiredError indicates the stored token has expired and could not be refreshed.

func (*TokenExpiredError) Error

func (e *TokenExpiredError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL